Features > Payments
Complete guide to setting up Stripe payments and handling subscription lifecycle in your Nexset application.
Initial Setup
- 1
Create a new Stripe account and activate payments
- 2
Add your website URL in [Settings] > [Public Details]
- 3
Configure your brand logo & colors in [Settings] > [Branding]
- 4
Enable customer emails for payments & refunds in [Settings] > [Customer Emails]
- 5
Activate the customer portal link in [Settings] > [Customer Portal]
- 6
Configure fraud prevention rules: Enable 3DS rules and block payments if CVC fails
Development Configuration
- 1
Enable Test Mode in your Stripe Dashboard
- 2
Create a product and copy the price ID (e.g., price_1ju5GD464564)
- 3
Add the price ID to
config.stripe.plans[0].priceId
inconfig.js
- 4
Copy your public & private keys from [Developers] section
- 5
Add keys to
STRIPE_SECRET_KEY
&STRIPE_PUBLIC_KEY
in.env.local
Webhook Setup
To test webhooks locally:
stripe listen --forward-to localhost:3000/api/webhook/stripe
Copy the signing secret and add it to STRIPE_WEBHOOK_SECRET
in .env.local
Production Deployment
- 1
Disable Test Mode in Stripe Dashboard
- 2
Update production environment with live Stripe keys
- 3
Configure production webhook endpoint (your-domain.com/api/stripe/webhook)
- 4
Add webhook signing secret to production environment variables
- 5
Optional: Configure monthly payout date in [Balance] > [Manage Payouts]
- 6
Optional: Enable customer emails for payments & refunds
Implementation Details
Creating Checkouts
Use the ButtonCheckout component to create checkout sessions for both one-time payments and subscriptions.
Webhook Event Handling
The API automatically handles Stripe webhook events and manages user access through the hasAccess
boolean flag. Below is how different events are processed:
switch (eventType) {
case "checkout.session.completed":
// Payment successful, subscription active
// Grant service access
break;
case "checkout.session.expired":
// Payment incomplete
// Optional: Send abandoned cart reminder
break;
case "invoice.paid":
// Recurring payment successful
// Maintain service access
break;
case "invoice.payment_failed":
// Payment attempt failed
// Handle access revocation or notify user
break;
case "customer.subscription.deleted":
// Subscription cancelled
// Remove service access
break;
}
You can customize the webhook handler in /api/stripe/webhook
to add your own business logic, such as adding credits, sending digital products, or triggering other workflows.