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
TenantBillingrecord in KV tracking:replies_remaining,replies_used(lifetime), andreplies_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:
| Pack | Replies | Price (INR) | Price (USD) |
|---|---|---|---|
| Starter | 500 | 249.00 | $3.00 |
| Growth | 2,000 | 799.00 | $10.00 |
| Scale | 10,000 | 2,999.00 | $36.00 |
| Volume | 50,000 | 9,999.00 | $120.00 |
Prices are stored in paise (INR) and cents (USD) internally.
Razorpay Integration
The payment flow works as follows:
- Tenant selects a credit pack on the pricing page (
/pricing) - Concierge creates a Razorpay order via the API
- The Razorpay checkout widget opens in the browser
- On successful payment, Razorpay sends a webhook to
POST /webhook/razorpay - Concierge verifies the payment signature (HMAC-SHA256) and credits the tenant's balance
- The payment is recorded in the
paymentsD1 table
Required Secrets
RAZORPAY_KEY_ID: Razorpay API key IDRAZORPAY_KEY_SECRET: Razorpay API key secretRAZORPAY_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
}