# Paddle webhook and supabase user sync edge

> Edge receives Paddle webhook and updates Supabase in one flow. For "paddle webhook and supabase user sync edge", store PADDLE_API_KEY, SUPABASE_SERVICE_ROLE_KEY in Secret Vault, call https://api.paddle.com/subscriptions/{{query.subscriptionId}} from a Worker, and let Any Frontend / Mobile hit only https://realcomposer.com/v1/workspace/paddle-webhook-supabase-sync-edge with an rc_live_ client token.

- Canonical page: https://realcomposer.com/recipes/paddle-webhook-supabase-sync-edge
- Client platform: Any Frontend / Mobile
- Upstream services: Paddle, Supabase
- Category: Platforms & Frameworks
- JSON version: https://realcomposer.com/recipes/paddle-webhook-supabase-sync-edge.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=paddle-webhook-supabase-sync-edge&via=agent

## Problem: CORS blocks Paddle and Supabase in Any Frontend / Mobile

Low-code Any Frontend / Mobile tools expose connector tokens in shared workspaces, so Paddle and Supabase credentials leak to every editor.

- Browser console CORS errors blocking launches
- Editors pasting secrets into reusable components
- Inability to test locally without disabling security

## Solution steps

1. **Store upstream credentials in Secret Vault**: Create PADDLE_API_KEY, SUPABASE_SERVICE_ROLE_KEY vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.

2. **Configure upstream steps and output mapping**: Use GET against https://api.paddle.com/subscriptions/{{query.subscriptionId}}. Allowed origins on the client token should match leave cache ttl at 0 when each response is user-specific (include userid or record id in query params before enabling cache).

3. **Call from Any Frontend / 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/paddle-webhook-supabase-sync-edge', {
  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": "Paddle webhook and supabase user sync edge",
  "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": "supabase",
      "upstreamUrlTemplate": "https://{{secrets.SUPABASE_PROJECT_REF}}.supabase.co/rest/v1/{{query.table}}?{{query.filter}}",
      "httpMethod": "GET",
      "headersTemplate": {
        "apikey": "{{secrets.SUPABASE_SERVICE_ROLE_KEY}}",
        "Authorization": "Bearer {{secrets.SUPABASE_SERVICE_ROLE_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": "supabase.rowId",
        "sourcePath": "0.id",
        "type": "string",
        "sourceStep": "supabase"
      },
      {
        "targetPath": "supabase.email",
        "sourcePath": "0.email",
        "type": "string",
        "sourceStep": "supabase"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/paddle-webhook-supabase-sync-edge" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_paddle-w",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "paddle-webhook-supabase-sync-edge"
  },
  "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",
  "supabase_rowId": "sample",
  "supabase_email": "sample"
}
```

## FAQ

### Can Any Frontend / Mobile call Paddle without holding the production key?

Use scoped tokens where the vendor allows them on paddle-webhook-supabase-sync-edge. Admin keys stay {{secrets.*}} references only.

### How do I forward JSON bodies to POST upstreams?

paddle-webhook-supabase-sync-edge 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?

Upstream steps in paddle-webhook-supabase-sync-edge honor timeoutMs and optional fallback JSON without leaking secrets.
