gpt4 book ai didi

php - Paypal 集成 HTTP 错误

转载 作者:太空宇宙 更新时间:2023-11-03 16:08:39 24 4
gpt4 key购买 nike

我的网站上集成了 PayPal。我的网站上有一个表格,将客户带到 PayPal 以完成付款,然后将他们返回到我的网站。然后,我的网站将带有 PDT 交易 token 的请求发送回 PayPal,这样我就可以进行一些检查,然后自动将客户购买的产品记入贷方。

系统使用 PHP 和 cURL 发送处理这一切。

当我使用:"www.sandbox.paypal.com/cgi-bin/webscr"

连同沙箱凭据,一切正常,一切正常。

一旦我将其全部更改为 "www.paypal.com/cgi-bin/webscr"

它不起作用,我的代码告诉我请求失败。我的代码:

$pp_hostname = "www.paypal.com";

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';

$tx_token = $_GET['tx'];
$auth_token = "#######-hashed_out_here-########";
$req .= "&tx=$tx_token&at=$auth_token";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://$pp_hostname/cgi-bin/webscr");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
//set cacert.pem verisign certificate path in curl using 'CURLOPT_CAINFO' field here,
//if your server does not bundled with default verisign certificates.
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: $pp_hostname"));
$res = curl_exec($ch);
curl_close($ch);
if(!$res){
$this->twig->error("Request failed.");
}else{
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i='1'; $i<count($lines);$i++){
$test = explode("=", $lines[$i]);
if(empty($test[1])){
$keyarray[urldecode($test[0])] = '';
}else{
$keyarray[urldecode($test[0])] = urldecode($test[1]);
}
}
//give product
} else if (strcmp ($lines[0], "FAIL") == 0) {
$this->twig->error('Transaction failed!');
}
}

不确定我为什么会遇到问题,所以我不知道如何解决。我的 PayPal 账户设置为企业账户,开启了 PDT 和 IPN 以及自动返回

我似乎收到了 HTTP 错误,但我不能说,如果我记录 curl_error,它只会显示“”,如果我记录 curl_errno,我会得到 0。

最佳答案

我设法解决了这个问题。这是因为我的服务器没有安装 ssl 证书,一旦我这样做就可以正常工作。

关于php - Paypal 集成 HTTP 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28827060/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com