Integrate the customer portal
Stripe’s customer portal allows your customers to manage subscriptions and invoices. If you’re a Subscriptions user, the portal lets your customers manage their subscriptions (update, cancel, pause, and so on). Invoicing-only users can use the portal to pay an invoice, add a payment method, and more.
Supported payment methods
You can customize the portal to match your branding. This includes your icon, logo, colors, and business information. Additionally, customers automatically see localized versions of the portal based on their browser settings. Some of the languages that the portal supports are English, French, German, Italian, Dutch, Danish, Spanish, Japanese, and Simplified Chinese.
The portal also works with Stripe Tax—a paid product that automatically calculates tax on your transactions without the need to define the rates and rules.
Portal sessions are temporary. New portal sessions expire after a five minute period. If a customer uses it within that time period, then the session expires within one hour of the most recent activity. Each portal session can last up to two hours before expiring.
The customer portal is a secure, Stripe-hosted page that lets your customers manage their subscriptions and billing details.
Use Stripe’s API to fully integrate the customer portal.
Audience: Developers who know how to work with the Stripe API.
Clone a sample project with Firebase, Netlify Identity, Vercel and Next.js, or Ruby on Rails. If you’re interested in building a full, working subscription integration using Stripe Billing and Stripe Checkout, see our quickstart integration guide.
Watch us walk you through an integration on YouTube.
The portal provides features that allow your customers to:
- Update subscriptions.
- Cancel subscriptions.
- Pause subscriptions.
- Resume subscriptions.
- View their active subscriptions.
- View their current and past invoice history, and download invoices.
- Update payment methods.
- Update billing information, including their tax IDs.
Get started
With the customer portal, you can provide subscription and billing management to your customers without building it yourself. After you configure and integrate the portal, customers redirect to a co-branded dashboard where they can manage their account based on the functionality you configured.
Follow these steps to integrate your application with the customer portal:
- Configure the portal’s features and user interface (UI).
- Implement a redirect to integrate the portal with your application.
- Listen to webhooks to receive updates to customers’ subscriptions and payment methods.
- Go live to use the portal in your production environment.
You can optionally customize portal sessions to enable different features for different customers.
Configure the portalDashboard
Before you integrate the customer portal, you must configure its functionality and branding in the Dashboard or API. These settings determine what your users can do with the portal. Its features depend on your product and price catalog, so there are different settings for live and test modes.
If you’re using the customer portal with Stripe Connect, make sure you configure the customer portal for the platform, not a connected account.
Set a product catalog
If you allow customers to upgrade, downgrade, or change the quantities of their subscriptions, you must also set a product catalog. This includes the products and prices that your customers can upgrade or downgrade to, as well as the subscriptions on which they can update quantities. The portal displays the following attributes of your product catalog:
- Product name and description—these attributes are editable in the Dashboard and API.
- Quantity restrictions per product—these attributes are editable in the Dashboard.
- Price amount, currency, and billing interval—these attributes are immutable and can only be set on creation in the Dashboard and API.
Enable tax ID collection
If you use Stripe Tax to automatically collect taxes for subscriptions, you can let customers set and update their tax IDs in the customer portal. Stripe Billing adds the tax IDs to the customers’ invoices. To enable this, go to the Customer portal settings and turn on Tax ID. For more information, see how customer tax IDs work with subscriptions and invoices.
Limitations
The customer portal has the following limitations:
Updating subscriptions in the portal is only supported for
charge_automatically
subscriptions with a singlelicensed
price.If subscriptions use any of the following, customers can only cancel them in the portal (they can’t update such subscriptions):
- Multiple products
- Usage-based billing
- Unsupported payment methods
Customers can’t cancel subscriptions that are attached to schedules.
Customers that have active subscriptions and have enabled Stripe Tax can’t update their billing or shipping addresses to an unrecognized location; they must provide a valid address.
The portal doesn’t display the payment method section if the customer’s default payment method is not supported.
Preview and test
As you configure your settings, you can preview the portal by clicking Preview. This launches a read-only version of the portal that lets you see how your customers could manage their subscriptions and billing details.
After saving your settings, you can launch the portal and test it by using a customer in test mode. Navigate to a customer in the Dashboard, click Actions, and then select Open customer portal.
Previewing the portal as a read-only version is only available when your Dashboard is in test mode. If you’re unable to preview and test the portal, check your settings to make sure that your configuration is saved in test mode. For previewing and testing to work, you also need to have edit permissions in the Dashboard.
Language support
The portal is automatically localized for a set of languages. To view a localized version of the portal, set your browser’s default language to the language you’d like to preview.
Which languages are supported by the portal?
Implement a redirectClient-sideServer-side
A portal session is the entry point into the customer portal. It provides a unique, temporary link to the portal. When a customer wants to manage their billing, create a new portal session and redirect them to the session’s url
.
On your site, add a button that customers can click to enter the portal. Use a POST request to create a portal session:
<form method="POST" action="/create-customer-portal-session"> <button type="submit">Manage billing</button> </form>
Next, add an endpoint that creates a portal session and redirects your customers. Make sure to authenticate customers on your site before creating sessions for them. To create a session, you need the customer’s ID and a return_url
, which is required if a default return URL isn’t set in the Dashboard configuration.
When you create a portal session, Stripe returns the portal session object
, which contains the session’s short-lived URL that your customers use to access the customer portal.
Listen to webhooksServer-side
When subscriptions are upgraded, downgraded, or canceled, you need to ensure that customers receive only the products or services they’re actively subscribed to. Stripe sends notifications of these changes to your integration using webhooks. In the Event
object, look at the ID for the subscription or the customer to determine which customer the event applies to.
If you haven’t set up a webhook endpoint with Stripe before, you can use Stripe’s webhooks documentation to get started, and then listen for the events described below.
Subscription upgrades and downgrades
Listen for the customer.subscription.updated event, and check the subscription.items.data[0].price
attribute to find the price the customer is subscribed to. Then, grant access to the new product.
When a customer uses the portal to upgrade or downgrade a subscription with a trial, the subscription’s trial ends immediately when switching to the new price.
Subscription quantity updates
Listen for the customer.subscription.updated event, and check the subscription.items.data[0].quantity
attribute to find the quantity the customer is subscribed to. Then, grant access to the new quantity.
Subscription cancellation
Listen to the customer.subscription.deleted event, and then remove the customer’s access to the product.
If you configure the portal to cancel subscriptions at the end of a billing period, listen to the customer.subscription.updated event to be notified of cancellations before they occur. If cancel_at_period_end
is true
, the subscription is canceled at the end of its billing period.
If a customer changes their mind, they can reactivate their subscription prior to the end of the billing period. When they do this, a customer.subscription.updated event is sent. Check that cancel_at_period_end
is false
to confirm that they reactivated their subscription.
Subscription pause
Listen for the customer.subscription.updated event. If subscription.pause_collection
is empty, it means that the subscription is resumed. Otherwise, the subscription is paused and subscription.pause_collection.resumes_at
indicates when the subscription is scheduled to resume. subscription.pause_collection.behavior
must always be 'void'
if the customer paused their subscription in the customer portal.
Payment method updates
Customers can use the portal to add and remove payment methods, and select a new default payment method.
- payment_method.attached—Occurs when a customer adds a payment method.
- payment_method.detached—Occurs when a customer removes a payment method.
- customer.updated—Check the
invoice_settings.default_payment_method
attribute to find the payment method that a customer selected as the new default.
If you have subscriptions that override the customer-level default payment method, customers can remove this override. Listen to the customer.subscription.updated event and check the subscription’s default_payment_method
attribute when this occurs.
Billing information updates
The customer.updated event is sent when customers update their billing information. Use this webhook to update any relevant information in your database. All updates must be treated as billing information changes only. Don’t use the customer billing email address as a login credential.
Listen to the customer.tax_id.created and customer.tax_id.deleted events to receive updates when customers manage their tax IDs. Stripe can validate some types of tax IDs. Listen to the customer.tax_id.updated event to get notified of validation updates. Learn more in the tax IDs guide.
Configuration creations and updates
The billing_portal.configuration.created and the billing_portal.configuration.updated events are sent when a configuration is created or updated. Listen for these webhooks to respond to changes.
Go live
Make sure to test the portal before enabling it in production. When you’re ready to go live:
When you create a portal session, Stripe returns the portal session object
, which contains the session’s short-lived URL that your customers must use to access the customer portal.
- Turn off View test data in the Dashboard.
- Configure the portal in live mode.
- Add your webhooks in live mode.
Stripe maintains two distinct sets of portal configurations: one for live mode and one for test mode. To help you validate your integration, making changes in one mode does not affect your configuration in the other.