我正在使用 Stripe 实现 Subscription*(已准备好 SCA)。
我尝试处理 https://stripe.com/docs/billing/subscriptions/payment#handling-action-required .
在 Stripe 端创建订阅后,我得到了上面文档中的答案:
{
"id": "sub_XXXXXXXXXXXXXXXXXXX",
"object": "subscription",
"status": "incomplete",
...
"latest_invoice": {
...
"payment_intent": {
"status": "requires_action",
...
"next_action": {
"type": "use_stripe_sdk",
...
},
...
}
}
}
根据文档 https://stripe.com/docs/api/payment_intents/object#payment_intent_object-next_action-type
next_action.type
可以有两个值 redirect_to_url
和 use_stripe_sdk
所以我的问题是如何获得
next_action.type = redirect_to_url
(而不是 use_stripe_sdk
)以及如何强制条纹填充 next_action.redirect_to_url
(因为我想在我的 UI 中自己处理它)?*关于SO已经有一个类似的问题:
https://stackoverflow.com/questions/56490033/how-to-handle-use-stripe-sdk-through-php
但我的情况是创建 订阅 我无法控制 PaymentIntent
最佳答案
据我了解, next_action.type
将等于 redirect_to_url
仅当您选择手动处理 3D 安全身份验证 https://stripe.com/docs/payments/payment-intents/verifying-status#manual-3ds-auth
根据文档:
To handle 3D Secure authentication manually, you can redirect the customer. This approach is used when you manually confirm the PaymentIntent and provide a
return_url
destination to indicate where the customer should be sent once authentication is complete. Manual PaymentIntent confirmation can be performed on the server or on the client with Stripe.js.
使用 Stripe.js 的示例:
stripe.confirmPaymentIntent(
'{PAYMENT_INTENT_CLIENT_SECRET}',
{
payment_method: '{PAYMENT_METHOD_ID}',
return_url: 'https://example.com/return_url'
}
).then(function(result) {
// Handle result.error or result.paymentIntent
});
使用 Stripe Python 的示例:
intent = stripe.PaymentIntent.confirm(
'{PAYMENT_INTENT_ID}',
payment_method='{PAYMENT_METHOD_ID}',
return_url='https://example.com/return_url'
)
编辑:根据 @karllekko's评论
{PAYMENT_INTENT_ID}
在您的情况下将是 latest_invoice.payment_intent.id
.
关于stripe-payments - 如何获取 PaymentIntent next_action.type = redirect_to_url 而不是 use_stripe_sdk 进行订阅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56898839/