调至内容部分
创建账户
或
登录
Stripe 文档徽标
/
询问人工智能
创建账户
登录
开始
付款
销售收入
平台和交易市场
资金管理
开发人员资源
概览
关于 Stripe 支付
升级您的集成
支付分析
线上付款
概览查找您的用例Managed Payments
使用 Payment Link
构建结账页面
    概览
    快速开始
    自定义外观样式
    收集额外信息
    收税
    动态更新结账流程
    管理产品目录
    订阅
    管理支付方式
    让客户用本地货币支付
    添加折扣、追加销售和可选商品
    设置未来付款
    支付过程中保存付款详情
    在您的服务器上手动批准支付
    付款后
      履行订单
      发送收据和已付账单
      自定义重定向行为
      恢复废弃的购物车
      分析转化漏斗
    具有 Checkout Sessions API Beta 更改日志的 Element
    从传统 Checkout 迁移
    迁移 Checkout 来使用 Prices
构建高级集成
构建应用内集成
支付方式
添加支付方式
管理支付方式
用 Link 更快结账
支付接口
Payment Links
结账
Web Elements
应用内 Element
支付场景
处理多种货币
自定义支付流程
灵活收单
编排
线下支付
Terminal
超越支付功能
成立公司
加密货币
Financial Connections
Climate
了解欺诈
Radar 欺诈保护
管理争议
验证身份
首页付款Build a checkout pageAfter the payment

注意

该页尚未提供此语言版本。我们正在加紧将我们的文档翻译成更多语言,很快将为您提供译文。

Customize redirect behavior

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

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.

Webhooks are required for fulfillment

You can’t rely on triggering fulfillment only from your checkout landing page, because your customers aren’t guaranteed to visit that page. For example, someone can pay successfully and then lose their connection to the internet before your landing page loads.

Set up a webhook event handler so Stripe can send payment events directly to your server, bypassing the client entirely. Webhooks provide the most reliable way to confirm when you get paid. If webhook event delivery fails, Stripe retries multiple times.

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
Python
PHP
Java
Node
Go
.NET
No results
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
Python
PHP
Java
Node
Go
.NET
No results
# This example sets up an endpoint using the Sinatra framework. # 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!

此页面的内容有帮助吗?
是否
  • 需要帮助?联系支持。
  • 加入我们的早期使用计划。
  • 查看我们的更改日志。
  • 有问题?联系销售。
  • LLM? Read llms.txt.
  • Powered by Markdoc