脚本宝典收集整理的这篇文章主要介绍了php – PayPal沙箱IPN验证始终返回INVALID,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我试过这个代码: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
谁能帮助我,我做错了什么?
谢谢.
所以我的最终工作代码是:(使用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字段的字符大小写.然后我尝试验证已修改的数据,并意外地成功!
以上是脚本宝典为你收集整理的php – PayPal沙箱IPN验证始终返回INVALID全部内容,希望文章能够帮你解决php – PayPal沙箱IPN验证始终返回INVALID所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。