Paddle Billing Setup & Integration Guide
The paddle provider integrates Paddle Billing (Merchant of Record), Subscriptions, Customer Portal, and One-Time Subscription Charges into the Kirak payments runtime.
1. Prerequisites & Installation
Section titled “1. Prerequisites & Installation”Kirak connects to Paddle Billing directly via async REST API calls with httpx. No external Paddle SDK or additional pip package is required.
pip install "kirak"[!NOTE] Merchant of Record (MoR): Paddle acts as the Merchant of Record, collecting and remitting global sales tax/VAT on your behalf. A completed transaction’s
amountreflects the tax-inclusive grand total paid by the customer, andnet_amountstores your net payout earnings.
2. Credentials & Configuration
Section titled “2. Credentials & Configuration”Step 1: Obtain API Key
Section titled “Step 1: Obtain API Key”In the Paddle Dashboard (Sandbox or Live):
- Navigate to Developer Tools $\rightarrow$ Authentication.
- Generate an API key.
Step 2: Configure Checkout Domain
Section titled “Step 2: Configure Checkout Domain”In Paddle $\rightarrow$ Checkout $\rightarrow$ Checkout settings:
- Set the Default payment link to an approved page on your site that includes
Paddle.js. - When Kirak initiates a checkout, it returns your approved URL appended with
?_ptxn=<transaction_id>.
Step 3: Configure kirak.json
Section titled “Step 3: Configure kirak.json”{ "payments": { "default_provider": "paddle", "providers": { "paddle": { "type": "paddle", "environment": "sandbox", "default_tax_category": "standard" } } }}| Setting | Type | Default | Description |
|---|---|---|---|
environment |
string | "sandbox" |
"sandbox" or "production" |
default_tax_category |
string | "standard" |
Tax category used when auto-creating items without a catalog price_id |
checkout_url |
string | null |
Optional approved URL override for Paddle.js checkout |
Step 4: Set Environment Variables
Section titled “Step 4: Set Environment Variables”KIRAK_PAYMENT_PADDLE_API_KEY=...KIRAK_PAYMENT_PADDLE_WEBHOOK_SECRET=... # Obtained in Step 33. Configuring Webhooks
Section titled “3. Configuring Webhooks”In the Paddle Dashboard $\rightarrow$ Developer Tools $\rightarrow$ Notifications $\rightarrow$ New destination:
- URL:
https://your-domain.com/payments/webhook/paddle - Subscribe to Events:
- Transactions:
transaction.completed,transaction.canceled,transaction.payment_failed - Adjustments & Refunds:
adjustment.created,adjustment.updated - Subscriptions:
subscription.created,subscription.activated,subscription.updated,subscription.trialing,subscription.paused,subscription.resumed,subscription.past_due,subscription.canceled
- Transactions:
- Copy the generated Secret key into
KIRAK_PAYMENT_PADDLE_WEBHOOK_SECRET.
[!NOTE] Signature Verification: Paddle signs requests using the
Paddle-Signatureheader (ts=...;h1=...). Kirak verifies the HMAC-SHA256 hash of<ts>:<raw_body>against your configured secret key.
4. Usage Examples
Section titled “4. Usage Examples”4.1 One-Time Checkout with Catalog Price
Section titled “4.1 One-Time Checkout with Catalog Price”result = await kirak.payments.initiate_payment({ "provider": "paddle", "user_id": "usr_500", "amount": 2999, # $29.99 "currency": "USD", "name": "Desktop Pro", "type": "one_time", "price_id": "pri_01gsz8x8sawmvhz1pv30nge1ke", # Paddle Catalog Price ID})
checkout_url = result["data"]["url"]4.2 Subscriptions
Section titled “4.2 Subscriptions”result = await kirak.payments.initiate_payment({ "provider": "paddle", "user_id": "usr_500", "amount": 0, # Price defined by catalog price_id "currency": "USD", "name": "SaaS Starter Plan", "type": "subscription", "price_id": "pri_01h8abcdefghijk1234567890",})4.3 Customer Billing Portal
Section titled “4.3 Customer Billing Portal”Paddle provides a self-service customer portal where users can update payment cards or cancel their subscription:
portal = await kirak.payments.get_billing_portal({ "user_id": "usr_500", "provider": "paddle",})portal_url = portal["data"]["portal_url"]4.4 One-Time Charges on Existing Subscriptions
Section titled “4.4 One-Time Charges on Existing Subscriptions”Paddle does not keep standalone vaulted card tokens in Kirak. Instead, off-session charges are executed against an active subscription:
result = await kirak.payments.charge_off_session({ "provider": "paddle", "user_id": "usr_500", "amount": 1500, # $15.00 "currency": "USD", "name": "API Extra Usage", "subscription_id": "sub_01h8subxxxxxxxxxxxxxxxxx", "idempotency_key": "paddle-overage-usr500-oct",})5. Webhook Event Mapping
Section titled “5. Webhook Event Mapping”Normalized event |
Gateway Events | Description |
|---|---|---|
payment_completed |
transaction.completed |
Transaction paid and finalized |
payment_failed |
transaction.payment_failed |
Payment failed |
subscription_renewed |
transaction.completed (for recurring subscription cycle) |
Cycle billed |
subscription_updated |
subscription.updated, subscription.resumed |
Subscription modified |
subscription_past_due |
subscription.past_due |
Renewal charge failed |
subscription_cancelled |
subscription.canceled |
Subscription terminated |
refund_completed |
adjustment.created, adjustment.updated (action="refund") |
Refund issued |
dispute_created |
adjustment.created (action="chargeback") |
Chargeback opened |