【发布时间】:2021-01-31 16:19:27
【问题描述】:
我正在寻找使用 PHP 进行 PayPal 付款的方法。我了解有已弃用的 API 和当前的 API。所以我找到了几种方法。但是很多文件把我带进了迷宫。我很困惑。客户端按钮渲染,如何调用我们的 PHP 脚本/什么是 PayPal-Request-Id 并获取它/我们可以用 webscr ==> cmd=_express-checkout&token=EC-7BA65327KY8480517 等的令牌做什么。
我尝试在我的页面上使用一个按钮来使用 html 表单提交一些 paypal 所需的参数。接收的php文件根据需要形成支付记录,然后创建订单。我得到了订单 ID,但它是做什么用的?所以我设置了一个新参数,符合 PayPal 创建付款的需要。这给了我 4 个链接,我选择重定向一个以供客户端登录并继续。有了这个,我进入了登陆页面,然后我执行了付款,但沙盒仪表板上的每笔付款都显示为待处理。
然后我很困惑如何完成付款。这里有我的泰铢数据
{"id":"PAYID-MAKU2OI7RR56034B9692111L","intent":"sale","state":"created","payer":{"payment_method":"paypal"},"transactions":[{"amount":{"total":"1126.15","currency":"THB","details":{"subtotal":"979.26","tax":"146.89","shipping":"0.00","insurance":"0.00","handling_fee":"0.00","shipping_discount":"0.00"}},"description":"aonang to","custom":"0","invoice_number":"kbv.starlight_12","soft_descriptor":"MFWD","payment_options":{"allowed_payment_method":"INSTANT_FUNDING_SOURCE","recurring_flag":false,"skip_fmf":false},"item_list":{"items":[{"name":"MFWD","sku":"kbv.starlight_12","description":"aonang to ","price":"979.26","currency":"THB","tax":"146.89","quantity":1}]},"related_resources":[]}],"note_to_payer":"Contact us for any questions on your order.","create_time":"2021-01-30T12:12:40Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-MAKU2OI7RR56034B9692111L","rel":"self","method":"GET"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-1G552540DR9655320","rel":"approval_url","method":"REDIRECT"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-MAKU2OI7RR56034B9692111L/execute","rel":"execute","method":"POST"}]}
【问题讨论】:
-
var EXECUTE_URL = '/example/executePayment'; /* 设置你需要传递给你的服务器的数据 / / 调用你的服务器来执行支付 */ return fetch('/my-server/capture-paypal-transaction', { 正文:JSON.stringify({
标签: paypal paypal-sandbox