Paypal Express Checkout Curl 在线失败,但在沙盒中工作
Paypal Express Checkout Curl Failing on Live, but working in Sandbox
我很难过,因为这是有效的,但现在,突然间,它不起作用了。
我使用 Paypal 的 Express Checkout 并使用以下代码:
$post = array(
'USER'=>$username,
'PWD'=>$password,
'SIGNATURE'=>$signature,
'METHOD'=>'SetExpressCheckout',
'VERSION'=>'119',
[... All the other info to be sent to Paypal...]
);
$post = http_build_query($post);
$live_curl = "https://api-3t.paypal.com/nvp";
$sandbox_curl = "https://api-3t.sandbox.paypal.com/nvp";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $live_curl);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 3); // 3 seconds to connect
curl_setopt ($ch, CURLOPT_TIMEOUT, 10); // 10 seconds to complete
$output = curl_exec($ch);
curl_close($ch);
当我使用沙箱 url 时它工作正常,但在实时服务器上我收到此错误:
cUrl error (#28): Operation timed out after 0 milliseconds with 0 out of 0 bytes received
这个用了好久了,我最近还通过它下单,现在不行了!
编辑: 我的网站有 SSL,所以设置 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
就像我们在很多类似问题的答案中看到的那样,不是一种选择。这违背了安全结帐的目的。此外,我在所有调试中都尝试过它,但没有用。
更新: 我将 CURLOPT_VERBOSE
设置为 TRUE
并得到了这个:
Hostname was found in DNS cache
Hostname in DNS cache was stale, zapped
Trying 173.0.84.69...
Connected to api-3t.paypal.com (173.0.84.69) port 443 (#0)
successfully set certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
Operation timed out after 0 milliseconds with 0 out of 0 bytes received
Closing connection 0
我联系了我的房东并询问他们最近是否有任何可能影响此情况的更改。他们说:
I think I know what caused this. We set the MTU to 1476 company wide
to fix some issues. I changed it back to 1500.
好吧,那没用。所以他把它改成1400,突然就可以用了!
所以对我来说合乎逻辑的问题是
Why would diminishing the MTU make it work?
他们的回答:
This is due to the new DDOS protection. I would like to escalate this ticket and have it investigated further so we can narrow down why the reduction to 1476 did not resolve this issue for you.
所以升级支持代理说:
1476 should work just fine and I've tried to connect to the
https://api-3t.paypal.com site from a system with MTU set to 1476 and
it worked just fine for me.
嗯,是的。它实际上总是从命令行为我工作。
所以他把我网站的 MTU 改回了 1476,惊喜!
效果很好。
那么,到底是什么问题呢?我不知道。
据我所知,所有设置都恢复到不工作时的状态。
我遇到了同样的问题,我的头撞在桌子上,然后读了这个 post,所以我联系了我的托管服务提供商,这是他们的答案
Thank you for contacting our Technical Support Department.
We have recently changed our DDoS protection provider and have
encountered such issues with curl queries.
You should not receive the error anymore.
Please verify.
paypal 网关又开始工作了。因此,请先联系您的托管服务提供商。
我很难过,因为这是有效的,但现在,突然间,它不起作用了。
我使用 Paypal 的 Express Checkout 并使用以下代码:
$post = array(
'USER'=>$username,
'PWD'=>$password,
'SIGNATURE'=>$signature,
'METHOD'=>'SetExpressCheckout',
'VERSION'=>'119',
[... All the other info to be sent to Paypal...]
);
$post = http_build_query($post);
$live_curl = "https://api-3t.paypal.com/nvp";
$sandbox_curl = "https://api-3t.sandbox.paypal.com/nvp";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $live_curl);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 3); // 3 seconds to connect
curl_setopt ($ch, CURLOPT_TIMEOUT, 10); // 10 seconds to complete
$output = curl_exec($ch);
curl_close($ch);
当我使用沙箱 url 时它工作正常,但在实时服务器上我收到此错误:
cUrl error (#28): Operation timed out after 0 milliseconds with 0 out of 0 bytes received
这个用了好久了,我最近还通过它下单,现在不行了!
编辑: 我的网站有 SSL,所以设置 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
就像我们在很多类似问题的答案中看到的那样,不是一种选择。这违背了安全结帐的目的。此外,我在所有调试中都尝试过它,但没有用。
更新: 我将 CURLOPT_VERBOSE
设置为 TRUE
并得到了这个:
Hostname was found in DNS cache
Hostname in DNS cache was stale, zapped
Trying 173.0.84.69...
Connected to api-3t.paypal.com (173.0.84.69) port 443 (#0)
successfully set certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
Operation timed out after 0 milliseconds with 0 out of 0 bytes received
Closing connection 0
我联系了我的房东并询问他们最近是否有任何可能影响此情况的更改。他们说:
I think I know what caused this. We set the MTU to 1476 company wide to fix some issues. I changed it back to 1500.
好吧,那没用。所以他把它改成1400,突然就可以用了!
所以对我来说合乎逻辑的问题是
Why would diminishing the MTU make it work?
他们的回答:
This is due to the new DDOS protection. I would like to escalate this ticket and have it investigated further so we can narrow down why the reduction to 1476 did not resolve this issue for you.
所以升级支持代理说:
1476 should work just fine and I've tried to connect to the https://api-3t.paypal.com site from a system with MTU set to 1476 and it worked just fine for me.
嗯,是的。它实际上总是从命令行为我工作。
所以他把我网站的 MTU 改回了 1476,惊喜! 效果很好。
那么,到底是什么问题呢?我不知道。 据我所知,所有设置都恢复到不工作时的状态。
我遇到了同样的问题,我的头撞在桌子上,然后读了这个 post,所以我联系了我的托管服务提供商,这是他们的答案
Thank you for contacting our Technical Support Department.
We have recently changed our DDoS protection provider and have encountered such issues with curl queries.
You should not receive the error anymore.
Please verify.
paypal 网关又开始工作了。因此,请先联系您的托管服务提供商。