3

我试图让 Paypal 在交易后重定向到我的网站并检索有关交易的信息。到目前为止,Paypal 确实重定向到了正确的位置,但是我之后返回到 Paypal 的 php curl 操作检索到一个错误页面,而不是我期待的 SUCCESS/FAIL 消息:

抱歉 - 您的最后一个操作无法完成

[...]

我们目前无法完成您的请求。请单击重试或稍后重试。我们对不便表示抱歉。

消息 3004

我试过让我的代码在屏幕上打印'tx'参数,手动构建我的请求并将其直接放在浏览器中,即:

https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-synch&tx=34A96012RS258972T&at=x7cYS4yOvBi2k_LuLWsJ3h_J-2n-29VCgzhFDR79on8s1mQSlSxIIIibiW3e

但是返回了上述相同的错误页面。

我已登录到我的沙盒 paypal 帐户,并且“at”参数包含与我的沙盒商家测试帐户关联的正确支付数据传输身份令牌。

我的请求是否缺少任何内容?我没有用我的实际 Paypal 帐户对其进行测试,因为在我知道它有效之前我不想要任何真实的货币兑换。

4

2 回答 2

2

同样的错误 - 两周前注意到 - 已与贝宝联系,后者告诉我检查我的代码 - 但即使复制和粘贴代码示例仍然会产生错误。登录测试卖家账号,能看到交易吗?我可以但再次单击详细信息视图会生成错误。

我能够通过此帐户通过 PDT,但随后它突然开始失败,而我的代码没有任何更改。

2012 年 7 月 31 日更新:Paypal 仍未确认解决方案 - 与商家电话支持而不是技术团队交谈,因为他们显然没有电话技术支持 - 商家建议基本上告诉他们进行现场测试并避免沙盒。每次测试至少 20 便士,因为您必须退还您的测试交易。

我可以告诉你不是一个很快乐的人。:(

于 2012-07-24T09:44:46.067 回答
1
$tx=$_REQUEST['tx'];

$paypal_url='https://www.paypal.com/cgi-bin/webscr?cmd=_notify-synch&tx='.$tx.'&at=token here';

$curl = curl_init($paypal_url);

$data = array(

"cmd" => "_notify-synch",

"tx" => $tx,

"at" => "token here"


);                                                                    

$data_string = json_encode($data); 

curl_setopt ($curl, CURLOPT_HEADER, 0);

curl_setopt ($curl, CURLOPT_POST, 1);

curl_setopt ($curl, CURLOPT_POSTFIELDS, $data_string);

curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 1);

$headers = array (

'Content-Type: application/x-www-form-urlencoded',

'Host: www.paypal.com',

'Connection: close'

);

curl_setopt ($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

curl_setopt ($curl, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($curl);

$lines = explode("\n", $response);

$keyarray = array();

if (strcmp ($lines[0], "SUCCESS") == 0) {

for ($i=1; $i<count($lines);$i++){

list($key,$val) = explode("=", $lines[$i]);

$keyarray[urldecode($key)] = urldecode($val);

}


$first_name=$keyarray['first_name'];

$last_name=$keyarray['last_name'];

$payment_status=$keyarray['payment_status'];

$business=$keyarray['business'];

$payer_email=$keyarray['payer_email'];

$payment_gross=$keyarray['payment_gross'];

$mc_currency=$keyarray['mc_currency']; 

}
于 2013-07-02T12:58:31.583 回答