Paypal 集成,如何使用 createOrder onApprove?

Paypal integration, how to use createOrder onApprove?

贝宝文档在这里: https://developer.paypal.com/docs/business/checkout/set-up-standard-payments/

表示

Within createOrder and onApprove, call your server-side using the Fetch API to retrieve a token or capture a payment. Within createOrder, return the Order ID (or EC token) generated from your server-side code.

是否有任何示例说明如何执行此操作?

谢谢

是的,他们是 documented here。这些路由应该 return 只有 JSON 数据(没有 HTML 或文本)。后者应该(成功时)在执行 return(特别是 purchase_units[0].payments.captures[0].id、PayPal 交易 ID)

之前将付款详细信息存储在您的数据库中

将这两条路线与以下批准流程配对:https://developer.paypal.com/demo/checkout/#/pattern/server