Paddle
The Paddle extension connects Billing to Paddle Billing. Paddle sells as merchant of record: buyers pay Paddle, and Paddle collects and files sales tax and VAT, approves refunds and handles disputes. Paddle's webhooks keep Billing's items current, and users manage cards and invoices in Paddle's customer portal.
Install
Add it to your build next to Billing (Add Billing to your app):
set.Add(billing.New(billing.Config{}), paddle.New(paddle.Config{}))
The module is pocketone.dev/ext/paddle.
Keys
In the dashboard, open Billing → Settings. Paddle's section is below Billing's own. All three come from Paddle's Developer tools.
| Setting | Where to find it |
|---|---|
| API key | Developer tools → Authentication. A sandbox key (pdl_sdbx_apikey_) uses Paddle's sandbox. |
| Client-side token | Same page (test_ in the sandbox, live_ in production). The checkout page loads Paddle.js with it; it isn't secret. |
| Webhook secret key | The pdl_ntfset_ secret of the notification destination below. |
The API key and token must come from the same account: both sandbox or both live. Press Test to check the key, then Save changes.
Paddle's sandbox is a separate account at sandbox-vendors.paddle.com, with its own products and keys.
Webhooks
Add a notification destination (Developer tools → Notifications) at the URL shown in Paddle's settings section:
<your app>/api/_c/billing/v1/webhook?provider=paddle. Send these events:
transaction.completed,transaction.payment_failedsubscription.created,subscription.updated,subscription.activated,subscription.canceled,subscription.paused,subscription.resumed,subscription.past_due,subscription.trialingadjustment.created,adjustment.updated
Paste the destination's secret key into the settings.
Try it on your machine
Paddle sends webhooks only to a public HTTPS address. Put your local app behind a tunnel and use the tunnel's address for the notification destination:
cloudflared tunnel --url http://localhost:8090
# or: ngrok http 8090
Set the app's Application URL (Settings → Application) to the tunnel's address too, so the checkout page and
return URLs use it. Use sandbox keys, start a checkout, and pay with card 4242 4242 4242 4242, any future date and
CVC 100.
Checkout and your domain
Paddle's checkout runs on a page Billing serves at /api/_c/billing/v1/pay: it opens Paddle's checkout over the page,
and closing it sends the buyer to the cancel URL. Live checkouts need your app's domain approved under
Checkout → Website approval in Paddle. Set a default payment link there too (any page on your domain).
Products
In Paddle, make a product with a price: with a billing cycle for a subscription product, without one for an order. On
Billing → Products, set prices to the price id: {"paddle": "pri_..."}. Check prices confirms it.
What Billing's calls do at Paddle
| Billing | Paddle |
|---|---|
checkout |
A transaction for the product's price and quantity, opened with Paddle.js. |
portal |
A customer portal session. |
cancel, resume |
Cancels at the next billing period or now; removes a scheduled cancel. |
quantity, plan |
Updates the subscription's items, prorated as asked. |
refund |
A refund adjustment, in full or in part. Paddle approves it, so it stays pending until Paddle does. |
A one-time purchase is its transaction (txn_...).
The extension's reference is on its extension page.
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.