Payment Providers
RustBill integrates with multiple payment providers via feature-gated modules. Each provider handles checkout sessions, payment verification, and webhook processing.
Supported Providers
| Provider | Feature Flag | Checkout | Webhooks | Recurring |
|---|---|---|---|---|
| Stripe | stripe | Yes | Yes | Yes |
| Xendit | xendit (default) | Yes | Yes | Yes |
| LemonSqueezy | lemonsqueezy (default) | Yes | Yes | Yes |
Stripe Setup
1. Enable the Feature
# Cargo.toml
[features]
default = ["stripe", "xendit", "lemonsqueezy"]2. Configure Credentials
Set your Stripe keys via environment variables or the settings API:
export STRIPE_SECRET_KEY=sk_live_...
export STRIPE_WEBHOOK_SECRET=whsec_...Or configure via the admin settings API:
PUT /api/settings/providers/stripe
Content-Type: application/json
{
"secretKey": "sk_live_...",
"webhookSecret": "whsec_...",
"enabled": true
}3. Set Up Webhook Endpoint
In the Stripe Dashboard, create a webhook endpoint pointing to:
https://your-domain.com/api/billing/webhooks/stripeSubscribe to these events:
checkout.session.completedinvoice.paidinvoice.payment_failedcustomer.subscription.updated
Xendit Setup
1. Configure Credentials
export XENDIT_SECRET_KEY=xnd_...
export XENDIT_WEBHOOK_TOKEN=your-callback-token2. Set Up Callback URL
In the Xendit Dashboard, set your callback URL:
https://your-domain.com/api/billing/webhooks/xenditLemonSqueezy Setup
1. Configure Credentials
export LEMONSQUEEZY_API_KEY=your-api-key
export LEMONSQUEEZY_WEBHOOK_SECRET=your-signing-secret
export LEMONSQUEEZY_STORE_ID=your-store-id2. Set Up Webhook
In the LemonSqueezy Dashboard, create a webhook pointing to:
https://your-domain.com/api/billing/webhooks/lemonsqueezySubscribe to:
order_createdsubscription_createdsubscription_updatedsubscription_payment_success
Manual Payments
For bank transfers, checks, or offline payments, use the manual payment method:
POST /api/billing/payments
Content-Type: application/json
{
"invoiceId": "01JQX...",
"amount": "54.99",
"paymentMethod": "manual",
"notes": "Bank transfer ref: TRF-12345"
}Provider Selection
When a customer has a default payment method, the subscription lifecycle engine automatically selects the appropriate provider for auto-charge. You can also specify the provider explicitly during checkout.