
This integration guide covers the full stack for working with Chargebee's billing platform, from framework-specific implementations like Laravel Cashier to REST API patterns. It emphasizes retrieval-led reasoning and provides practical code examples for webhook validation, customer management, and subscription handling across seven language SDKs. The skill includes security best practices (environment variables, credential rotation) and links to comprehensive reference docs for API schemas and error codes. What's useful here is the clear hierarchy: it pushes you toward framework integrations first, then SDKs, and only REST as a fallback. The webhook handler pattern with idempotency checks is production-ready out of the box.
$ npx -y skills add chargebee/ai --skill chargebee-integration --agent claude-codeInstalls into .claude/skills of the current project.
This skill helps you integrate Chargebee Billing with your app or website.
IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning when integrating Chargebee.
Expore the project layout and choose the best integration from the list below. Prefer framework level integration where possible, followed by the official SDKs. Fallback to REST API only if the other options aren't feasible.
For the frameworks below, use the chargebee-init CLI which currently integrates checkout, portal and webhooks:
Invoke the CLI with: npx chargebee-init --use-defaults --path=<full-path-to-app> to skip all input prompts.
Chargebee provides official SDKs for multiple languages. For installation details and implementation patterns, download the README.md file from the GitHub repository.
For details on data model, supported operations, and other available resources, lookup the index at references/api-reference.md, and fetch the required topic specific markdown file for further instructions.
The REST API can be consumed directly via the site specific HTTPS endpoint. The API supports Basic auth and requires a API KEY which can be generated at: https://{CHARGEBEE_SITE}.chargebee.com/apikeys_and_webhooks/api. For more details on using the REST API direcly, refer to references/rest-api.md.
Security notes:
# Using requests library
import os
import requests
CHARGEBEE_SITE = os.getenv("CHARGEBEE_SITE")
CHARGEBEE_API_KEY = os.getenv("CHARGEBEE_API_KEY")
headers = {
"Authorization": f"Basic {CHARGEBEE_API_KEY}",
"Content-Type": "application/json"
}
base_url = f"https://{CHARGEBEE_SITE}.chargebee.com/api/v2"
response = requests.get(
f"{base_url}/customers/{customer_id}",
headers=headers
)
# Using Python SDK
import chargebee
chargebee.configure(CHARGEBEE_API_KEY, CHARGEBEE_SITE)
result = chargebee.Customer.retrieve(customer_id)
customer = result.customer
Chargebee sends webhook events for important billing events. Webhook handlers should:
from flask import Flask, request
import os
import secrets
app = Flask(__name__)
processed_events = set() # Use persistent storage in production.
WEBHOOK_USERNAME = os.getenv("CHARGEBEE_WEBHOOK_USERNAME")
WEBHOOK_PASSWORD = os.getenv("CHARGEBEE_WEBHOOK_PASSWORD")
@app.route('/chargebee/webhook', methods=['POST'])
def handle_webhook():
auth = request.authorization
if not auth:
return '', 401
if not secrets.compare_digest(auth.username or '', WEBHOOK_USERNAME or ''):
return '', 401
if not secrets.compare_digest(auth.password or '', WEBHOOK_PASSWORD or ''):
return '', 401
event = request.get_json(force=True)
event_id = event['id']
if event_id in processed_events:
return '', 200
event_type = event['event_type']
# Process based on event type
if event_type == 'subscription_created':
handle_subscription_created(event['content'])
elif event_type == 'subscription_cancelled':
handle_subscription_cancelled(event['content'])
# ... handle other events
processed_events.add(event_id)
return '', 200
For complete webhook event schemas and all event types, see references/webhooks.md.
Sponsors