# Retool connect paddle refunds securely

> Retool queries RealComposer for Paddle write operations. For "retool connect paddle refunds securely", store PADDLE_API_KEY in Secret Vault, call https://api.paddle.com/adjustments?action=refund&per_page=20 from a Worker, and let Retool hit only https://realcomposer.com/v1/workspace/retool-paddle-refunds-secure-proxy with an rc_live_ client token.

- Canonical page: https://realcomposer.com/recipes/retool-paddle-refunds-secure-proxy
- Client platform: Retool
- Upstream services: Paddle
- Category: Platforms & Frameworks
- JSON version: https://realcomposer.com/recipes/retool-paddle-refunds-secure-proxy.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=retool-paddle-refunds-secure-proxy&via=agent

## Problem: CORS blocks Paddle in Retool

Low-code Retool tools expose connector tokens in shared workspaces, so Paddle 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 vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.

2. **Target the real upstream URL**: Configure headersTemplate to inject vault secrets, target https://api.paddle.com/adjustments?action=refund&per_page=20, and Add output mapping fields that mirror the JSON contract your screen already expects.

3. **Query from Retool**: Allowed origins on the token should list every Retool host that calls this URL.

```
// REST resource or JS query
const rows = await fetch('https://realcomposer.com/v1/workspace/retool-paddle-refunds-secure-proxy', {
  headers: { Authorization: 'Bearer rc_live_token' }
}).then(r => r.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": "Retool connect paddle refunds securely",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "paddle",
      "upstreamUrlTemplate": "https://api.paddle.com/adjustments?action=refund&per_page=20",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.PADDLE_API_KEY}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "subscriptionId",
        "sourcePath": "data.id",
        "type": "string",
        "sourceStep": "paddle"
      },
      {
        "targetPath": "status",
        "sourcePath": "data.status",
        "type": "string",
        "sourceStep": "paddle"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/retool-paddle-refunds-secure-proxy" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_retool-p",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "retool-paddle-refunds-secure-proxy"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "subscriptionId": "sample",
  "status": "sample"
}
```

## FAQ

### Does Retool need CORS changes after adding RealComposer?

Store PADDLE_API_KEY for retool-paddle-refunds-secure-proxy. Retool never sees decrypted values.

### When does edge caching apply to this recipe?

retool-paddle-refunds-secure-proxy forwards client JSON to POST upstreams unchanged; secrets interpolate only in URLs and header templates.

### What happens if an upstream step times out?

Upstream steps in retool-paddle-refunds-secure-proxy honor timeoutMs and optional fallback JSON without leaking secrets.
