Stripe Setup in Nextbase Ultimate
This guide walks you through how Stripe has been set up in different files in Nextbase Ultimate.
This guide will walk you through how Stripe has been set up in different files in Nextbase Starter Kit..
Stripe Configuration
Stripe configuration is stored in the .env
file. You need to provide your Stripe API keys here.
Stripe Client
A Stripe client is created in src/utils/stripe.ts
. This client is used to interact with the Stripe API.
Stripe Webhook
A webhook endpoint is set up in src/pages/api/stripe/webhook.ts
to handle events from Stripe.
Stripe Checkout and Customer Portal
A checkout session is created in src/data/user/organizations.ts
.
Stripe Subscriptions
Subscriptions are managed in src/utils/supabase-admin.ts
. Subscriptions are at the organization level.
When a subscription is created, the manageSubscriptionStatusChange
function is called. This function creates a new subscription record in the database.
Organization Admins
Organization admins can manage subscriptions in /organization/[organizationId]/settings/billing
route.
All members can see the current subscription status in /organization/[organizationId]/settings/billing
route. However,
only organization admins can manage subscriptions.