# Setup Intents API 更多地了解任何用 Setup Intents API 保存支付方式。 用 *Setup Intents API* (The Setup Intents API lets you build dynamic flows for collecting payment method details for future payments. It tracks the lifecycle of a payment setup flow and can trigger additional authentication steps if required by law or by the payment method) 设置一个用于未来付款的支付方式。它与付款类似,但不用创建收款。[立即设置用于未来付款的支付方式](https://docs.stripe.com/payments/save-and-reuse.md)。 目标是保存支付证书,并为未来付款进行优化,也就是为任何支付场景正确配置支付方式。以设置银行卡为例,可能有必要通过客户的银行验证客户或检查卡的有效性。Stripe 在整个过程中更新 `SetupIntent` 对象。 ## 保存并重新使用支付方式 Setup Intents API 尤其适用于那些入驻了客户但不立即对其扣款的公司: - 一家汽车租赁公司,在客户租车前收集支付方式详情,租期结束后再对银行卡扣款。 - 一个众筹网站,先收集银行卡信息,之后活动达到某一特定金额时才扣款。 - 一家公用事业公司,每月根据用量扣取不同金额,但是要在第一个月付款前收集 SEPA 支付信息。 > 您也可在 [Checkout](https://docs.stripe.com/payments/save-and-reuse.md?platform=checkout) 并完成收款的同时,设置支付方式以便未来使用。 #### 开始 - [不预先扣款的情况下保存银行卡](https://docs.stripe.com/payments/save-and-reuse.md) - [保存银行详情用于 SEPA 直接借记付款](https://docs.stripe.com/payments/sepa-debit/set-up-payment.md) - [保存银行详情用于 BECS 直接借记付款](https://docs.stripe.com/payments/au-becs-debit/set-up-payment.md) ## 获取保存支付方式的授权 当您保存客户支付详情时,需自行负责遵守所有相关法律法规及银行卡组织规则。 ### 未来会话内使用 若您将支付方式设置为支持未来*会话内* (A payment is described as on-session if it occurs while the customer is actively in your checkout flow and able to authenticate the payment method)支付(例如在未来的结账页面展示该支付方式),则必须明确获取客户对此特定用途的授权。例如,可添加“保存我的支付方式以便未来使用”复选框来获取客户授权。 若您需要区分仅用于会话外的支付方式,以及可在未来*会话内* (A payment is described as on-session if it occurs while the customer is actively in your checkout flow and able to authenticate the payment method)购物中向客户展示的支付方式,可使用 PaymentMethod 对象中的 [allow_redisplay](https://docs.stripe.com/api/payment_methods/object.md#payment_method_object-allow_redisplay) 参数。 ### 未来会话外使用 如果您设置一个支付方式用于未来的*会话外* (A payment is described as off-session if it occurs without the direct involvement of the customer, using previously-collected payment information)付款,则您需要获得许可。事先制作一份协议(有时候叫做_授权_)后您便可以在客户不经常使用您的网站或应用的情况对其进行扣款。 在您的网站或应用中添加条款,陈明您计划如何处理付款,并让客户同意加入。条款中至少要包含以下几点: - 客户给予您代其发起一次或一系列付款的许可 - 预计的付款频率(即一次性或经常性) - 如何确定付款金额 请查看针对[保存银行卡](https://docs.stripe.com/payments/save-and-reuse.md?platform=web&ui=elements#collect-payment-details)或[保存 SEPA 银行详情](https://docs.stripe.com/payments/sepa-debit/set-up-payment.md)推荐的授权文本。 对于受 *SCA* (Strong Customer Authentication (SCA) is a regulatory requirement in effect as of September 14, 2019, that impacts many European online payments. It requires customers to use two-factor authentication like 3D Secure to verify their purchase) 影响的用户,该协议可确保付款顺利成功。在您设置了您的集成可以正确保存银行卡之后,Stripe 会将后续的任何会话外付款标为*商家发起的交易* (A payment made off-session with a properly authenticated saved card, can qualify as merchant-initiated transaction and be exempt from SCA) (MIT),这样客户便不需要再回到线上并进行验证了。处理商家发起的交易时需要有您与客户之间签订的协议 ## 明确使用场景以提高成功率 [usage](https://docs.stripe.com/api/setup_intents/object.md#setup_intent_object-usage) 参数用于告知 Stripe 您今后计划如何使用保存的支付方式详情。对于某些支付方式,Stripe 可利用您的 `usage` 设置为客户选取最顺畅的流程。这种优化旨在增加成功付款的次数。 例如,欧洲的 *SCA* (Strong Customer Authentication (SCA) is a regulatory requirement in effect as of September 14, 2019, that impacts many European online payments. It requires customers to use two-factor authentication like 3D Secure to verify their purchase) 规范监管下的信用卡和借记卡可能需要客户在保存过程中对银行卡进行验证。将 `usage` 设置为 `off_session`,可为会话外付款正确验证信用卡或借记卡,客户便可以不回到线上再重新验证。虽然在最初的设置流程中会带来一些阻力,但是将 `usage` 设置为 `off_session` 可让客户在后续的会话外付款时更加轻松。 但是,如果您只计划在客户结账时用卡,则将 `usage` 设置为 `on_session`。这样银行就会知道您只会在客户能够进行验证的时才使用银行卡,因此您可以将银行卡详情的验证推迟到此时候,避免前期造成的阻力。 | 您打算如何用卡 | 要使用的用法枚举值 | | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | | 仅*会话内* (A payment is described as on-session if it occurs while the customer is actively in your checkout flow and able to authenticate the payment method)付款 | `on_session` | | 仅*会话外* (A payment is described as off-session if it occurs without the direct involvement of the customer, using previously-collected payment information)付款 | `off_session`(默认) | | 会话内与会话外这两种付款方式 | `off_session`(默认) | `Usage` 是一种优化措施。您仍然可以使用已设置为会话内支付的卡片来进行会话外支付,但银行更有可能拒绝会话外支付并要求客户进行身份验证。无论哪种情况,都可能会要求后续的身份验证,因此建议在您的应用中[构建一个恢复流程](https://docs.stripe.com/billing/revenue-recovery.md)。当会话外卡支付需要身份验证时,让您的客户重新上线完成支付。 如果未指定,则 `usage` 默认为 `off_session`。查看如何在您的服务器上创建 SetupIntent 并指定 `usage`: ```curl curl https://api.stripe.com/v1/setup_intents \ -u "<>:" \ -d usage=on_session ``` > 请按照该页的指南操作,确保您的集成能够处理要求*强客户认证* (Strong Customer Authentication (SCA) is a regulatory requirement in effect as of September 14, 2019, that impacts many European online payments. It requires customers to use two-factor authentication like 3D Secure to verify their purchase)的银行卡。正确标记交易有助于 Stripe 代您正确申请 SCA 豁免,将每笔付款的验证要求降到最低。