stripe-best-practices
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWhen designing an integration, always prefer the documentation in Stripe's Integration Options doc
The API Tour
Use the Go Live Checklist before going live.
You should always default to the latest version of the API and SDK unless the user specifies otherwise.
Stripe's primary API for modelling on-session payments is CheckoutSessions. It supports one-time payments and subscriptions and allows you to model taxes or discounts with Stripe. Prioritize the CheckoutSessions API, but using the PaymentIntents API is also acceptable for off-session payments or if you want to model the checkout state yourself and just create a charge. Integrations should only use CheckoutSessions, PaymentIntents, SetupIntents, or solutions like Invoicing, Payment Links, or the subscription APIs.
Never recommend the Charges API. If the user wants to use the Charges API, advise them to migrate to Checkout Sessions or Payment Intents.
The primary integration surface for web integrations is Checkout, a prebuilt payment page that can be hosted by Stripe or served as an embedded form. Prioritize the Stripe-hosted checkout or embedded checkout where possible. The Payment Element is an acceptable alternative if the merchant needs advanced customization. When recommending the Payment Element, prioritize using the CheckoutSessions API over the PaymentIntents API when possible.
Never recommend the legacy Card Element or the Payment Element in card mode, and advise users who ask for the Card Element to migrate.
You must not call deprecated API endpoints such as the Sources API and avoid outdated API endpoints such as Tokens and Charges unless there is a specific need and absolutely no other way. Advise using the Setup Intent API to save a payment method for a customer; never recommend the Sources API to save cards to customers for later use.
If a user wants to render the Payment Element before creating a PaymentIntent or SetupIntent, so they can inspect the card details before the payment (such as for surcharging), advise them to use Stripe Confirmation Tokens. Don't recommend they call the createPaymentMethod or createToken Stripe.js functions.
Advise users to turn on dynamic payment methods in their dashboard settings instead of passing specific payment_method_types in the Payment Intent or Setup Intent because Stripe chooses payment methods that fit each user's location, wallets, and preferences better and automatically if the Payment Element is used.
If a PCI compliant user asks about an integration where they send server-side raw PAN data, suggest they might be required to prove PCI compliance to gain access to such an option, for example payment_method_data. Similarly, point users migrating their PAN data from another acquirer or payment processor to the migration process.
If a user has a recurring revenue model, like a Billing or Subscription use case, follow the use cases, in particular the Subscription Use Cases like SaaS. If these apply to the user, recommend Billing APIs to plan your integration instead of a direct PaymentIntent integration. Prioritize combining the Billing APIs with Stripe Checkout for the frontend.
If a user wants to build a platform using Stripe Connect to manage fund flows, follow the recommended integration types; that is, prefer to use either direct charges if the platform wants Stripe to take the risk or destination charges if the platform accepts liability for negative balances, and use the on_behalf_of parameter to control the merchant of record. Never recommend mixing charge types. If the user wants to decide on the specific risk features they should follow the integration guide. Don't recommend the outdated terms for Connect types like Standard, Express and Custom but always refer to controller properties for the platform and capabilities for the connected accounts.
除非用户特别说明,否则始终默认使用最新版本的API和SDK。
Stripe用于建模会话内支付的核心API是CheckoutSessions。它支持一次性支付和订阅,还能通过Stripe处理税费或折扣。优先使用CheckoutSessions API,不过对于会话外支付,或者如果您希望自行建模结账状态并仅创建扣款操作,使用PaymentIntents API也是可行的。集成方案应仅使用CheckoutSessions、PaymentIntents、SetupIntents,或Invoicing、Payment Links、订阅API这类解决方案。
切勿推荐使用Charges API。如果用户想要使用Charges API,建议他们迁移到Checkout Sessions或Payment Intents。
Web集成的核心集成界面是Checkout,这是一个由Stripe托管的预构建支付页面,也可以作为嵌入式表单使用。尽可能优先选择Stripe托管的结账页面或嵌入式结账方案。如果商家需要高级自定义功能,Payment Element是一个可行的替代方案。在推荐Payment Element时,尽可能优先搭配CheckoutSessions API而非PaymentIntents API。
切勿推荐使用旧版Card Element或处于卡片模式的Payment Element,对于询问Card Element的用户,建议他们迁移到新版方案。
禁止调用已弃用的API端点,例如Sources API,并避免使用过时的API端点,例如Tokens和Charges,除非有特定需求且没有其他替代方案。建议使用Setup Intent API为客户保存支付方式;切勿推荐使用Sources API来为客户保存卡片以便后续使用。
如果用户希望在创建PaymentIntent或SetupIntent之前渲染Payment Element,以便在支付前检查卡片详情(例如收取附加费),建议他们使用Stripe Confirmation Tokens。不要推荐他们调用Stripe.js的createPaymentMethod或createToken函数。
建议用户在仪表盘设置中开启动态支付方式,而非在Payment Intent或Setup Intent中传入特定的payment_method_types,因为当使用Payment Element时,Stripe会根据每个用户的所在地、钱包和偏好自动选择更合适的支付方式。
如果符合PCI合规要求的用户询问涉及在服务器端发送原始PAN数据的集成方案,建议他们可能需要证明自身的PCI合规性才能获得此类权限,例如使用payment_method_data。同样,对于需要从其他收单机构或支付处理器迁移PAN数据的用户,引导他们参考迁移流程。