Skip to main content

Stripe API

Launch provides type-safe tRPC endpoints for all Stripe operations. These endpoints handle payment intents, checkout sessions, and product management.

Available Endpoints

stripe.getProducts

Fetches all active products and prices from your Stripe account.

stripe.createPaymentIntent

Creates a payment intent for one-time purchases.

stripe.createCheckoutSession

Creates a checkout session for subscriptions.

stripe.getSubscriptionStatus

Returns the current Stripe subscription for the authenticated user (if any), plus the local subscription record used for display.

stripe.cancelSubscription

Schedules a subscription to cancel at period end.

stripe.resumeSubscription

Resumes a subscription that was scheduled to cancel at period end.

stripe.changeSubscriptionPlan

Switches between subscription prices (monthly ↔ annual). Upgrades take effect immediately with proration; downgrades take effect at renewal.

API Structure

Location: apps/api/src/routers/stripe.ts

Authentication

  • getProducts - Public, no authentication required
  • createPaymentIntent - Protected, requires authenticated user
  • createCheckoutSession - Protected, requires authenticated user
  • getSubscriptionStatus - Protected, requires authenticated user
  • cancelSubscription - Protected, requires authenticated user
  • resumeSubscription - Protected, requires authenticated user
  • changeSubscriptionPlan - Protected, requires authenticated user

Customer Management

When a user makes their first payment, a Stripe customer is automatically created and linked to their account:

Error Handling

All endpoints return structured errors:

Test Checklist

  • stripe.getProducts returns products
  • stripe.createPaymentIntent returns a client secret
  • stripe.createCheckoutSession returns a valid URL
  • stripe.getSubscriptionStatus returns subscription info (if subscribed)
  • stripe.cancelSubscription sets cancel_at_period_end
  • stripe.resumeSubscription clears cancel_at_period_end
  • stripe.changeSubscriptionPlan swaps price with correct proration

Troubleshooting

If API calls fail, verify Stripe keys in apps/api/.env (copy from apps/api/example.env first) and restart the API.

Remove / Disable

To disable payments while you configure Stripe, set: apps/mobile/features/feature-registry.tsxfeatureFlags.payments = false For production removal guidance, see Removing Features.

Next Steps

Webhooks

Handle asynchronous payment events.

Database Schema

View the database models for payment data.