1. Create your catalog

Create a product for the plan and a recurring price for its billing interval. Add coupons and tax settings where applicable.

2. Create or find a customer

Use a stable customer record for the account that owns access. Store your internal account ID in metadata.

3. Start the subscription

Create a subscription with the customer, price, optional trial, discount, and return URLs. Use an idempotency key so a network retry cannot create a second subscription.

4. Provision access from events

Grant access after the subscription or first invoice is confirmed. Handle renewal, payment failure, cancellation, pause, resume, and trial-ending events.

5. Give customers control

Create a customer-portal session so customers can update payment details, review invoices, change plans, pause service, or cancel according to your policy.