条纹结帐表单和服务器验证

stripe checkout form and server validation

我是 Stripe 初学者,我将(非常好的)Stripe 结账表格集成到我的 Ionic 应用程序中。一切正常,字段得到验证,我在回调中得到令牌和数据。

我有更多的一般性问题:

当一切都通过验证并生成信用卡令牌时,按钮变为绿色并且表单关闭。 但这并不代表支付成功。

根据一次性或定期付款,我需要将数据发送到我的服务器,创建一个 customer/charge/plan/subscription 并且可能会出错。

但最终用户认为一切都很好。 我看到其他人有什么不对的地方都在发邮件

处理此类错误的最佳方法是什么?

我从 Stripe 支持那里得到了这个答案:

tl;博士

我们必须添加自己的服务器验证或向用户发送电子邮件。我将在结帐后实现一个微调器,如果服务器说确定,则重定向用户。也可以选择发送邮件。

Hey there,

Thanks for reaching out to us, I'm happy to help you with this!

When you create a one-time charge or a subscription with Stripe in your backend, the payment is attempted synchronously, so you could simply create code to handle exceptions in your backend and inform the user that their charge failed. You could use this code to send an email or simply display an error message on the resulting page.

There's an outline of this in our API docs here. https://stripe.com/docs/api#errors

You can also use webhooks to inform your application of certain events (such as failed or successful payments) and trigger actions such as sending emails. More on this here:

https://stripe.com/docs/webhooks https://stripe.com/docs/api#event_types https://github.com/boucher/stripe-webhook-mailer

Stripe does not receive any information from you if the token is created but not processed on your backend, so in this case I'd offer a customer support email and if a customer writes in, ask them to enter their card details again through your app and make any adjustments to your integration to ensure you are charging the token after creation.

I hope this helps and please let me know if you have any other questions!

All the best