Stripe For Production

There are a few steps you need to take to get your Stripe account ready for production and start collecting payments.

Get the API Keys and Webhook Signing Secret

Login to your Stripe account

Go to the Stripe dashboard and login with your credentials.

Turn off test mode

Make sure you're not in test mode. You can check this by looking at the top right corner of the dashboard.

Uncheck the Test mode switch.

Get the API keys

Click the Developers tab on the top right corner of the dashboard.

Click the API keys tab.

Copy the Publishable key and Secret key and save them temporarily in a text file. We will need them later for when we deploy.

Create a webhook

Click the Webhooks tab.

Click the Add endpoint button.

Enter the endpoint URL where you want to receive the webhook events.

https://www.app.your-prod-url.com/api/stripe/webhook

If your production URL redirects to the www subdomain, make sure to add the www subdomain to the URL. Otherwise, you might get a 308 permanent redirect error in production.

Notice the app subdomain.

Select the 2023-10-16 version.

Click the Select events button and add the following events:

  • checkout.session.completed
  • invoice.paid
  • invoice.payment_failed
  • customer.subscription.updated
  • customer.subscription.deleted
  • customer.subscription.trial_will_end

Click Add events.

Click Add endpoint.

Get the webhook signing secret

Click the webhook endpoint you just created.

Reveal the signing secret, copy it and save it in the text file, along with the API keys.

Copy The Products/Plans To The Production Environment

Luckily we can copy over the products and plans we created in the test/development environment to the production environment.

Activate test mode

Activate test mode at the top right corner of the dashboard.

Copy the products/plans

Click on Product catalog on the left sidebar, you'll see the products and plans we previously created.

Click on the ... next to the product and click on Copy to live mode.

Do this for all the products/plans you have created.

Configure the Customer Portal

We did this step earlier in the test/development environment. We need to do it again in the production environment.

The customers portal allows your customers to manage their subscriptions and can be accessed through the billing page in your app. However, we need to activate it first in the Stripe dashboard.

Turn off test mode

Make sure you're not in test mode. You can check this by looking at the top right corner of the dashboard.

Uncheck the Test mode switch.

Setup the customer portal

Click on the settings icon in the top right corner, then click on Settings.

Click on Billing and then click on Customer portal.

Click on the Activate test link button.

Go to Cancellations and make sure Cancel subscriptions is checked.

Go to Subscriptions and check customers can switch plans. Add all the products/plans you have created.

Fill in the rest of the options as you see fit and click on Save changes.

Limit customers to one subscription

Go back to the Settings page again.

Click on Payments and then check the Limit customers to 1 subscription.

Click on Save.

Send Automatic Invoices

Follow the steps below to enable automatic invoices for your customers.

Turn off test mode

Make sure you're not in test mode. You can check this by looking at the top right corner of the dashboard.

Uncheck the Test mode switch.

Setup automatic emails

Click on the settings icon in the top right corner, then click on Settings.

Click on Billing and then click on Subscriptions and emails.

Activate the following:

  • Send a reminder email 7 days before the trial ends.
  • Add a one-time "trial over" message to the statement descriptor.
  • Send emails about expiring cards.
  • Send emails when card payments fail.
  • Send emails when card payments fail.
  • Send finalized invoices and credit notes to customers.
  • Send reminders if a recurring invoice hasn't been paid.

Change the following:

  • Subscription status: If all retries for a payment fail to cancel the subscription.
  • If a recurring payment is incomplete for to 7 days and cancel the subscription.

Make sure to save all the changes by clicking on the Save button for each section.

Setup automatic invoices

Click on the settings icon in the top right corner, then click on Settings.

Click on Business and then click on Customer emails.

Activate the following:

  • Successful payments.
  • Refunds.

Next Steps

There are tons of other features you can enable in the Stripe dashboard, I encourage you to explore them and see what fits your business needs.

We're going to need the API keys and webhook signing secret in the hosting section, so make sure you have them saved in a safe place.

Last updated on