Skip to main content

Billing Controller

The Billing Controller provides comprehensive financial management capabilities including subscription management, payment processing, credit operations, and billing analytics for the VChata platform.

Base Path

Overview

This controller provides complete financial management capabilities:
  • ๐Ÿ’ณ Subscription Management - Start, pause, cancel, and modify subscriptions
  • ๐Ÿ’ฐ Credit Operations - Purchase, refill, and auto-refill credit balances
  • ๐Ÿ”’ Payment Methods - Secure payment method management (add, update, remove)
  • ๐Ÿ“Š Usage Analytics - Detailed usage analytics and reporting
  • ๐Ÿงพ Transaction History - Complete transaction and invoice history
  • ๐Ÿ“ˆ Billing Insights - Real-time billing insights and forecasting

Authentication & Authorization

  • ๐Ÿ” All endpoints require valid JWT authentication token
  • ๐Ÿ‘ฅ Most operations restricted to OWNER or ADMIN roles
  • ๐Ÿข All operations scoped to userโ€™s current organization

Rate Limiting

  • ๐Ÿ“Š Standard endpoints: 100 requests/minute per user
  • ๐Ÿ“ˆ Reporting endpoints: 20 requests/minute per user
  • ๐Ÿ’ณ Payment operations: 10 requests/minute per user

Billing Setup

Setup Billing

Description: Initializes billing infrastructure for an organization including Stripe customer creation. Requirements:
  • User must have OWNER or ADMIN role in the organization
  • Organization must not already have billing setup
  • Valid email and name are required for Stripe customer creation
object

Payment Methods

Add Payment Method

Description: Attaches a payment method to the organizationโ€™s Stripe customer.
object

List Payment Methods

Description: Retrieves all payment methods associated with the organization.

Delete Payment Method

Description: Removes a payment method from the organization.

Set Default Payment Method

Description: Sets a payment method as the default for future charges.

Setup Intents

Create Setup Intent

Description: Creates a Stripe setup intent for adding payment methods without processing a charge.

Subscriptions

Get Subscription

Description: Retrieves the current subscription details for the organization.

Create Subscription

Description: Creates a new subscription for the organization.

Cancel Subscription

Description: Cancels the current subscription at the end of the billing period.

Pause Subscription

Description: Pauses the current subscription.

Resume Subscription

Description: Resumes a paused subscription.

Credit Management

Get Balance

Description: Retrieves the current credit balance and auto-refill settings.

Purchase Credits

Description: Purchases credits using the organizationโ€™s payment method.

Usage Analytics

Get Usage

Description: Retrieves detailed usage analytics for the current and previous billing periods.

Generate Usage Report

Description: Generates a detailed usage report for the specified date range.

Transaction History

Get Transactions

Description: Retrieves transaction history for the organization.

Get Invoices

Description: Retrieves invoice history for the organization.

Auto-Refill Settings

Configure Auto-Refill

Description: Configures automatic credit refill settings.

Get Auto-Refill Settings

Description: Retrieves current auto-refill configuration.

Error Responses

Common Errors

Integration Notes

  • ๐Ÿ’Ž Powered by Stripe - Secure payment processing
  • ๐Ÿ”ข USD Currency - All monetary amounts in USD with 2 decimal precision
  • ๐Ÿ“… ISO 8601 Timestamps - All timestamps in UTC format
  • ๐Ÿท๏ธ Metadata Tracking - Comprehensive tracking for all operations
  • ๐Ÿ’ฏ Atomic Operations - All financial operations are atomic
  • ๐Ÿ”„ Automatic Retry - Built-in retry mechanisms for transient failures
  • ๐Ÿ“ Audit Trails - Complete audit trails for all billing activities