# 卡的运作机制 了解在线信用卡或借记卡付款的原理。 [银行卡](https://docs.stripe.com/payments/cards.md)是在线支付最常用的方式之一,在全球范围内应用广泛。银行卡有多种类型,支付流程也包含多个步骤。有关支付方式交易费用的信息,请参阅[本地支付方式定价](https://stripe.com/pricing/local-payment-methods)。 ## 支付流程 为了构建能够支持所有客户的 Stripe 集成,您需要了解银行卡支付背后的流程。 ### 检查银行卡信息 Stripe 检查提供的信息格式是否正确(例如,到期日是否是过去的日期)。这时并不能保证卡本身是否有效。 ### 客户身份验证 一些银行,尤其是欧洲和印度等受监管地区的银行,可能会提示客户对购买进行身份验证。例如,客户可能会收到一条含代码的短信,让其在银行网站上输入代码。 ### 授权 银行检查资金是否充足,如果成功,则冻结客户账户的此金额,保证可以向 Stripe 用户进行支付。 ### 捕获 钱从发卡行流向 Stripe 用户的账户。 ## 银行卡更新 [更新已保存的卡](https://docs.stripe.com/api/cards/update.md)只能更改其名称、账单地址、有效期或元数据。若要进行任何其他更改,您必须删除该卡并创建一张新卡。 要让您的客户管理他们自己的支付方式,实施一个流程,允许他们手动更新和替换他们保存的卡。 要更改客户的账单和订阅的默认支付方式,请发起 API 调用来[更新客户](https://docs.stripe.com/api.md#update_customer),并为 `invoice_settings.default_payment_method` 属性提供新的值。 ```curl curl https://api.stripe.com/v1/customers/cus_V9T7vofUbZMqpv \ -u "<>:" \ -d "invoice_settings[default_payment_method]"=pm_1Msy7wLkdIwHu7ixsxmFvcz7 ``` 有关 Checkout 如何处理已保存支付方式的信息,请参阅[创建 Checkout Session](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-customer)。如需在其他情境中考虑默认支付方式,请使用自定义代码。 ## 银行卡自动更新 即使发卡行已更换了某张实物卡片,但已保存的支付方式的详情仍可继续作用。Stripe 与*卡组织* (A network that processes the transactions of a particular card brand. It might be an intermediary in front of an issuing bank as with Visa or Mastercard, or a standalone entity as with American Express)深入合作,在客户收到新卡后(例如更换到期、挂失或被盗的卡片),自动尝试更新保存的卡片信息。这样,客户可以不间断的使用您的服务,减少了客户换卡后收集新卡信息的麻烦。 银行卡自动更新功能要求*发卡行* (The entity that issued a payment card to a cardholder. This could be a bank, such as with the Visa or Mastercard network, or it could be the card network itself, such as with American Express)加入卡组织并提供这一信息。这在美国被广泛支持,使得 Stripe 能够自动更新所发行的多数 American Express、Visa、Mastercard 以及 Discover 信用卡。国际支持因国家而异。没有办法识别哪些卡可以自动更新。 您可以通过侦听 Stripe *Webhook* (A webhook is a real-time push notification sent to your application as a JSON payload through HTTPS requests) 来洞悉银行卡的更新活动: - `payment_method.updated` 事件通过 API 调用通知您银行卡的更新情况。 - `payment_method.automatically_updated` 事件的作用是在卡组织自动更新银行卡时给您发送通知。 因此如果需要更新自己的记录,这些事件中要包含新卡的有效期和卡片末四位。如果卡更新时包含新的卡号,则 [fingerprint](https://docs.stripe.com/api/payment_methods/object.md#payment_method_object-card-fingerprint) 会发生变化。 ## See also - [银行卡](https://docs.stripe.com/payments/cards.md) - [联名卡的合规](https://docs.stripe.com/co-badged-cards-compliance.md) - [支付方式集成选项](https://docs.stripe.com/payments/payment-methods/integration-options.md)