# How to Call Stripe API from React Native Without Leaking Secret Key

> React Native APK and IPA bundles can be disassembled with standard decompilers, exposing hardcoded environment variables. Use RealComposer to store your Stripe Secret Key server-side on Cloudflare Workers and return only safe, slimmed responses to your mobile app.

- Canonical page: https://realcomposer.com/recipes/stripe-proxy-react-native
- Client platform: React Native / Expo
- Upstream services: Stripe
- Category: Security & Secret Vault
- JSON version: https://realcomposer.com/recipes/stripe-proxy-react-native.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=stripe-proxy-react-native&via=agent

## Problem: Decompiled Mobile Bundles Reveal All Constants

React Native javascript bundles (index.android.bundle) are plain text inside mobile installation packages.

- Plaintext key extraction from mobile APKs
- Fraudulent charge generation
- Compromised customer data

## Solution steps

1. **Store Secret in Vault**: Encrypted with AES-256-GCM in RealComposer.

2. **Call from Expo / React Native**: Fetch edge endpoint with public bearer token.

## Pipeline config

Import this config into a RealComposer pipeline. `{{secrets.NAME}}` values are read from the encrypted Secret Vault at request time, so the client never sees them.

```json
{
  "name": "React Native Stripe Proxy",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "steps": [
    {
      "stepKey": "sub",
      "upstreamUrlTemplate": "https://api.stripe.com/v1/subscriptions/{{query.subId}}",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.STRIPE_SECRET_KEY}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "id",
        "sourceStep": "sub",
        "sourcePath": "id"
      },
      {
        "targetPath": "status",
        "sourceStep": "sub",
        "sourcePath": "status"
      },
      {
        "targetPath": "currentPeriodEnd",
        "sourceStep": "sub",
        "sourcePath": "current_period_end",
        "type": "number"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/acme/sub-status?subId=sub_123"
```

## Payload before and after

Raw upstream response:

```json
{
  "id": "sub_123",
  "status": "active",
  "current_period_end": 1712000000,
  "plan": {}
}
```

Slimmed RealComposer response:

```json
{
  "id": "sub_123",
  "status": "active",
  "currentPeriodEnd": 1712000000
}
```

## FAQ

### Is Hermes byte-code decompilation safe?

No, Hermes bytecode can be easily decompiled to extract string literals.
