Overview
This guide walks through integrating CrediBill payment infrastructure into your SaaS application. We’ll cover:- Setting up payment providers
- Creating subscriptions
- Handling webhooks
- Managing customer payments
- Monitoring and debugging
Prerequisites
- Active CrediBill account
- Secret API key from dashboard
- Payment provider account (Flutterwave, PawaPay, Pesapal, or DPO)
- Backend server (Node.js, Python, etc.)
- Basic understanding of webhooks
1. Setup
Store API Key in Environment
API Base URL
Authorization header:
2. Configure Payment Providers
Step 1: Get Provider Credentials
Follow the Provider Setup Guide to obtain credentials for your chosen provider.Step 2: Add to CrediBill Dashboard
- Go to Settings → Payment Providers
- Click Add Provider
- Select provider (Flutterwave, PawaPay, Pesapal, or DPO)
- Enter credentials obtained from provider
- Set environment (Test or Live)
- Click Save & Test Connection
Step 3: Verify Connection
Multi-Provider Setup (Recommended)
Add providers via API:3. Create Customers
Basic Customer Creation
With Payment Method
4. Create Subscriptions
Simple Subscription
With Usage-Based Pricing
Subscription Lifecycle
5. Handle Webhooks
Set Up Webhook Endpoint
Handle Payment Success
Handle Payment Failure
Handle Subscription Events
6. Test Your Integration
Test Mode
Use provider test credentials to test without real payments. Prefer testing by calling the CrediBill API from your server (App Router) or using cURL.- Next.js (App Router)
- cURL
Test Webhooks Locally
Use ngrok to receive webhooks locally:- Go to Settings → Webhooks
- Update URL to:
https://your-ngrok-url.ngrok.io/webhooks/credibill - Send test webhook from dashboard
Test Webhook Handling
7. Go Live Checklist
Provider Setup
- Live merchant accounts created
- Business verification completed
- Live API credentials obtained
- Webhook URLs configured in provider dashboards
- Test payment successful with real provider
- Webhook delivery confirmed
CrediBill Configuration
- Primary provider configured in dashboard
- Backup provider configured (optional but recommended)
- Environment set to Live (not Test)
- Webhook secret saved securely
- Webhook URL points to production
- HTTPS certificate valid (not self-signed)
Code Review
- Webhook signature verification implemented
- Timing-safe comparison used
- Timestamp validation implemented
- Idempotency checks in place
- No credentials hardcoded
- All secrets in environment variables
- Error messages don’t expose credentials
- Logging doesn’t log sensitive data
Testing
- End-to-end payment test successful
- Failed payment handling tested
- Webhook delivery tested
- Signature verification works
- Idempotency handling works
- Multiple payment methods tested
Monitoring
- Error alerts configured
- Payment success metrics tracked
- Webhook delivery monitored
- Failed payments monitored
- Unusual activity alerts set up
- Daily reconciliation process established
Deployment
- Code deployed to production
- Configuration deployed (env vars)
- Webhooks configured in production
- First payment tested end-to-end
- Monitor logs for first 24 hours
- Team on standby for issues
8. Common Integration Issues
Issue: Webhook Signature Verification Fails
Cause: Using parsed JSON body instead of raw body Solution:Issue: Webhooks Not Received
Checklist:- Webhook URL is publicly accessible (not localhost)
- HTTPS certificate is valid
- Firewall allows traffic from CrediBill
- Endpoint returns 200 OK
- Endpoint responds within 10 seconds
- Check webhook logs in CrediBill dashboard
Issue: Payment Stuck in Pending
Cause: Provider API slow or webhook delivery delayed Solution:- Wait 5-10 minutes (mobile money can be slow)
- Check provider dashboard for payment status
- Check CrediBill webhook logs for delivery attempts
- Contact provider support if stuck > 30 minutes
Issue: Customer Charged Multiple Times
Cause: Duplicate payment initiation or missing idempotency Solution:- Implement idempotency keys (see code above)
- Check webhook idempotency handling
- Use database unique constraints on transaction IDs
- Check for double form submissions in UI
Next Steps
- Webhooks Reference - Complete webhook event documentation
- Security Best Practices - Production security guide
- Provider Setup - Detailed provider configuration
- API Reference - Full API documentation