| title | Chargebee Connection Setup |
|---|---|
| description | Complete guide to setting up and configuring Chargebee connections in Flexprice |
A Chargebee connection in Flexprice stores encrypted credentials that allow the system to interact with your Chargebee account for:
- Creating item families, items, and item prices in Chargebee
- Synchronizing customers to Chargebee
- Syncing invoices to Chargebee for payment collection
- Receiving webhook notifications from Chargebee
Before setting up your Chargebee connection, ensure you have:
- Active Chargebee Account - Sign up at chargebee.com
- API Key - Available in your Chargebee Dashboard
- Webhook Endpoint - Configured in Chargebee Dashboard
- Flexprice Environment - Valid tenant and environment IDs
| Credential | Location in Chargebee Dashboard | Required | Purpose |
|---|---|---|---|
| Site Name | Settings → API & Webhooks → Site | ✅ | Chargebee site identifier |
| API Key | Settings → API & Webhooks → API Keys | ✅ | API authentication |
| Webhook Username | Settings → API & Webhooks → Webhooks | ❌ | Basic Auth username (optional) |
| Webhook Password | Settings → API & Webhooks → Webhooks | ❌ | Basic Auth password (optional) |
-
Site Name:
- Go to Chargebee Dashboard → Settings → API & Webhooks
- Your site name is displayed at the top (e.g.,
flexprice-test or flexprice)
-
API Key:
- Go to Chargebee Dashboard → Settings → API & Webhooks → API Keys
- Copy your API key
- Use test API keys for development
-
Webhook Credentials (Optional):
- Go to Chargebee Dashboard → Settings → API & Webhooks → Webhooks
- Configure Basic Authentication for webhook security
- Copy the username and password
https://api.cloud.flexprice.io/v1/webhooks/chargebee/tenant_01K1TJDVNSN7TWY8CZY870QMNV/env_01K1TJJF0CJR410C6QVPYQTNV0
Configure these events in your Chargebee webhook endpoint:
| Event Type | Purpose |
|---|---|
payment_succeeded |
Track successful payment completions |
- Go to Chargebee Dashboard → Settings → API & Webhooks → Webhooks
- Click + Add New Webhook
- Enter your webhook URL
- Select the required events listed above
- Configure Basic Authentication (optional but recommended)
- Click Save
You can create a Chargebee connection directly from the Flexprice dashboard.
Endpoint: POST /api/v1/connections
Headers:
Content-Type: application/json
Authorization: Bearer your_api_key
X-Tenant-ID: your_tenant_id
X-Environment-ID: your_environment_idRequest Body:
{
"name": "Chargebee Production",
"provider_type": "chargebee",
"encrypted_secret_data": {
"site": "acme-production",
"api_key": "acme-production_api_key_...",
"webhook_username": "webhook_user",
"webhook_password": "webhook_password"
}
}{
"id": "conn_1234567890abcdef",
"name": "Chargebee Production",
"provider_type": "chargebee",
"status": "active",
"created_at": "2024-01-20T10:30:00Z",
"updated_at": "2024-01-20T10:30:00Z"
}- Environment Separation: Use different API keys for test/production
- Key Rotation: Regularly rotate your Chargebee API keys
- Access Control: Limit API key permissions in Chargebee
- Encryption: All credentials are encrypted at rest in Flexprice
- HTTPS Only: Always use HTTPS for webhook endpoints
- Basic Authentication: Use Basic Auth for webhook verification (recommended)
- Secret Management: Keep webhook credentials secure and rotate regularly
- Rate Limiting: Implement rate limiting on webhook endpoints
| Issue | Cause | Solution |
|---|---|---|
| Connection test fails | Invalid API key or site name | Verify credentials in Chargebee Dashboard |
| Webhook not received | Incorrect webhook URL | Check URL format and endpoint |
| Authentication fails | Wrong webhook credentials | Update webhook username/password in connection |
| API calls fail | Invalid site name | Verify site name matches your Chargebee account |
- Check Chargebee Dashboard: Verify API key and site name
- Test API Key: Use Chargebee API to test key validity
- Monitor Webhooks: Check webhook delivery logs in Chargebee
- Review Logs: Check Flexprice application logs for errors
After setting up your Chargebee connection:
- Create Item Family: Create an item family in Chargebee (required for plan sync)
- Sync Plans: Sync your Flexprice plans to Chargebee
- Test Invoice Sync: Create a test invoice and sync to Chargebee
- Monitor Webhooks: Ensure webhook events are being received
- Go Live: Switch to production credentials when ready
For detailed API documentation, see the API Reference.