Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Developer tools
Get started
Payments
Finance automation
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Overview
About Stripe payments
Upgrade your integration
Payments analytics
Online payments
OverviewFind your use caseManaged Payments
Use Payment Links
Build a checkout page
    Overview
    Quickstarts
    Customize look and feel
    Collect additional information
    Collect taxes
    Dynamically update checkout
    Manage your product catalog
    Subscriptions
    Manage payment methods
    Let customers pay in their local currency
    Add discounts, upsells, and optional items
    Set up future payments
    Save payment details during payment
    Manually approve payments on your server
    After the payment
      Fulfill orders
      Send receipts and paid invoices
      Customize redirect behavior
      Recover abandoned carts
      Analyze conversion funnel
    Elements with Checkout Sessions API beta changelog
    Migrate from legacy Checkout
    Migrate Checkout to use Prices
Build an advanced integration
Build an in-app integration
Payment methods
Add payment methods
Manage payment methods
Faster checkout with Link
Payment interfaces
Payment Links
Checkout
Web Elements
In-app Elements
Payment scenarios
Custom payment flows
Flexible acquiring
Orchestration
In-person payments
Terminal
Other Stripe products
Financial Connections
Crypto
Climate
HomePaymentsBuild a checkout pageAfter the payment

Customize redirect behavior

Display a confirmation page with your customer's order information.

Copy page

If you have a Checkout integration that uses a Stripe-hosted page, Stripe redirects your customer to a success page that you create and host on your site. You can use the details from a Checkout Session to display an order confirmation page for your customer (for example, their name or payment amount) after the payment.

Redirect customers to a success page

To use the details from a Checkout Session:

  1. Modify the success_url to pass the Checkout Session ID to the client side.
  2. Look up the Checkout Session using the ID on your success page.
  3. Use the Checkout Session to customize what’s displayed on your success page.

Modify the success URL Server-side

Add the {CHECKOUT_SESSION_ID} template variable to the success_url when you create the Checkout Session. Note that this is a literal string and must be added exactly as you see it here. Do not substitute it with a Checkout Session ID—this happens automatically after your customer pays and is redirected to the success page.

Ruby
session = Stripe::Checkout::Session.create( success_url: "http://yoursite.com/order/success", success_url: "http://yoursite.com/order/success?session_id={CHECKOUT_SESSION_ID}", # other options..., )

Create the success page Server-side

Look up the Checkout Session using the ID and create a success page to display the order information. This example prints out the customer’s name:

Ruby
# This example sets up an endpoint using the Sinatra framework. # Watch this video to get started: https://youtu.be/8aA9Enb8NVc. # Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys Stripe.api_key =
'sk_test_BQokikJOvBiI2HlWgH4olfQ2'
require 'sinatra' get '/order/success' do session = Stripe::Checkout::Session.retrieve(params[:session_id]) customer = Stripe::Customer.retrieve(session.customer) "<html><body><h1>Thanks for your order, #{customer.name}!</h1></body></html>" end

Test the integration

To confirm that your redirect is working as expected:

  1. Click the checkout button.
  2. Fill in the customer name and other payment details.
  3. Click Pay.

If it works, you’re redirected to the success page with your custom message. For example, if you used the message in the code samples, the success page displays this message: Thanks for your order, Jenny Rosen!

Was this page helpful?
YesNo
Need help? Contact Support.
Join our early access program.
Check out our changelog.
Questions? Contact Sales.
LLM? Read llms.txt.
Powered by Markdoc