我用谷歌搜索了这个问题,并尝试了所有建议,但没有任何效果。
我尝试了以下代码:https : //developer.paypal.com/docs/classic/ipn/ht_ipn/,但是它不起作用。只需将其复制粘贴并删除旧的magick_quotes路由即可。
我尝试了以下代码:http : //samples.geekality.net/view-source.php?file=ipn/ipn_handler.class.php,它也无法正常工作。
在所有情况下,我都尝试执行以下操作:
$req = 'cmd=_notify-validate&' . file_get_contents('php://input');
为确保我向IPN发送的邮件与发送给我的邮件完全相同。另外,我使用了调试代理(Fiddler),并保存了IPN发送给我的内容以及我发送给IPN的内容。请求主体在字节之间是相同的,除了我的请求以cmd=_notify-validate&
字符串为前缀。
是的,我检查了我使用的沙箱网址是否正确。以下是整个请求正文:
IPN发送给我的信息:(我只是将个人数据替换为XXX)
POST http://localhost.loc/en/payment/success/1 HTTP/1.1
Host: localhost.loc
Connection: keep-alive
Content-Length: 921
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: null
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
mc_gross=1.00&protection_eligibility=Ineligible&payer_id=5XNKM66NSDKC4&tax=0.00&payment_date=05%3A34%3A11+Jun+01%2C+2015+PDT&payment_status=Completed&charset=utf-8&first_name=XXX&mc_fee=0.33¬ify_version=3.8&custom=topup%3A262262%3A1%3A1433162020&payer_status=verified&business=XXX&quantity=1&payer_email=XXX&verify_sign=AG58dBsn5g2z8O8NEjotbuJGP14PAIpZ4k26VL8IyhaDPkcDRj002Keq&memo=hmgvjgjhgfjhfggjhfjtfgjh&txn_id=4CN141026K278934Y&payment_type=instant&last_name=XXX&receiver_email=XXX&payment_fee=0.33&receiver_id=DCMXPXGX4QX6J&txn_type=web_accept&item_name=Account+top+up&mc_currency=USD&item_number=Account+262262+top+up&residence_country=US&test_ipn=1&handling_amount=0.00&transaction_subject=topup%3A262262%3A1%3A1433162020&payment_gross=1.00&shipping=0.00&auth=ANSTBwT3znll-gJQZO2cLoV5QJFW9v8W.FqyWxffdtI0L-9mfsoe2xRL44M86Sn2XtYGtcqG4Fjjel1kdYZyxpQ
我发送给IPN的内容:
POST https://www.sandbox.paypal.com/cgi-bin/webscr HTTP/1.1
Host: www.sandbox.paypal.com
Accept: */*
Content-Length: 942
Content-Type: application/x-www-form-urlencoded
cmd=_notify-validate&mc_gross=1.00&protection_eligibility=Ineligible&payer_id=5XNKM66NSDKC4&tax=0.00&payment_date=05%3A34%3A11+Jun+01%2C+2015+PDT&payment_status=Completed&charset=utf-8&first_name=XXX&mc_fee=0.33¬ify_version=3.8&custom=topup%3A262262%3A1%3A1433162020&payer_status=verified&business=XXX&quantity=1&payer_email=XXX&verify_sign=AG58dBsn5g2z8O8NEjotbuJGP14PAIpZ4k26VL8IyhaDPkcDRj002Keq&memo=hmgvjgjhgfjhfggjhfjtfgjh&txn_id=4CN141026K278934Y&payment_type=instant&last_name=XXX&receiver_email=XXX&payment_fee=0.33&receiver_id=DCMXPXGX4QX6J&txn_type=web_accept&item_name=Account+top+up&mc_currency=USD&item_number=Account+262262+top+up&residence_country=US&test_ipn=1&handling_amount=0.00&transaction_subject=topup%3A262262%3A1%3A1433162020&payment_gross=1.00&shipping=0.00&auth=ANSTBwT3znll-gJQZO2cLoV5QJFW9v8W.FqyWxffdtI0L-9mfsoe2xRL44M86Sn2XtYGtcqG4Fjjel1kdYZyxpQ
谁能帮我我做错了什么?谢谢。
AARRRRGH !!!!!!!! 我对贝宝只有脏话!!!!!!! 问题出在……(鼓……塔达姆!)在charset
野外!不,它的值必须与IPN发送给您的值相同,但是...大写!IPN以小写形式发送它!因此,无论手册告诉我们“按原样”返回数据,您都必须修改IPN数据以成功验证它。PayPal错误?
所以我的最终工作代码是:(使用HTTP_Request2)
protected function verifyPostData() {
$this->request->setBody('cmd=_notify-validate&' . str_replace('=utf-8', '=UTF-8', file_get_contents('php://input')));
$response = $this->request->send();
if ($response->getStatus() != 200) {
throw new \RuntimeException("Transaction data verification request failed with code {$response->getStatus()}");
}
$content = trim($response->getBody());
return ($content == 'VERIFIED');
}
我是如何做到的:我发送了此交易的PDT请求并获得了交易数据。然后,我对PDT和IPN数据进行了字段到字段的比较。PDT有没有一些IPN领域,如auth
,verify_sign
和test_ipn
。但是所有其他字段似乎必须相同。唯一的区别在于该charset
字段的字符情况。然后,我尝试验证修改后的数据,但意外地成功了!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句