Xendit Setup & Integration Guide
The xendit provider integrates Xendit Invoices (Virtual Accounts, E-Wallets, QRIS, Credit Cards, Retail Outlets) and Refunds across Southeast Asian markets (IDR, PHP, THB, VND, MYR, USD).
1. Prerequisites & Installation
Section titled “1. Prerequisites & Installation”Kirak communicates with Xendit directly via async REST API calls with httpx. No external Xendit SDK or additional pip package is required.
pip install "kirak"2. Credentials & Configuration
Section titled “2. Credentials & Configuration”Step 1: Obtain Secret Key
Section titled “Step 1: Obtain Secret Key”In the Xendit Dashboard:
- Navigate to Settings $\rightarrow$ API Keys.
- Create a secret key with write access to Money-in:
xnd_development_...(Test mode)xnd_production_...(Live mode)
Step 2: Configure Webhooks
Section titled “Step 2: Configure Webhooks”In Settings $\rightarrow$ Webhooks:
- Set the Invoices URL (Invoice Paid, Invoice Expired) and Refund URL (Refund Succeeded) to:
https://your-domain.com/payments/webhook/xendit - Copy the Verification Token (Xendit delivers this in the
x-callback-tokenheader).
Step 3: Configure kirak.json
Section titled “Step 3: Configure kirak.json”{ "payments": { "default_provider": "xendit", "providers": { "xendit": { "type": "xendit", "environment": "test", "success_url": "https://your-domain.com/payment/success" } } }}[!NOTE] The
environmentsetting ("test"or"live") must match your key’s prefix (xnd_development_orxnd_production_). A mismatch raises aCONFIGURATION_ERRORat startup.
Step 4: Set Environment Variables
Section titled “Step 4: Set Environment Variables”KIRAK_PAYMENT_XENDIT_SECRET_KEY=xnd_development_...KIRAK_PAYMENT_XENDIT_CALLBACK_TOKEN=your_verification_token_from_step23. Usage Examples
Section titled “3. Usage Examples”3.1 One-Time Invoice Checkout
Section titled “3.1 One-Time Invoice Checkout”Amounts are passed in minor units (e.g. for IDR, whole rupiah is sent to the gateway; pass minor-unit equivalents):
result = await kirak.payments.initiate_payment({ "provider": "xendit", "user_id": "usr_900", "amount": 150000, # Rp 150,000 IDR "currency": "IDR", "name": "E-Commerce Purchase", "type": "one_time", "payment_email": "buyer@example.co.id",})
invoice_url = result["data"]["url"]3.2 Verification & Refunds
Section titled “3.2 Verification & Refunds”# Verify payment upon customer return:await kirak.payments.verify_payment({ "provider": "xendit", "payment_id": result["data"]["reference"],})
# Issue refund (Admin / System only):await kirak.payments.refund_payment({ "provider": "xendit", "payment_id": "inv_xxxxxxxxxxxx", "amount": 50000, "currency": "IDR", "idempotency_key": "refund-xnd-900-1",})4. Feature Limitations
Section titled “4. Feature Limitations”| Feature | Support Status | Notes |
|---|---|---|
| One-Time Invoices | Supported | Supports QRIS, OVO, Dana, Virtual Accounts, Cards |
| Refunds | Supported | Dispatched via /refunds endpoint |
| Subscriptions | Not Supported | Returns 501 NOT_SUPPORTED; Xendit Recurring API requires customer pre-linking |
| Disputes | Not Supported | Xendit does not offer a public programmatic disputes API |
| Saved Payment Methods | Not Supported | Returns 501 NOT_SUPPORTED |
5. Webhook Event Mapping
Section titled “5. Webhook Event Mapping”Normalized event |
Gateway Events | Description |
|---|---|---|
payment_completed |
invoice.paid |
Invoice paid via VA, QRIS, card, or e-wallet |
payment_failed |
invoice.expired |
Invoice expired unpaid |
refund_completed |
refund.succeeded |
Refund processed |