> ## Documentation Index
> Fetch the complete documentation index at: https://docs.affixo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect Paddle

> Paste one Paddle API key and Affixo tracks your Paddle Billing sales, renewals, refunds and chargebacks on its own. No webhook to copy and no server code.

If you sell through [Paddle Billing](https://www.paddle.com/billing), you don't need to write any code to run your affiliate program. You paste one Paddle API key into Affixo. Affixo checks it, adds its own notification destination in your Paddle account, and from then on every completed transaction, renewal, refund and chargeback comes in by itself and pays (or takes back) the right commission.

```mermaid theme={null}
flowchart TD
  A["Affiliate link"] --> B["Your site with the Affixo snippet"]
  B --> C["Paddle.js checkout (carries the visitor id)"]
  C --> D["Paddle sends the transaction to Affixo"]
  D --> E["Commission for the affiliate"]
```

Affixo only reads your Paddle sales. It never charges your customers, never issues refunds in Paddle, and never pays your affiliates for you.

> [!NOTE]
>
> **Paddle connections are rolling out.** If you don't see **I use Paddle** on **Settings → Payments & products**, it isn't switched on for your account yet. Until then you can report Paddle sales from your server, as described in [Connect any payment processor](https://docs.affixo.dev/connect-any-processor.md).

This guide is for **Paddle Billing**. Paddle Classic accounts (the older Paddle, with numeric vendor ids) aren't supported.

## Before you start

You need:

* **The Affixo snippet** on every page of your site, as described in [Integrate Affixo tracking](https://docs.affixo.dev/integrate.md). It is what tells Paddle which affiliate sent the buyer.
* **A program with a commission set**, so a sale has something to pay.
* **Access to Developer tools in Paddle**, to create the API key.
* **Billing access in Affixo**, to change how your workspace takes payments.

> [!WARNING]
>
> **One processor per account.** A workspace takes its sales from Stripe, from Paddle, from Polar, or from your own server, never more than one. If this workspace has already used Stripe, it can't switch to Paddle. Use a new workspace for your Paddle products, or contact support if you think the Stripe link is a mistake.

## Step 1: Create a Paddle API key

In Paddle, open **Developer tools → Authentication**, go to **API keys** and create a new key. Give it these permissions and no others:

| Permission | Why Affixo needs it |
| - | - |
| `transaction.read` | Read each completed transaction and its amount |
| `adjustment.read` | Read refunds, so commissions on refunded sales shrink |
| `customer.read` | Read the buyer's email, which Paddle leaves off the transaction |
| `product.read` | Name the product on each sale |
| `subscription.read` | Link renewals to the first sale, for recurring commissions |
| `notification_setting.write` | Add, and later remove, Affixo's one notification destination in your Paddle account |

Copy the key when Paddle shows it. A live key starts with `pdl_live_apikey_`, a sandbox key with `pdl_sdbx_apikey_`.

Paddle keys expire, after 90 days unless you pick another date. Put a reminder in your calendar to reconnect with a new key before yours runs out. Paddle's own guide is [Authentication](https://developer.paddle.com/api-reference/about/authentication).

> [!TIP]
>
> None of these permissions lets Affixo create transactions, issue refunds or move money. Affixo asks Paddle what a key can do and refuses one that can also change anything else in your account, like refunds, prices or customers, so a leaked key could never be used for that. Older Paddle keys (made before May 2025, with no `pdl_` at the start) can't be limited like this, so Affixo doesn't accept them. Make a new key instead.

## Step 2: Paste it into Affixo

1. In Affixo, open **Settings → Payments & products** and choose **I use Paddle**.
2. Pick **Live** for your real store. (Use **Sandbox** for a sandbox key, see [Test it with the Paddle sandbox](#test-it-with-the-paddle-sandbox).)
3. Paste the key and click **Connect Paddle**.

Affixo then:

```mermaid theme={null}
flowchart TD
  A["You paste the key"] --> B["Affixo checks it with Paddle"]
  B -->|"Wrong key or a missing permission"| X["Nothing is saved. You see what to fix."]
  B -->|"OK"| C["Key stored encrypted"]
  C --> D["Affixo adds one notification destination in Paddle"]
  D -->|"Paddle already has 10 active"| Y["Nothing is saved. Turn one off in Paddle first."]
  D -->|"OK"| E["Connected"]
```

You'll see the connection as **Connected**, with the last 4 characters of the key and the time of the last event from Paddle. Affixo never shows the key again. In Paddle, the new destination appears under **Developer tools → Notifications** as **Affixo affiliate tracking**. Leave it there: it is how your sales reach Affixo.

> [!NOTE]
>
> Paddle allows 10 active notification destinations per account. If you already have 10, Affixo tells you and saves nothing. Turn off one you no longer use in **Developer tools → Notifications**, then connect again.

## Step 3: Your Paddle checkouts

**Paddle.js checkouts on your site work as they are.** When a page with the snippet opens a Paddle checkout, through `Paddle.Checkout.open()` or a `paddle_button` element, the snippet adds the visitor's id to the checkout's custom data. Paddle keeps it on the transaction, and Affixo uses it to find the affiliate. Custom data you already pass is kept, and the snippet only adds one key, `affixo_visitor_id`.

**If your server creates transactions with Paddle's API**, pass the visitor id yourself:

```js theme={null}
// In the browser, before you call your server
const visitorId = await window.Affixo.ready();
// Send visitorId to your server with the order, then when you create the transaction:
// custom_data: { affixo_visitor_id: visitorId }
```

A checkout you open with a `transactionId` takes its custom data from that transaction, so set it there.

> [!WARNING]
>
> **Paddle's hosted checkout links can't carry the visitor id.** Paddle doesn't let a link add custom data. A sale through a hosted checkout link can only be matched by the buyer's email, if they signed up as a lead first. Use Paddle.js on your own pages for the strongest tracking. See [Attribution](https://docs.affixo.dev/attribution.md).

## What Affixo books

```mermaid theme={null}
flowchart LR
  P1["Transaction completed"] --> S["Sale + commission"]
  P2["Renewal completed"] --> R["Renewal sale + recurring commission"]
  P3["Refund approved"] --> F["Commission reduced or reversed"]
  P4["Chargeback"] --> C["Commission reversed"]
  P5["Chargeback reversed"] --> W["Commission restored"]
```

| In Paddle | In Affixo |
| - | - |
| A transaction completes | A sale on the subtotal after discounts and before tax. The commission follows your campaign's rules. |
| A \$0 transaction (a free trial, a 100% discount) | A lead, not a sale. It earns nothing, but later renewals still credit the same affiliate. |
| A subscription renews | A new sale for the same affiliate, paid if your campaign pays recurring commissions. |
| A refund is approved | The commission shrinks in proportion to everything refunded on that transaction so far. A $5 sale with $2 refunded pays commission on \$3. |
| A refund is waiting for approval, or rejected | Nothing changes. Only an approved refund takes commission back. |
| A transaction is fully refunded | The commission is reversed. |
| A chargeback | The commission is reversed. |
| A chargeback is reversed (you won the dispute) | The commission is restored. |
| A payment method change | Nothing. It isn't a purchase. |

Refunds and chargebacks count before tax, the same basis as the sale. Each Paddle event is booked once, however many times Paddle sends it.

## Test it with the Paddle sandbox

Paddle has a separate [sandbox](https://sandbox-vendors.paddle.com) with test cards. Connect it in Affixo as its own **Sandbox** connection. Sandbox sales book as **test sales** with test commissions, which are never paid and never counted in reports, payouts or alerts.

> [!WARNING]
>
> **Start every sandbox purchase from a test visit.** Affixo keeps test and live data apart: a sandbox sale only matches a test click, and a normal visit is a live click. If you click an affiliate link the usual way and then pay in the sandbox, the sale arrives but credits no one.

```mermaid theme={null}
flowchart TD
  A["Open yoursite.com/?ref=CODE&_sa_test=1"] --> B["Test click recorded"]
  B --> C["Buy with a Paddle.js sandbox checkout"]
  C --> D["Test sale + test commission on Referrals"]
```

1. In the Paddle sandbox, create a product and a price, and put a Paddle.js checkout for it on a page of your site that has the snippet (initialize Paddle.js with `environment: "sandbox"` and a sandbox client-side token). A test page is fine.
2. Create a sandbox API key with the same permissions as in step 1.
3. In Affixo, choose **Sandbox** on **Settings → Payments & products**, paste the sandbox key and click **Connect Paddle sandbox**.
4. Open your site through an affiliate's link with `_sa_test=1` added, for example `https://yoursite.com/?ref=jane&_sa_test=1`. That marks your visit as a test for the next 30 minutes in that browser. See [Test links](https://docs.affixo.dev/sa-js.md#test-links).
5. Open the checkout and pay with Paddle's sandbox test card `4242 4242 4242 4242`.
6. Within a few seconds the sale shows on **Referrals** as a test sale, credited to that affiliate. The **Check it works** box on the Paddle screen also says **Sandbox events are arriving**.
7. To test refunds, refund part of the transaction in the Paddle sandbox. Once Paddle approves the refund, the commission shrinks.

Paddle's webhook simulator sends made-up transactions, so Affixo's destination only listens to real sandbox events. Test with a real sandbox checkout, as above.

A sandbox connection doesn't count as your payments being connected. Connect **Live** before you launch.

## Change or remove the connection

* **Rotate the key:** create a new key in Paddle, then paste it with **Reconnect live** (or **Reconnect sandbox**). Affixo adds the new destination before it removes the old one, so no sale is missed. Use a key from the same Paddle account: the connection follows whichever key you paste.
* **Disconnect:** click **Disconnect** on the connection. Affixo removes its destination in Paddle and deletes the key. New sales stop coming in until you reconnect. Sales already booked stay as they are.
* **Stop using Paddle:** after disconnecting, **Use Stripe or another processor**, at the top of the page, takes you back to the list of options. This only works until your first real (live) Paddle sale. After that the workspace stays on Paddle.

## Troubleshooting

| What you see | What to do |
| - | - |
| "That doesn't look like a Paddle Billing API key" | You pasted something else, often a password your browser filled in, or an older key without `pdl_` at the start. Make a new key in Paddle and paste it. |
| "That's a Paddle sandbox key" (or "a live Paddle key") | Pick the other mode above the key box, or paste the key for the mode you picked. |
| "Paddle didn't accept that key" | The key is wrong, expired or revoked. |
| "That key is missing the ... permission" | Create a new key with every permission in step 1. |
| "That key can also change things in your Paddle account" | The key has a write permission Affixo doesn't need (the message names it). Create a new key with only the permissions in step 1. |
| "That key is for a different Paddle account" | You're reconnecting with a key from another Paddle account. Disconnect first, then connect the new one. |
| "This Paddle account is already connected to another Affixo workspace" | A live Paddle account can be connected to one workspace at a time, so one sale never pays two commissions. Disconnect it in the other workspace, then connect it here. If you can't get into that workspace, contact support. |
| "Your Paddle account already has 10 active notification destinations" | Turn one off in Paddle under **Developer tools → Notifications**, then connect again. |
| "Another connect attempt changed this connection while we were working" | Someone (or another tab) was connecting at the same time and that attempt failed. Nothing was saved. Connect again. |
| "Stripe has already been used on this workspace" | See [One processor per account](#before-you-start). |
| The connection says **Needs attention** | Paddle stopped accepting the key Affixo has, usually because it expired or was revoked. Reconnect with a new key. |
| A sandbox sale shows up with no affiliate | The visit wasn't a test visit. Start again from a `?_sa_test=1` link (step 4 of the sandbox test). |
| A live sale shows up with no affiliate | The buyer didn't come through an affiliate link, the checkout wasn't on a page with the snippet, it was a hosted checkout link, or your server made the transaction without `custom_data.affixo_visitor_id`. |
| A refund didn't change the commission | Paddle hasn't approved the refund yet. It counts once it's approved. |
| No events at all | Check that **Affixo affiliate tracking** is still active under **Developer tools → Notifications** in Paddle. If someone deleted or turned it off, reconnect with **Reconnect live**. |

Still stuck? Contact support and include the Paddle transaction id (it starts with `txn_`).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.