# Merge paddle subscriptions with stripe payment history

> Paddle subscription status and Stripe invoices in single client request. For "merge paddle subscriptions with stripe payment history", store PADDLE_API_KEY, STRIPE_SECRET_KEY in Secret Vault, call https://api.paddle.com/subscriptions/{{query.subscriptionId}} from a Worker, and let React / Flutter / Mobile hit only https://realcomposer.com/v1/workspace/merge-paddle-with-stripe-billing-api with an rc_live_ client token.

- Canonical page: https://realcomposer.com/recipes/merge-paddle-with-stripe-billing-api
- Client platform: React / Flutter / Mobile
- Upstream services: Paddle, Stripe
- Category: Multi-API Aggregation
- JSON version: https://realcomposer.com/recipes/merge-paddle-with-stripe-billing-api.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=merge-paddle-with-stripe-billing-api&via=agent

## Problem: Serial Paddle and Stripe calls slow React / Flutter / Mobile pages

Each extra Paddle and Stripe hop adds hundreds of milliseconds and another OAuth refresh path your UI must manage.

- One slow upstream blocking an entire page
- Partial failures leaving UI in inconsistent states
- Duplicate auth refresh logic per service

## Solution steps

1. **Bind vault keys to the Worker**: Create PADDLE_API_KEY, STRIPE_SECRET_KEY vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.

2. **Configure upstream steps and output mapping**: Configure headersTemplate to inject vault secrets, target https://api.paddle.com/subscriptions/{{query.subscriptionId}}, and Add output mapping fields that mirror the JSON contract your screen already expects.

3. **Call from React / Flutter / Mobile**: Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.

```
const res = await fetch('https://realcomposer.com/v1/workspace/merge-paddle-with-stripe-billing-api', {
  headers: { Authorization: 'Bearer rc_live_your_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": "Merge paddle subscriptions with stripe payment history",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "paddle",
      "upstreamUrlTemplate": "https://api.paddle.com/subscriptions/{{query.subscriptionId}}",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.PADDLE_API_KEY}}"
      },
      "timeoutMs": 3000
    },
    {
      "stepKey": "stripe",
      "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": "paddle.subscriptionId",
        "sourcePath": "data.id",
        "type": "string",
        "sourceStep": "paddle"
      },
      {
        "targetPath": "paddle.status",
        "sourcePath": "data.status",
        "type": "string",
        "sourceStep": "paddle"
      },
      {
        "targetPath": "stripe.customerId",
        "sourcePath": "id",
        "type": "string",
        "sourceStep": "stripe"
      },
      {
        "targetPath": "stripe.email",
        "sourcePath": "email",
        "type": "string",
        "sourceStep": "stripe"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/merge-paddle-with-stripe-billing-api" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_merge-pa",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "merge-paddle-with-stripe-billing-api"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "paddle_subscriptionId": "sample",
  "paddle_status": "sample",
  "stripe_customerId": "sample",
  "stripe_email": "sample"
}
```

## FAQ

### Can React / Flutter / Mobile call Paddle without holding the production key?

Point React / Flutter / Mobile at /recipes/merge-paddle-with-stripe-billing-api edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins.

### Does POST traffic get cached?

merge-paddle-with-stripe-billing-api keeps cache TTL at 0 because it uses POST upstream calls or per-user responses. Add ids to query strings before enabling GET cache.

### Can I restrict which domains call this pipeline?

Allowed origins on the merge-paddle-with-stripe-billing-api client token restrict which domains may call the edge URL.
