paymentIntents如果因任何原因确认失败会返回什么?

huangapple go评论53阅读模式
英文:

What will paymentIntents return if confirmation fails due to any reason?

问题

  1. 从返回的对象 payment_intent 中,我该如何检查支付确认是否成功扣款?
  2. 如果支付失败,它会抛出错误吗,还是会返回一些表示失败的标志?
英文:
const payment_intent = await stripe.paymentIntents.create({
          customer: customer_id,
          payment_method: pm_id,
          amount: 1000,
          currency: "usd",
          confirm: true,
          off_session: true,
          //-------------------------------------
        });

The question is:

  1. From the returned object, payment_intent, how can I check if the payment confirmation was successfully charged?
  2. Will it throw an error if it fails or will it return some flag to indicated failure?

答案1

得分: 1

stripe.paymentIntents.create 返回一个PaymentIntent对象,其中包含last_payment_error属性,该属性包含"在上一个PaymentIntent确认中遇到的支付错误。" 因此,如果失败,您可以在该属性中找到原因。

要知道是否成功,可以检查PaymentIntent对象的status属性。如果成功,它将返回succeeded,如果尚未成功,它将显示当前状态。

编辑

如果API调用被阻止以继续,可能有许多原因,包括卡错误,它会引发错误。可以在这里看到可能的错误列表。

英文:

stripe.paymentIntents.create returns a PaymentIntent object, which contains the last_payment_error property, which contains "The payment error encountered in the previous PaymentIntent confirmation." So, if it fails you can find the reason for it in that property.

To know, if it succeeded, you can check the status property of the PaymentIntent object. Which returns succeeded, if it did. Or shows the current status, if it didn't succeed, yet.

EDIT

It would throw an error, if an API call is prevented from continuing, which could have many reasons, including a card error. A list of possible errors can be seen here.

huangapple
  • 本文由 发表于 2023年6月8日 08:39:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76427925.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定