Billing & Payments
AIUS uses Stripe for all payment processing, subscription management, and billing operations.Overview
The billing system provides:- Subscription Management - Recurring billing for plans (Free, Basic, Pro, Enterprise)
- Credit System - Monthly credit quotas with prepaid top-ups for overage
- Payment Methods - Customer payment method management
- Invoices - Invoice tracking and history
- Billing Portal - Self-service customer portal
Pricing Model
AIUS uses a subscription + credits model:- Each plan includes a monthly credit quota that refreshes automatically
- Credits are deducted based on actual API usage costs (1 credit = 1)
- Additional credits can be purchased anytime for overage
- When quota is exceeded, users must purchase credits to continue using the service unless the quota resets (daily/weekly/monthly)
- Plans:
- Free: $10 one-time credit (1,000 credits), no monthly fee, quota never resets
- Basic: $50/month (5,000 credits/month), monthly quota resets
- Pro: $200/month (20,000 credits/month), monthly quota resets
- Enterprise: Custom pricing (50,000+ credits/month), monthly quota resets
Subscriptions
Create Subscription Checkout
Create a Stripe checkout session for a new subscription.Get Subscription
Retrieve subscription details for a client.Credits
Create Credit Top-up
Create a checkout session for purchasing credits.Get Credit Balance
Retrieve current credit balance.List Credit Transactions
Retrieve credit transaction history.Billing Portal
Create Portal Session
Create a Stripe customer portal session for self-service billing management.Payment Methods
List Payment Methods
Retrieve saved payment methods for a client.Invoices
List Invoices
Retrieve invoice history for a client.Credit System
How Credits Work
- Monthly Quota - Each subscription plan includes a monthly credit quota that refreshes automatically (except Free tier which never resets)
- Purchase Credits - Users can purchase additional credits via Stripe checkout for overage
- Credit Addition - Webhook adds credits to balance on successful payment
- Usage Deduction - Credits are deducted when using AI services based on actual cost
- Transaction History - All credit transactions are logged
- Quota Refresh - Monthly quota is reset at the start of each billing cycle (Basic, Pro, Enterprise)
- Quota Exceeded - When quota is exceeded, users must purchase credits to continue using the service unless the quota resets
Credit Conversion
Current conversion: **1 credit = 1)Transaction Types
- topup - Credits purchased via Stripe
- usage - Credits consumed by API usage
- refund - Credits refunded (manual or automatic)
- quota_refresh - Monthly quota reset at billing cycle start
Webhooks
Stripe webhooks are used to keep billing data synchronized:checkout.session.completed- Processes successful paymentsinvoice.paid- Syncs paid invoicesinvoice.payment_failed- Handles payment failurescustomer.subscription.created- Syncs new subscriptionscustomer.subscription.updated- Updates subscription changescustomer.subscription.deleted- Marks subscriptions as canceled
Error Handling
Billing endpoints return standard error responses:payment_failed- Payment processing errorinvalid_price_id- Invalid Stripe price IDsubscription_not_found- No active subscriptioninsufficient_credits- Not enough credits for operation