Sell subscriptions as a SaaS startup
Launch a pre-built subscriptions integration as a SaaS startup.
This guide is for SaaS startups who want to accept recurring payments (subscriptions) using a flat rate pricing model. This means you charge a flat rate per month for your product or service at the beginning of a certain time period.
Your customers are redirected to the hosted page to enter their payment details then return to your site. You’ll use Checkout to create a Stripe-hosted page that calls the Checkout Sessions API.
Create a Stripe account
Before integrating with Stripe, you must create a Stripe account.
- Create an account by entering your email address, full name, country, and creating a password.
- Fill out your business profile.
- In the Dashboard, click Verify your email. A verification email is sent to your email address.
- Verify your email address.
Create a test product and price
Create products and set prices in the Dashboard.
Enter the product and price details:
- Name: Enter “Plus”
- Price: Enter “8”
- Currency: Select USD
Upload a test product image.
Select Recurring.
Click Add test product.
Accept subscriptions payments
To accept payments, build an integration with Stripe-hosted Checkout, a prebuilt payment page.
Before you begin
Refer to the Stripe-hosted Checkout quickstart as you go through this step. You can download the example app or open it in VS Code.
Set up your server
Your server communicates with the Stripe API to initialize the checkout process, but Stripe actually securely hosts the actual payment form. Setting up your server varies by programming language, but typically involves installing the Stripe library, configuring your API keys, and implementing the endpoints needed to create Checkout Sessions and handle post-payment processes.
- Open the Quickstart, and select React for the front end, and Node for the back end.
- Install the Stripe Node library.
- Create a Checkout Session. A Checkout Session is a server-side object in Stripe that defines a payment flow for a customer. The endpoint path must match the
actionattribute of your checkout button. - Define a product to sell. Add the test product (“Plus”) you created earlier in the Dashboard. After you set the test product, you get a price ID value, which your front end needs to pass when creating a Checkout Session needs
- Choose a payment mode. To initiate recurring payments with subscriptions, set the
modetosubscription. - Supply success and cancel URLs. Stripe redirects your customer to these pages after they complete or cancel a payment. Host these pages on your site.
- Redirect your customer to the URL for the Checkout page. This is the URL returned in the Checkout Session response.
Create your checkout page
This is a page on your site that shows the customer a summary of their order before they proceed to complete payment. They can review and modify their selections if needed.
- Add an order preview page.
- Add a checkout button. This is the button the customer clicks on the order preview page that redirects them to the Stripe-hosted payment page.
Test your checkout page
- Add
“proxy”: "<http://localhost:4242>”to yourpackage.file during local development.json - Run
npm startand go to http://localhost:3000/checkout. - In your checkout page, enter the test card
4242424242424242to submit a test payment as a customer. - (Optional) To sign up for a Link account, select Save my information for faster checkout. You can test Link as the payment method to see the checkout flow for a returning customer.
Additional recommended configurations
Learn how to add payment methods, trial periods, and set up a customer portal.
Customize payment page
You can apply custom branding to Checkout. In the Dashboard, go to Branding settings to:
- Upload a logo or icon
- Customize the background color, button color, font, and shapes for the page
Add payment methods
In the Payment methods page in the Dashboard, enable the payment methods you want to accept from your customers. Checkout supports several payment methods, and also uses dynamic payment methods
This means Stripe handles the logic for dynamically displaying the most relevant eligible payment methods to each customer to maximize conversion. Stripe only shows customers the payment methods they’re eligible to use, based on factors like their location or if the payment method supports subscriptions.
Add trial periods
Configure a Checkout Session to add a free trial to your customer’s subscription by passing one of the following parameters:
- subscription_data.trial_period_days, the length (in days) of your free trial.
- subscription_data.trial_end, a Unix timestamp representing the end of the trial period.
Add a customer portal
Your customers manage their existing subscriptions and invoices in a customer portal. Use the Dashboard to create the portal. At a minimum, make sure to configure it so that customers can update their payment methods.
Monitor your subscriptions
To monitor subscriptions for your Stripe-hosted Checkout integration, you can set up an endpoint to listen to specific webhook events that occur throughout the subscription lifecycle.
Set up a webhook endpoint
Create a webhook endpoint on your server to receive event notifications from Stripe.
In the Dashboard, register this endpoint in your webhook settings.
Implement webhook signature verification for security using your webhook secret. If you don’t know your
STRIPE_key, go to the destination details view of the Webhooks tab in Workbench to view it.WEBHOOK_ SECRET In Workbench, select the events you want.
Enter the endpoint’s name, URL, and description in the Dashboard.
Monitor the following events at minimum (for more events, see Subscription webhooks):
Event name Description Your response checkout.session. completed Sent when a customer successfully completes the Checkout Session, informing you of a new purchase. Use entitlements to provision the subscription. invoice.paid Sent each billing period when a payment succeeds. For monthly billing, continue to provision the subscription each month as you receive invoice.events. Examine the event type and parse the payload of each event object. Store thepaid subscription.andid customer.event objects in your database for verification purposes.id invoice.payment_ failed Sent each billing period if there’s an issue with your customer’s payment method. Notify your customer and direct them to the customer portal to update their payment method.
Set the billing cycle
You can explicitly set a subscription’s billing cycle anchor to a fixed date (for example, the 1st of the next month) when creating a Checkout Session. The billing cycle anchor determines the first full invoice date, when customers are billed the full subscription amount. For example, a monthly subscription created on May 15 with an anchor on June 1 is first initially billed on May 15, then always on the 1st of the month.
To configure a billing cycle anchor, set the subscription_ parameter when you create a Checkout Session in subscription mode. The anchor must be a future UNIX timestamp before the next natural subscription billing date.
If the billing cycle anchor is during a session’s active period and a customer attempts payment after it has passed, Checkout displays and charges for the full period starting with the billing cycle anchor instead of the prorated period before the billing cycle anchor.
To learn more, see Set the billing cycle date.
Go live
- In the Dashboard, open your Account settings.
- Enter your business type, tax details, business details, personal verification information, and customer-facing information (for example, a statement descriptor).
- Add bank details to confirm where your money will be paid out.
- Set up two-step authentication to secure your account.
- You can optionally add automatic tax collection or revenue-based climate donations.
- Review the information you entered, and click Agree and submit.
- After you activate your profile, Stripe updates you from sandbox mode to live mode.
Learn more about activating your Stripe account.
Next steps
After setting up your integration, we recommend you implement the following features:
- Enable and automatically collect tax on subscriptions in Checkouts sessions.
- Cancel or refund a payment. You can cancel a payment before it’s completed, or refund all or part of a payment after it succeeds.
- Set up your bank account to receive payouts.
- Enable Adaptive pricing. This allows Stripe to let your customers pay in their local currency in over 150 countries.