# How to Call Stripe API from FlutterFlow Securely Without Exposing Secret Key

> To call the Stripe API from FlutterFlow securely, never place your Stripe Secret Key (sk_live_...) inside FlutterFlow API call headers or variables. Instead, store your secret in RealComposer Secret Vault and make your FlutterFlow API call to RealComposer edge URL with a restricted client token. RealComposer automatically injects your Stripe Secret Key server-side on Cloudflare Workers, keeping your key 100% invisible to client decompilation.

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

## Problem: The Danger of Direct Stripe Calls in FlutterFlow

FlutterFlow compiles apps directly into Dart/Flutter client code for iOS, Android, and Web. If you configure a custom API call in FlutterFlow with an Authorization header containing sk_live_..., any user can decompile your Android APK, inspect the web network console, or run a proxy like Charles/Mitmproxy to extract your master Stripe secret key. With this key, an attacker can issue unauthorized refunds, drain payouts, or steal customer PII.

- Secret key extraction by decompiling Android APK or inspecting browser DevTools
- Unauthorized refunds, customer balance transfers, and account draining
- Permanent Stripe account suspension due to compliance violations

## Solution steps

1. **Save Stripe Secret Key in RealComposer Secret Vault**: Open your RealComposer Secret Vault dashboard and add STRIPE_SECRET_KEY with your sk_live_... value. It is encrypted using AES-256-GCM and bound to your workspace.

2. **Compose Your Edge Endpoint**: Configure upstream step to https://api.stripe.com/v1/customers with header Authorization: Bearer {{secrets.STRIPE_SECRET_KEY}}. RealComposer injects the secret server-side on Cloudflare Workers.

3. **Call from FlutterFlow with Restricted Client Token**: In FlutterFlow API Calls, set your URL to https://realcomposer.com/v1/your-workspace/stripe-customer and add header Authorization: Bearer rc_live_.... Your app is completely secured.

```
// FlutterFlow Custom API Call
Endpoint: https://realcomposer.com/v1/acme/stripe-customer
Headers:
  Authorization: Bearer rc_live_99a8b7c6...
  Content-Type: application/json
```

## 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": "FlutterFlow Stripe Customer Proxy",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "stripeCustomer",
      "upstreamUrlTemplate": "https://api.stripe.com/v1/customers/{{query.customerId}}",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.STRIPE_SECRET_KEY}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "customerId",
        "sourceStep": "stripeCustomer",
        "sourcePath": "id"
      },
      {
        "targetPath": "email",
        "sourceStep": "stripeCustomer",
        "sourcePath": "email"
      },
      {
        "targetPath": "name",
        "sourceStep": "stripeCustomer",
        "sourcePath": "name"
      },
      {
        "targetPath": "balance",
        "sourceStep": "stripeCustomer",
        "sourcePath": "balance",
        "type": "number"
      },
      {
        "targetPath": "currency",
        "sourceStep": "stripeCustomer",
        "sourcePath": "currency"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/acme/stripe-customer?customerId=cus_Q129abc456XYZ" \
  -H "Authorization: Bearer rc_live_your_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "id": "cus_Q129abc456XYZ",
  "object": "customer",
  "address": {
    "city": "San Francisco",
    "line1": "510 Townsend St",
    "postal_code": "94103"
  },
  "balance": 0,
  "created": 1689230400,
  "currency": "usd",
  "default_source": "card_1MnXYZ456",
  "delinquent": false,
  "description": "Enterprise billing account",
  "email": "alex@acme.com",
  "invoice_prefix": "9A2B3C",
  "invoice_settings": {
    "default_payment_method": "pm_194723812398"
  },
  "livemode": true,
  "metadata": {
    "internal_id": "usr_8819"
  },
  "name": "Alex Johnson",
  "phone": "+14155552671",
  "tax_exempt": "none"
}
```

Slimmed RealComposer response:

```json
{
  "customerId": "cus_Q129abc456XYZ",
  "email": "alex@acme.com",
  "name": "Alex Johnson",
  "balance": 0,
  "currency": "usd"
}
```

## FAQ

### Does FlutterFlow have a built-in way to hide Stripe secret keys in custom API calls?

No. FlutterFlow only hides keys when using their native Stripe Checkout widget. For custom API calls (creating customers, fetching invoices, managing subscriptions), any secret key in the API builder is embedded in client code unless routed through a backend proxy like RealComposer.

### What is the latency overhead of using RealComposer between FlutterFlow and Stripe?

RealComposer runs directly on Cloudflare Workers edge network within milliseconds of Stripe servers. The proxy adds less than 3ms to the overall execution.
