调至内容部分
创建账户
或
登录
Stripe 文档徽标
/
询问人工智能
创建账户
登录
开始
付款
财务自动化
平台和交易市场
资金管理
开发人员工具
开始
付款
财务自动化
开始
付款
财务自动化
平台和交易市场
资金管理
概览
关于 Stripe 支付
升级您的集成
支付分析
线上付款
概览查找您的用例Managed Payments
使用 Payment Link
构建结账页面
    概览
    快速开始
    自定义外观样式
    收集额外信息
    收税
    动态更新结账流程
    管理产品目录
    订阅
    管理支付方式
      添加一键按钮
      向管理平台迁移支付方式
    让客户用本地货币支付
    添加折扣、追加销售和可选商品
    设置未来付款
    支付过程中保存付款详情
    在您的服务器上手动批准支付
    付款后
    具有 Checkout Sessions API Beta 更改日志的 Element
    从传统 Checkout 迁移
    迁移 Checkout 来使用 Prices
构建高级集成
构建应用内集成
支付方式
添加支付方式
管理支付方式
用 Link 更快结账
支付接口
Payment Links
结账
Web Elements
应用内 Element
支付场景
自定义支付流程
灵活收单
编排
线下支付
Terminal
其他 Stripe 产品
Financial Connections
加密货币
Climate
首页付款Build a checkout pageManage payment methods

向管理平台迁移支付方式

通过管理平台开启不同的 Checkout 支付方式。

复制页面

通过更改您的集成来从管理平台提取您的支付方式首选项,Stripe 会根据选择的货币或任何支付方式限制(例如最大交易限额)在结账时向您的客户显示所有兼容的支付方式。Stripe 还会根据每个客户所在地和使用的货币显示最相关的支付方式。

结账页面优先显示客户所在位置的已知支付方式,以提高转化率,而优先级低的支付方式会在溢出菜单下方隐藏。您的客户在结账时看到多个他们所在地方的流行支付方式和货币,但他们仍可从溢出菜单中选择其他支付方式。

更新您的集成

对于指定 payment_method_types 的现有 Stripe Checkout 集成,您必须删除该参数,才能将支付方式首选项迁移到管理平台。从您的集成移除参数后,某些支付方式会自动开启,包括银行卡和钱包。currency 参数限制客户在 Checkout Session 中看到的支付方式。

警告

升级您的集成时,会先关闭您的集成的所有非默认支付方式,比如银行重定向。如果您向您的 Checkout 集成添加了支付方式,则必须前往管理平台的支付方式设置页面来重新开启它们。

server.rb
Ruby
Stripe::Checkout::Session.create({ line_items: [ { price_data: { currency: 'eur', product_data: {name: 'T-shirt'}, unit_amount: 2000, }, quantity: 1, }, ], mode: 'payment', # Remove the payment_method_types parameter to manage payment methods in the Dashboard payment_method_types: ['card'], success_url: 'https://example.com/success', })

在管理平台中查看可用的支付方式

查看您的支付方式设置,看看您当前接受的支付方式。该列表中包含默认开启的支付方式,例如银行卡。这些支付方式的费用与银行卡类似或更低,并且可以立即结算。

Payment methods

By default, Stripe enables cards and other common payment methods. You can turn individual payment methods on or off in the Stripe Dashboard. In Checkout, Stripe evaluates the currency and any restrictions, then dynamically presents the supported payment methods to the customer.

To see how your payment methods appear to customers, enter a transaction ID or set an order amount and currency in the Dashboard.

You can enable Apple Pay and Google Pay in your payment methods settings. By default, Apple Pay is enabled and Google Pay is disabled. However, in some cases Stripe filters them out even when they’re enabled. We filter Google Pay if you enable automatic tax without collecting a shipping address.

Checkout’s Stripe-hosted pages don’t need integration changes to enable Apple Pay or Google Pay. Stripe handles these payments the same way as other card payments.

向您的集成添加支付方式或从中删除支付方式

在管理平台内的支付方式设置页面,您可以看到可用的支付方式并为您的集成开启新的支付方式。

您只需选择开启,即可启用一些支付方式。但是,某些支付方式要求额外的步骤才能开启。这些情况下,您会看到一个写有设置或审查条款字样的按钮。

要了解哪些支付方式适合您的业务,请查看我们的支付方式指南。

(推荐)处理延迟通知型支付方式

根据您集成的支付方式类型,付款确认可能会有 2-14 天的延迟。如果您在您的 Checkout 集成中设置了 webhooks 来自动履行 订单,则当您添加第一个延迟通知型支付方式时,您可能需要更新您的代码。

注意

This step is only required if you plan to use any of the following payment methods: Bacs Direct Debit, Bank transfers, Boleto, Canadian pre-authorized debits, Konbini, OXXO, Pay by Bank, SEPA Direct Debit, SOFORT, or ACH Direct Debit.

收到通过延迟通知型支付方式进行的付款时,资金不会立即到账。资金处理可能需要好几天,因此您应该延迟履行订单,直至资金到达您的账户。付款成功后,相关的 PaymentIntent 的状态将从 processing 变为 succeeded。

您需要处理以下 Checkout 事件:

事件名称描述后续步骤
checkout.session.completed客户通过提交 Checkout 表单成功授权了借记付款。等待付款成功或失败。
checkout.session.async_payment_succeeded客户付款成功。交付购买的商品或服务。
checkout.session.async_payment_failed付款被拒绝,或因其他原因未成功。Contact the customer through email and request that they place a new order.

These events all include the Checkout Session object.

更新您的事件处理程序,以履行订单:

Ruby
# 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'
# You can find your endpoint's secret in the output of the `stripe listen` # command you ran earlier endpoint_secret = 'whsec_...' post '/webhook' do event = nil # Verify webhook signature and extract the event # See https://stripe.com/docs/webhooks#verify-events for more information. begin sig_header = request.env['HTTP_STRIPE_SIGNATURE'] payload = request.body.read event = Stripe::Webhook.construct_event(payload, sig_header, endpoint_secret) rescue JSON::ParserError => e # Invalid payload return status 400 rescue Stripe::SignatureVerificationError => e # Invalid signature return status 400 end case event['type'] if event['type'] == 'checkout.session.completed' checkout_session = event['data']['object'] fulfill_order(checkout_session) end when 'checkout.session.completed' checkout_session = event['data']['object'] # Save an order in your database, marked as 'awaiting payment' create_order(checkout_session) # Check if the order is already paid (for example, from a card payment) # # A delayed notification payment will have an `unpaid` status, as # you're still waiting for funds to be transferred from the customer's # account. if checkout_session.payment_status == 'paid' fulfill_order(checkout_session) end when 'checkout.session.async_payment_succeeded' checkout_session = event['data']['object'] # Fulfill the purchase... fulfill_order(checkout_session) when 'checkout.session.async_payment_failed' session = event['data']['object'] # Send an email to the customer asking them to retry their order email_customer_about_failed_payment(checkout_session) end status 200 end def fulfill_order(checkout_session) # TODO: fill in with your own logic puts "Fulfilling order for #{checkout_session.inspect}" end def create_order(checkout_session) # TODO: fill in with your own logic puts "Creating order for #{checkout_session.inspect}" end def email_customer_about_failed_payment(checkout_session) # TODO: fill in with your own logic puts "Emailing customer about payment failure for: #{checkout_session.inspect}" end

测试

确保 stripe listen 仍在运行。以测试用户身份走一遍 Checkout,和之前步骤一样。您的事件处理程序应该会收到一个 checkout.session.completed 事件,并且您应该已经成功处理了它。

这些步骤都已完成,可随时将其投入生产。

测试您的集成

卡号场景如何测试
该卡付款成功,不需要验证。使用信用卡号以及有效期和 CVC 和邮编填写我们的信用卡表单。
该卡付款时需要验证。使用信用卡号以及有效期和 CVC 和邮编填写我们的信用卡表单。
该卡被拒绝,显示拒付代码,例如 insufficient_funds。使用信用卡号以及有效期和 CVC 和邮编填写我们的信用卡表单。
银联卡的长度为 13-19 位。使用信用卡号以及有效期和 CVC 和邮编填写我们的信用卡表单。

有关测试您的集成的更多信息,请参阅测试部分。

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