chargebee-integration

Comprehensive integration guide for Chargebee billing platform. Provides API integration patterns, webhook handling, SDK usage, and schema references for billing operations. Use when working with Chargebee for (1) API integration and REST endpoint calls, (2) Processing webhook events, (3) Customer management operations, (4) Subscription lifecycle handling, (5) Payment and invoice processing, (6) Any other billing-related integration tasks with Chargebee platform.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "chargebee-integration" with this command: npx skills add chargebee/ai/chargebee-ai-chargebee-integration

Chargebee Integration

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.

Quick Start

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.

Frameworks

For the frameworks below, use the chargebee-init CLI which currently integrates checkout, portal and webhooks:

  • Next.js
  • Express

Invoke the CLI with: npx chargebee-init --use-defaults --path=<full-path-to-app> to skip all input prompts.

SDKs

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.

REST API

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:

  • Load API keys from environment variables only.
  • Never hardcode or log API keys.
  • Rotate keys regularly and scope access by environment.
# 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

Common Operations

  • Customer CRUD operations
  • Subscription management
  • Invoice operations
  • Payment method handling
  • Plan and addon management
  • Usage based billing

Webhook Integration

Chargebee sends webhook events for important billing events. Webhook handlers should:

  1. Validate webhook requests using Basic Auth before processing payloads
  2. Handle idempotency (events may be sent multiple times)
  3. Return 200 OK quickly (process asynchronously if needed)
  4. Handle various event types appropriately

Basic Webhook Handler Pattern

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.

References

  • references/api-reference.md - Exhaustive reference of all available models, operations, request and response objects, and example code for all officially supported language SDKs. Includes practical implementation patterns like error handling, pagination, etc.
  • references/rest-api.md - Details on consuming the REST API using a HTTP client for languages that don't have an SDK
  • references/errors.md - All possible error codes that the API may return
  • references/events.md - List of supported webhook events

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

ai-sdk

Before searching docs, check if node_modules/ai/docs/ exists. If not, install only the ai package using the project's package manager (e.g., pnpm add ai ).

Repository Source
22.6K11.4K
vercel
General

stripe-best-practices

No summary provided by upstream source.

Repository SourceNeeds Review
-1.4K
stripe
General

ai-sdk

No summary provided by upstream source.

Repository SourceNeeds Review