Overview
The billing engine supports:- Subscription management
- One-time payments
- Usage-based billing
- Credit systems
- Multi-currency support
- Automated invoicing
- Tax calculation
- Payment methods (cards, customer balance)
Prerequisites
- Active Stripe account (sign up)
- Stripe API key (test or live)
- Verified business information (for live mode)
Core Configuration
Stripe Integration
Stripe secret API key for authentication.Key Types:
sk_test_*- Test mode (use for development)sk_live_*- Live mode (production)
Enable Stripe automatic tax calculation based on customer location.Requirements:
- Configure tax rates in Stripe Dashboard
- Enable Stripe Tax in your account
- Provide customer address information
List of Stripe webhook signing secrets for event validation.Multiple secrets support key rotation without downtime.
Default currency for billing operations.Examples:
usd, eur, gbp, inr, jpyMust be a valid ISO 4217 currency code.Plans and Products
Path to YAML files defining products and plans.Plans are automatically synced to Stripe during application startup.
Plans File Format
Create YAML files defining your products and plans:Customer Configuration
Automatically create a billing customer when an organization is created.
Plan name to automatically subscribe new customers to.The plan must exist in Stripe. Leave empty for no automatic subscription.
Create customer accounts in offline mode (not registered with Stripe).Useful for enterprise customers with custom billing arrangements.
Free credits to add when customer account is created (in smallest currency unit).
Credit Overdraft Configuration
Product name for calculating overdraft credit costs.Uses the first price of this product to determine per-unit cost.
Day of the month (1-31) when overdraft credits are invoiced.
Shift invoice range for overdraft credits by N months.
Plan Change Configuration
How to handle proration when subscription plan changes.Options:
create_prorations- Create proration items for plan changesnone- Don’t create proration itemsalways_invoice- Invoice immediately for plan changes
Proration behavior for immediate plan changes (not waiting for next billing cycle).
Payment collection method for plan changes.Options:
charge_automatically- Charge payment method automaticallysend_invoice- Send invoice for manual payment
Subscription Configuration
Behavior when trial period ends.Options:
release- Start paid subscriptioncancel- Cancel subscription (no invoice generated)
Product Configuration
How seat count adjusts when users are added/removed from organizations.Options:Use
exact- Seat count matches user count (increases and decreases)incremental- Seat count increases with users but never decreases
incremental for “purchased seats” model where seats remain available even when users leave.Payment Method Configuration
Configure payment method limits and restrictions.Supported types:
card, customer_balanceAmounts are in smallest currency unit (cents for USD).Refresh Intervals
How often to sync billing data with Stripe.
Complete Examples
Webhook Setup
Configure Stripe webhooks to receive events:-
Create Webhook Endpoint in Stripe
Go to Stripe Dashboard → Webhooks
Endpoint URL:
https://your-domain.com/v1beta1/webhooks/stripe -
Select Events
Listen for these events:
customer.createdcustomer.updatedcustomer.deletedinvoice.createdinvoice.finalizedinvoice.paidinvoice.payment_failedsubscription.createdsubscription.updatedsubscription.deletedcheckout.session.completedpayment_intent.succeededpayment_intent.payment_failed
-
Get Webhook Secret
Copy the webhook signing secret (
whsec_...) and add to configuration: -
Test Webhook
Use Stripe CLI to test locally:
Testing
Test Mode
Use Stripe test mode for development:4242424242424242- Successful payment4000000000000002- Card declined4000002500003155- Requires authentication (3D Secure)
Stripe CLI
Install and use Stripe CLI for testing:Troubleshooting
Common Issues
Problem: Invalid API keyDebug Mode
Enable debug logging:Best Practices
-
Use Test Mode for Development
- Always use test keys (
sk_test_*) during development - Switch to live keys only in production
- Always use test keys (
-
Secure API Keys
-
Configure Webhooks
- Always set up webhooks for reliable event handling
- Use webhook signing secrets for security
- Handle webhook retries gracefully
-
Monitor Billing
- Set up Stripe Dashboard alerts
- Monitor failed payments
- Track subscription churn
- Review dispute notifications
-
Handle Errors Gracefully
- Implement retry logic for transient failures
- Log all billing errors
- Notify customers of payment issues
- Provide clear error messages
-
Test Thoroughly
- Test all payment scenarios
- Verify proration calculations
- Test plan upgrades/downgrades
- Validate tax calculations
- Test webhook event handling
-
Plan for Scale
- Set appropriate refresh intervals
- Monitor Stripe API rate limits
- Consider caching billing data
- Use webhooks instead of polling