PayPal 订单 V2 未处理批准 url [英] PayPal Orders V2 not processing approve url
问题描述
根据 PayPal 订单 API
在此之后,我使用 rel = 批准复制 url.这个:https://www.sandbox.paypal.com/checkoutnow?token=3C454469W0667862G
现在,运行这个 url,这将打开沙箱 PayPal 页面.与买家登录后,点击支付,就在同一页面,没有任何错误.
知道为什么会这样吗?
'json' =>[意图"=>捕获",purchase_units"=>[[金额"=>[货币代码"=>美元",价值"=>100.00"]]]],
<块引用>
与买家登录后,点击支付,停留在同一页面,没有任何错误.
知道为什么会这样吗?
您尚未在创建正文中指定任何return_url应用上下文.它接下来无处重定向,因此它只是停留在同一页面上.
为了获得最佳用户体验,请勿使用任何重定向到批准网址或返回网址.而是不使用重定向.完全没有.
相反,配对 创建订单"和获取订单"的两个服务器端路由,审批流程如下:https://developer.paypal.com/demo/checkout/#/pattern/server
这让您的网站始终处于加载状态.
According to PayPal orders API as document here, We have to first create order then from the response, we have to copy the approve url and run in the browser. This will open PayPal page. There buyer will approve the request. After this a capture request should be made.
Issue details
I have following code that creates the order using PayPal API:
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', $uri, [
'json' => [
"intent" => "CAPTURE",
"purchase_units" => [
[
"amount" => [
"currency_code" => "USD",
"value" => "100.00"
]
]
]
],
'headers' => [
'Accept' => 'application/json',
'Accept-Language' => 'en_US',
'Content-Type' => 'application/json',
],
'auth' => [$clientId, $secret, 'basic']
]
);
$data = json_decode($response->getBody(), true);
echo "<pre>";
print_r($data);
echo "</pre>";
This code works fine. This gives me 4 urls as shown in the below screenshot.
After this, I copy the url with rel = approve. This one: https://www.sandbox.paypal.com/checkoutnow?token=3C454469W0667862G
Now, run this url, this will open the sandbox PayPal page. After login with buyer, and click pay, it stays on same page without any error.
Any idea why this is happening?
'json' => [
"intent" => "CAPTURE",
"purchase_units" => [
[
"amount" => [
"currency_code" => "USD",
"value" => "100.00"
]
]
]
],
After login with buyer, and click pay, it stays on same page without any error.
Any idea why this is happening?
You haven't specified any return_url in the create body's application_context. There is nowhere for it to redirect next, so it simply stays on the same page.
For the best user experience, do not use any redirects to an approval_url or return url. Instead use no redirects. At all.
Rather, pair your two server-side routes of 'Create an Order' and 'Capture Order' with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
This keeps your site loaded at all times.
这篇关于PayPal 订单 V2 未处理批准 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!