stripe-payments - 如何获取 PaymentIntent next_action.type = redirect_to_url 而不是 use_stripe_sdk 进行订阅

标签 stripe-payments

我正在使用 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-typenext_action.type可以有两个值 redirect_to_urluse_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/

相关文章:

api - Stripe Webhooks - 我可以发送 200 以外的响应代码吗?

javascript - Stripe.JS - 使用附加数据创建源(所有者)

mysql - 如何从 Rails 3 中的 Stripe gem 捕获 Web hook?

node.js - stripe.customers.retrieve 导致问题,因为它现在正在返回 Stripe.Customer | Stripe .DeletedCustomer

android-studio - 在 flutter 应用程序中集成 srtipe 时出现 Gradle 异常

ruby-on-rails - 我可以在添加新卡之前检查 Stripe 客户是否已经拥有特定卡吗?

ruby-on-rails - 将订阅模型与用户模型相关联

javascript - 付款请求按钮的自定义主题 [Stripe]

javascript - 从 Stripe API 检索发票时,如何缩小结果范围以仅检索对象内一个属性的数据?

python - Django - Stripe 订阅