Build a subscriptions integration with Checkout
Create and manage subscriptions to accept recurring payments with Checkout.

Customize logo, images, and colors.
Use prebuilt hosted pages to collect payments and manage your subscriptions.
Clone a sample integration from GitHub.
For an immersive version of this guide, see the Billing integration quickstart.
Explore the sample on GitHub or the demo.
What you’ll build 
This guide describes how to sell fixed-price monthly subscriptions using Stripe Checkout.
This guide shows you how to:
- Model your business by building a product catalog.
- Add a Checkout session to your site, including a button and success and cancellation pages.
- Monitor subscription events and provision access to your service.
- Set up the customer portal.
- Add a customer portal session to your site, including a button and redirect.
- Let customers manage their subscription through the portal.
- Learn how to use flexible billing mode to access enhanced billing behavior and additional features.
After you complete the integration, you can extend it to:
- Display taxes
- Apply discounts
- Offer customers a free trial period
- Add payment methods
- Integrate the hosted invoice page
- Use Checkout in setup mode
- Set up usage-based billing, pricing tiers, and usage-based pricing
- Manage prorations
- Allow customers to subscribe to multiple products
- Integrate entitlements to manage access to your product’s features
Set up Stripe
Install the Stripe client of your choice:
Optionally, install the Stripe CLI. The CLI provides webhook testing, and you can run it to create your products and prices.
その他のインストールオプションについては、Stripe CLI を使ってみるをご覧ください。
Create the pricing modelDashboard or Stripe CLI
ダッシュボードまたは Stripe CLI で商品とその価格を作成します。
この例では、「基本」と「プレミアム」という 2 つのサービスレベルオプションがある固定価格のサービスを使用しています。サービスレベルオプションごとに、1 つの商品と 1 つの継続価格を作成する必要があります (初期費用のような 1 回限りの支払いを追加する場合は、1 回限りの価格で 3 つ目の商品を作成します。わかりやすくするために、この例には 1 回限りの支払いを含めていません)。
この例では、各商品が 1 カ月間隔で請求されます。基本商品の価格は 5 USD で、プレミアム商品の価格は 15 USD です。
If you offer multiple billing periods, use Checkout to upsell customers on longer billing periods and collect more revenue upfront.
For other pricing models, see Billing examples.
Create a Checkout SessionClient and Server
Add a checkout button to your website that calls a server-side endpoint to create a Checkout Session.
<html> <head> <title>Checkout</title> </head> <body> <form action="/create-checkout-session" method="POST"> <!-- Note: If using PHP set the action to /create-checkout-session.php --> <input type="hidden" name="priceId" value="price_G0FvDp6vZvdwRZ" /> <button type="submit">Checkout</button> </form> </body> </html>
On the backend of your application, define an endpoint that creates the session for your frontend to call. You need these values:
- The price ID of the subscription the customer is signing up for (your frontend passes this value)
- Your
success_
, which is a page on your website that Checkout returns your customer to after they complete the paymenturl
You can optionally:
- Use
cancel_
to provide a page on your website where Checkout returns your customer, if they cancel the payment process.url - Configure a billing cycle anchor to your subscription in this call.
- Use custom text to include your subscription and cancellation terms, and a link to where your customers can update or cancel their subscription. We recommend configuring email reminders and notifications for your subscribers.
If you created a one-time price in step 2, pass that price ID as well. After creating a Checkout Session, redirect your customer to the URL returned in the response.
You can enable more accurate and predictable subscription behavior when you create a Checkout Session by setting the billing mode type to flexible
. You must use the Stripe API version 2025-06-30.basil or later.
注
You can use lookup_keys to fetch prices rather than price IDs. For an example, see the sample application.
This example customizes the success_
by appending the session ID. Learn more about customizing your success page.
From your Dashboard, enable the payment methods you want to accept from your customers. Checkout supports several payment methods.
Provision and monitor subscriptionsServer
After the subscription signup succeeds, the customer returns to your website at the success_
, which initiates a checkout.
webhook. When you receive a checkout.
event, use entitlements to provision the subscription. Continue to provision each month (if billing monthly) as you receive invoice.
events. If you receive an invoice.
event, notify your customer and send them to the customer portal to update their payment method.
To determine the next step for your system’s logic, check the event type and parse the payload of each event object, such as invoice.
. Store the subscription.
and customer.
event objects in your database for verification.
For testing purposes, you can monitor events in the Events tab of Workbench. For production, set up a webhook endpoint and subscribe to appropriate event types. If you don’t know your STRIPE_
key, go to the destination details view of the Webhooks tab in Workbench to view it.
The minimum event types to monitor:
Event name | Description |
---|---|
checkout. | Sent when a customer successfully completes the Checkout Session, informing you of a new purchase. |
invoice. | Sent each billing period when a payment succeeds. |
invoice. | Sent each billing period if there’s an issue with your customer’s payment method. |
For even more events to monitor, see Subscription webhooks.
Configure the customer portalDashboard
The customer portal lets your customers directly manage their existing subscriptions and invoices.
Use the Dashboard to configure the portal. At a minimum, make sure to configure the portal so that customers can update their payment methods.
Create a portal sessionServer
Define an endpoint that creates the customer portal session for your frontend to call. The CUSTOMER_
refers to the customer ID created by a Checkout Session that you saved while processing the checkout.
event. You can also set a default redirect link for the portal in the Dashboard.
Pass an optional return_
value for the page on your site to redirect your customer to after they finish managing their subscription:
Send customers to the customer portalClient
On your frontend, add a button to the page at the success_
that provides a link to the customer portal:
<html> <head> <title>Manage Billing</title> </head> <body> <form action="/customer-portal" method="POST"> <!-- Note: If using PHP set the action to /customer-portal.php --> <button type="submit">Manage Billing</button> </form> </body> </html>
After exiting the customer portal, the customer returns to your website at the return_
. Continue to monitor events to track the status of the customer’s subscription.
If you configure the customer portal to allow actions such as canceling a subscription, monitor additional events.
Test your integration
支払い方法をテストする
次の表を使用して、さまざまな支払い方法とシナリオをテストします。
決済手段 | シナリオ | テスト方法 |
---|---|---|
BECS ダイレクトデビット | 顧客が BECS ダイレクトデビットによる支払いに成功します。 | アカウント番号900123456 と BSB000000 を使用して、フォームに入力します。確定された PaymentIntent のステータスは、まずprocessing に移行し、3 分後にsucceeded ステータスに移行します。 |
BECS ダイレクトデビット | 顧客の支払いが account_ エラーコードで失敗します。 | アカウント番号 111111113 と BSB 000000 を使用して、フォームに入力します。 |
クレジットカード | カード支払いは成功し、認証は必要とされません。 | クレジットカード番号 4242 4242 4242 4242 と、任意の有効期限、セキュリティコード、郵便番号を使用してクレジットカードフォームに入力します。 |
クレジットカード | カード決済で認証が要求されます。 | クレジットカード番号 4000 0025 0000 3155 と、任意の有効期限、セキュリティコード、郵便番号を使用してクレジットカードフォームに入力します。 |
クレジットカード | カードが insufficient_ などの拒否コードで支払い拒否されます。 | クレジットカード番号 4000 0000 0000 9995 と、任意の有効期限、セキュリティコード、郵便番号を使用してクレジットカードフォームに入力します。 |
SEPA ダイレクトデビット | 顧客が SEPA ダイレクトデビットによる支払いに成功します。 | 口座番号 AT321904300235473204 を使用して、フォームに入力します。確定された PaymentIntent のステータスはまず、processing に移行し、3 分後に succeeded ステータスに移行します。 |
SEPA ダイレクトデビット | 顧客の PaymentIntent ステータスが processing から requires_ に移行します。 | 口座番号 AT861904300235473202 を使用して、フォームに入力します。 |
Monitor events
Set up webhooks to listen to subscription change events, such as upgrades and cancellations. You can view subscription webhook events in the Dashboard or with the Stripe CLI.
Learn more about testing your Billing integration.