简体   繁体   English

Google Pay 集成:在触发 Google Pay 弹出窗口之前创建订单

[英]Google Pay Integration: Create order before Google Pay pop up gets triggered

I'm currently implementing the Google Pay Checkout for my website and have a problem with the flow.我目前正在为我的网站实施 Google Pay Checkout,但遇到流程问题。 When the button is clicked the popup shows up immediately after but I want to first create an order on backend because I need to have a validation for the order.单击按钮后,弹出窗口会立即显示,但我想先在后端创建一个订单,因为我需要对订单进行验证。 On apple pay this is possible and I can close the apple payment-sheet if the order has a validation error.在苹果支付上这是可能的,如果订单有验证错误,我可以关闭苹果支付表。 On google I wanted to asynchronosly call backend for validation and afterwards fire the popup.在谷歌上,我想异步调用后端进行验证,然后触发弹出窗口。 That's not successful because the click event needs to fire the popup right away.这不成功,因为点击事件需要立即触发弹出窗口。 Do you know a way how to make the backend call and on success fire the popup?您知道如何进行后端调用并成功触发弹出窗口的方法吗?

You can do it on onClick event of onGooglePaymentButtonClicked function. In onGooglePaymentButtonClicked function, you can call your backend API for creating an order first and after a successful response call loadPaymentData for payment sheet.您可以在 onGooglePaymentButtonClicked function 的 onClick 事件上执行此操作。在 onGooglePaymentButtonClicked function 中,您可以先调用后端 API 创建订单,然后在成功响应后调用 loadPaymentData 以获取付款表。 You can use promises with callback then/catch to open payment sheet.您可以使用带有回调 then/catch 的承诺来打开付款表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM