NextAppFast allows you to integrate Stripe for Payment processing in your SaaS application.
Configure Stripe
To use Stripe with your NextAppFast-generated application, you'll need to set up your Stripe API keys. in .env (environment variables) file.
Where to find Stripe API key?
- Go to the Stripe dashboard.
- Click on the "Developers" section.
- Select "API Keys".
- You will see a list of your API keys, including both live mode and test mode keys.
Set Up Stripe API Keys in NextAppFast
- Locate the .env (environment variables) file in your NextAppFast-generated project.
- Add your Stripe API keys to the .env file.
Setup SaaS Pricing Plans
NextAppFast allows you to visually configure SaaS Pricing plans and integrate them with Stripe.
- Decide on whether you want to offer one-time payments or recurring subscriptions.
- Create a new product in Stripe (Dashboard -> Products -> Add Product).
- Copy the Stripe Price API key for your product. (It will start with 'price_')
- Run your app in NextAppFast (preview mode)
- Locate
Subscription Plan
menu item under theAdmin
section. - Add your product and enter the Stripe Price API key in the
Stripe Plan Id
field. - When you generate code for your app, NextAppFast will create a
plans.ts
file based on your entries in Subscription Plan table. It is this file that is used by pricing page. You can locate the file in\app\(checkout)\checkout\_components
folder. - Customize the
plans.ts
file as needed to adjust the features for each pricing plan.
Checkout
Checkout is handled via Stripe Checkout. When a user selects 'Checkout', the NextAppFast-generated code creates a Stripe Checkout Session and redirects the user to the Stripe-generated URL.You can find relevant code in app\(checkout)\checkout\_actions.tsx
folder.
After the user completes the payment, the return call from Stripe is handled in the app\(checkout)\checkout-success\page.tsx
file. The code retrieves the payment details from the Stripe Checkout Session and updates the database accordingly.
User Account Management
Stripe provides user account management functionality through the 'Customer Portal' (under Billing -> Portal). This allows users to self-manage their account and billing information.
When a user clicks 'Manage Account', the NextAppFast-generated code creates a Stripe Billing Portal and redirects the user to the Stripe-generated URL. You can find the relevant code in the app\(protected)\(admin)\account\_actions.tsx
.