C Concierge Documentation
Docs / Operate / Billing
Operate

Billing & credits.

Concierge uses a prepaid reply credit system. Every auto-reply (WhatsApp, Instagram) and relay reply (Discord) deducts one credit from the tenant's balance. When credits reach zero, auto-replies stop silently.

How Credits Work

  • Each tenant has a TenantBilling record in KV tracking: replies_remaining, replies_used (lifetime), and replies_granted (lifetime)
  • Credits are deducted before the reply is sent (optimistic deduction)
  • If the AI generation or message send fails, the credit is automatically restored
  • An empty reply (e.g., AI returns nothing) also triggers a credit restore

Getting Credits

There are two ways to get reply credits:

1. Management Grants (Free)

Platform operators can grant free credits to any tenant via the management panel. This is useful for onboarding, promotions, or support situations. Grants are logged to the audit trail.

2. Paid Credit Packs (Razorpay)

Tenants can purchase credit packs via Razorpay checkout. The available packs are configurable by management. Default packs seeded by the migration:

PackRepliesPrice (INR)Price (USD)
Starter500249.00$3.00
Growth2,000799.00$10.00
Scale10,0002,999.00$36.00
Volume50,0009,999.00$120.00

Prices are stored in paise (INR) and cents (USD) internally.

Razorpay Integration

The payment flow works as follows:

  1. Tenant selects a credit pack on the pricing page (/pricing)
  2. Concierge creates a Razorpay order via the API
  3. The Razorpay checkout widget opens in the browser
  4. On successful payment, Razorpay sends a webhook to POST /webhook/razorpay
  5. Concierge verifies the payment signature (HMAC-SHA256) and credits the tenant's balance
  6. The payment is recorded in the payments D1 table

Required Secrets

  • RAZORPAY_KEY_ID: Razorpay API key ID
  • RAZORPAY_KEY_SECRET: Razorpay API key secret
  • RAZORPAY_WEBHOOK_SECRET: Webhook secret for signature verification

Credit Pack Management

Platform operators can manage credit packs via the management panel at /manage/billing:

  • Create new packs with custom names, reply counts, and prices
  • Update existing pack details
  • Activate or deactivate packs (inactive packs are hidden from tenants)
  • Delete packs
  • Control sort order for display on the pricing page

All pack management actions are recorded in the audit log.

Billing State

Each tenant's billing state is stored in KV as a TenantBilling JSON object:

{
  "replies_remaining": 450,
  "replies_used": 50,
  "replies_granted": 500
}