[英]Best way to handle one-time payments with STRIPE webhooks in nodeJS
I am using STRIPE as my payment processor, in an REACT + nodeJS app.我在一个 REACT + nodeJS 应用程序中使用 STRIPE 作为我的支付处理器。 I already have something that already works, but I would like some feedback, maybe I'm doing something wrong.
我已经有一些已经有效的东西,但我想要一些反馈,也许我做错了什么。 So... I have this Redirect-To-Checkout functionality thats made available by STRIPE, basically I redirect the user to this STRIPE page where all card-data (sensitive information) is processes in order for the payment to full-fill.
所以...我有这个由 STRIPE 提供的 Redirect-To-Checkout 功能,基本上我将用户重定向到这个 STRIPE 页面,其中所有卡数据(敏感信息)都在处理,以便完全支付。
What I do in my nodeJS server part is the following:我在我的 nodeJS 服务器部分中所做的如下:
I have to do this whole process because Stripe no longer gives me access to some information I require when the user is checking-out his order(such as observation that the user has based on the type of service he chooses).我必须完成整个过程,因为当用户检查他的订单时,Stripe 不再允许我访问我需要的一些信息(例如根据他选择的服务类型观察用户所拥有的信息)。
Are there any down-sides to this approach or is there any other way to do it?这种方法有什么缺点还是有其他方法可以做到?
Thanks in advance!提前致谢!
You're not really far from the best practices that Stripe recommends here .您与 Stripe 在此处推荐的最佳实践相距不远。 The only thing that I would change is listening to
checkout.session.completed
instead of the payment_intent.succeeded
event.我唯一要改变的是收听
checkout.session.completed
而不是payment_intent.succeeded
事件。 As of the latest API version , a PaymentIntent is no longer created upfront so a better to way to handle order fulfillment is to either store the Checkout Session ID (eg cs_live_xxx
) or you could add some metadata when creating the Checkout Session and use that instead to identify the order. As of the latest API version , a PaymentIntent is no longer created upfront so a better to way to handle order fulfillment is to either store the Checkout Session ID (eg
cs_live_xxx
) or you could add some metadata when creating the Checkout Session and use that instead来识别订单。
I have to do this whole process because Stripe no longer gives me access to some information I require when the user is checking-out his order
我必须完成整个过程,因为当用户检查他的订单时,Stripe 不再允许我访问我需要的一些信息
As for this, I'm not sure what you mean, you can always use your app with the success page customization described here alongside webhooks.至于这一点,我不确定您的意思,您始终可以将您的应用程序与 此处描述的成功页面自定义一起与 webhook 一起使用。 I wouldn't use that to fulfill the order though since the user might close the page before the redirection completes which means that the fulfillment wouldn't be done in that case.
我不会使用它来完成订单,因为用户可能会在重定向完成之前关闭页面,这意味着在这种情况下不会完成。 As such, webhooks are essential to order fulfillment.
因此,webhook 对于订单履行至关重要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.