英文:
What will paymentIntents return if confirmation fails due to any reason?
问题
- 从返回的对象
payment_intent
中,我该如何检查支付确认是否成功扣款? - 如果支付失败,它会抛出错误吗,还是会返回一些表示失败的标志?
英文:
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:
- From the returned object,
payment_intent
, how can I check if the payment confirmation was successfully charged? - 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论