Architecture Overview
The payment system is designed with a multi-tenant architecture where each project can have its own Stripe configuration:API Groups
Payments (Aggregated)
Cross-project payment data for developers to view all subscriptions and transactions across their projects.| Endpoint | Method | Description |
|---|---|---|
/api/v1/payments/subscriptions | GET | List all subscriptions across projects |
/api/v1/payments/transactions | GET | List all payment transactions across projects |
/api/v1/payments/projects | GET | List projects with payment configuration status |
/api/v1/payments/stats | GET | Get aggregated payment statistics |
Stripe Configuration
Developer-facing endpoints for configuring Stripe credentials per project.| Endpoint | Method | Description |
|---|---|---|
/api/v1/payments/stripe/projects/{project_id}/config | GET | Get Stripe configuration |
/api/v1/payments/stripe/projects/{project_id}/config | PUT | Create or update Stripe configuration |
/api/v1/payments/stripe/projects/{project_id}/config | DELETE | Deactivate Stripe configuration |
/api/v1/payments/stripe/projects/{project_id}/webhook-urls | GET | Get webhook URLs for Stripe dashboard |
/api/v1/payments/stripe/projects/{project_id}/validate-credentials | POST | Validate Stripe API credentials |
/api/v1/payments/stripe/projects/{project_id}/subscriptions | GET | List project subscriptions |
/api/v1/payments/stripe/projects/{project_id}/payments | GET | List project payment transactions |
Stripe Checkout
Create Stripe checkout sessions for subscription or one-time payments.| Endpoint | Method | Description |
|---|---|---|
/api/v1/payments/stripe/checkout-session | POST | Create checkout session |
Stripe Webhooks
Receive and process webhook events from Stripe.| Endpoint | Method | Description |
|---|---|---|
/api/v1/payments/stripe/webhooks/{project_id}/{mode} | POST | Handle Stripe webhook events |
Stripe Subscriptions (End User)
End-user facing endpoints for managing their own subscriptions.| Endpoint | Method | Description |
|---|---|---|
/api/v1/payments/stripe/my-subscription | GET | Get current subscription |
/api/v1/payments/stripe/my-payments | GET | Get payment history |
/api/v1/payments/stripe/customer-portal | POST | Create customer portal session |
/api/v1/payments/stripe/cancel-subscription | POST | Cancel subscription |
/api/v1/payments/stripe/update-subscription | POST | Change subscription plan |
Authentication
Payment endpoints use different authentication methods based on the user type:| User Type | Auth Method | Header |
|---|---|---|
| Developer | OAuth2 Bearer Token | Authorization: Bearer {jwt} |
| End User | HTTP Bearer Token | Authorization: Bearer {jwt} |
| Webhook | Stripe Signature | Stripe-Signature: {signature} |
Test vs Live Mode
All Stripe endpoints support both test and live modes:- Test Mode: Uses test API keys (prefix
sk_test_/pk_test_), simulated payments - Live Mode: Uses live API keys (prefix
sk_live_/pk_live_), real payments
test_mode query parameter controls which mode is used (defaults to true for safety).
Quick Start
1. Configure Stripe Credentials
First, add your Stripe API keys to your project:2. Get Webhook URLs
Configure webhooks in your Stripe dashboard:3. Create Checkout Session
Create a checkout session for end users:Webhook Events
The following Stripe webhook events are processed:| Event | Action |
|---|---|
checkout.session.completed | Create subscription record |
customer.subscription.created | Store subscription details |
customer.subscription.updated | Update subscription status |
customer.subscription.deleted | Mark subscription cancelled |
invoice.paid | Record successful payment |
invoice.payment_failed | Record failed payment |

