简体   繁体   English

Paypal Express Checkout Curl实时失败,但在沙盒中工作

[英]Paypal Express Checkout Curl Failing on Live, but working in Sandbox

I'm stumped, because this was working, but now, all of a sudden, it does not work. 我很沮丧,因为这是行得通的,但是现在突然之间,它行不通了。

I use Paypal's Express Checkout and have the following code: 我使用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);

When I use the sandbox url it works fine, but on the live server I get this error: 当我使用沙盒网址时,它工作正常,但是在实时服务器上,我收到此错误:

cUrl error (#28): Operation timed out after 0 milliseconds with 0 out of 0 bytes received cUrl错误(#28):0毫秒后操作超时,收到0字节中的0字节

This has worked for a long time, I even received an order through it recently, but it doesn't work now! 这已经使用了很长时间,最近我什至收到了订单,但是现在不起作用!

Edit: My website has SSL, so setting curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 编辑:我的网站有SSL,所以设置curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); like we see in so many answers to questions like this, is not an option. 就像我们在对此类问题的众多答案中看到的那样,这不是一个选择。 That defeats the purpose of a secure checkout. 这违反了安全结帐的目的。 Besides, I've tried it in all my debugging, and does not work. 此外,我在所有调试中都尝试过,但是没有用。

Update: I set CURLOPT_VERBOSE to TRUE and got this: 更新:我将CURLOPT_VERBOSETRUE并得到了这个:

Hostname was found in DNS cache 在DNS缓存中找到主机名
Hostname in DNS cache was stale, zapped DNS缓存中的主机名已过时,已更改
Trying 173.0.84.69... 正在尝试173.0.84.69 ...
Connected to api-3t.paypal.com (173.0.84.69) port 443 (#0) 已连接到api-3t.paypal.com(173.0.84.69)端口443(#0)
successfully set certificate verify locations: 成功设置证书验证位置:
CAfile: /etc/pki/tls/certs/ca-bundle.crt CAfile:/etc/pki/tls/certs/ca-bundle.crt
CApath: none CApath:无
Operation timed out after 0 milliseconds with 0 out of 0 bytes received 0毫秒后操作超时,收到0个字节中的0个
Closing connection 0 关闭连接0

I contacted my host and asked them if anything had been changed recently that may have affected this. 我与房东联系并询问他们最近是否有任何更改可能影响了此情况。 They said: 他们说:

I think I know what caused this. 我想我知道是什么原因造成的。 We set the MTU to 1476 company wide to fix some issues. 我们将MTU设置为1476公司范围,以解决某些问题。 I changed it back to 1500. 我将其更改回1500。

Well, that didn't work. 好吧,那没有用。 So he changed it to 1400 and all of a sudden it works! 因此,他将其更改为1400,然后突然生效!

So the logical question for me was 所以对我来说,合理的问题是

Why would diminishing the MTU make it work? 为什么要减少MTU使其起作用?

Their answer: 他们的答案:

This is due to the new DDOS protection. 这是由于新的DDOS保护。 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不能为您解决此问题的原因。

So the escalated support agent says: 因此,升级的支持人员说:

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. 1476应该可以正常工作,我已经尝试从MTU设置为1476的系统连接到https://api-3t.paypal.com网站,它对我来说也很好。

Well, yes. 嗯,是。 It actually always worked for me from the command line. 实际上,它总是从命令行为我工作。

So he changed my site's MTU back to 1476 and surprise! 因此,他将我站点的MTU更改回1476,并感到惊讶! It works just fine. 它工作正常。

So, what was the real problem in the end? 那么,到底真正的问题是什么? I don't know. 我不知道。 As far as I know all settings are back to what they were when it was not working. 据我所知,所有设置都恢复到不工作时的状态。

I faced the same problem , and was hitting my head against the desk, and then read this post, so i contacted my hosting provider and this was their answer 我遇到了同样的问题,把头撞在桌子上,然后阅读了这篇文章,所以我联系了我的托管服务提供商,这就是他们的答案

Thank you for contacting our Technical Support Department. 感谢您与我们的技术支持部门联系。

We have recently changed our DDoS protection provider and have encountered such issues with curl queries. 我们最近更改了DDoS保护提供程序,并在curl查询中遇到了此类问题。

You should not receive the error anymore. 您不应该再收到该错误。

Please verify. 请验证。

And the paypal gateway started to work again. 贝宝网关再次开始工作。 So contact your hosting provider first. 因此,请首先与您的托管服务提供商联系。

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

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