Paypal IPN returns 立即购买按钮无效但已通过 IPN 模拟器验证
Paypal IPN returns INVALID with buy now button But VERIFIED with IPN Simulator
我被 paypal IPN 的问题困住了,当我使用 paypal 立即购买按钮时它总是无效,但是它与 IPN 模拟器完美配合。
我知道在 Whosebug 上有很多关于此的问题和答案可以提供帮助,但我已经从这里和其他网站尝试了很多东西,none 其中有效。
这是我正在使用的按钮代码,
<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick"><input type="hidden" name="business" value="xxx-facilitator@gmail.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="Teddy Bear">
<input type="hidden" name="amount" value="12.99">
<input type="hidden" name="notify_url" value="http://mysite/ipn">
<input type="hidden" name="custom" value="2">
<input type="hidden" name="return" value="http://mysite/success">
<input type="hidden" name="cancel_return" value="http://mysite/cancel">
<input type="image" src="http://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
这是 IPN 侦听器代码,
<?php
$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$postFields = 'cmd=_notify-validate';
foreach($_POST as $key => $value){
$value = urlencode(stripslashes($value));
$postFields .= "&$key=".$value;
}
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postFields
));
$result = curl_exec($ch);
curl_close($ch);
if($result == "VERIFIED"){
$handle = fopen('ipn.txt','w');
fwrite($handle,$result.'----'.$postFields);
fclose($handle);
}else{
$handle = fopen('ipn.txt','w');
fwrite($handle,$result.'----'.$postFields);
fclose($handle);
}
这是我从模拟器保存到 ipn.txt 的响应,
VERIFIED----cmd=_notify-validate&residence_country=US&invoice=abc1234&address_city=San+Jose&first_name=John&payer_id=TESTBUYERID01&shipping=3.04&mc_fee=0.44&txn_id=332239535&receiver_email=seller%40paypalsandbox.com&quantity=1&custom=xyz123&payment_date=17%3A48%3A59+9+Feb+2015+PST&address_country_code=US&address_zip=95131&tax=2.02&item_name=something&address_name=John+Smith&last_name=Smith&receiver_id=seller%40paypalsandbox.com&item_number=AK-1234&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31Aryx.id7DMD.5oDzhJYQOgjfGK2z&address_country=United+States&payment_status=Completed&address_status=confirmed&business=seller%40paypalsandbox.com&payer_email=buyer%40paypalsandbox.com¬ify_version=2.1&txn_type=web_accept&test_ipn=1&payer_status=verified&mc_currency=USD&mc_gross=12.34&address_state=CA&mc_gross1=9.34&payment_type=instant&address_street=123%2C+any+street
最后是通过按下按钮并在通过 paypal 沙盒帐户付款后的响应文本。
INVALID----cmd=_notify-validate&mc_gross=12.99&protection_eligibility=Eligible&address_status=unconfirmed&payer_id=K95EGBDGNUN8S&tax=0.00&address_street=Flat+no.+507+Wing+A+Raheja+Residency%0AFilm+City+Road%2C+Goregaon+East&payment_date=17%3A53%3A25+Feb+09%2C+2015+PST&payment_status=Completed&charset=UTF-8&address_zip=400097&first_name=Test&mc_fee=0.81&address_country_code=IN&address_name=Test+Buyer¬ify_version=3.8&custom=46&payer_status=verified&business=xxx-facilitator%40gmail.com&address_country=India&address_city=Mumbai&quantity=1&verify_sign=AlLjZyUxzvtq5pK4-AOSkTM98NV-AIiAPCkBL.N4R.UZINnl-aty.OZT&payer_email=xxx-buyer%40gmail.com&txn_id=4LG750650N267953C&payment_type=instant&last_name=Buyer&address_state=Maharashtra&receiver_email=xxx-facilitator%40gmail.com&payment_fee=0.81&receiver_id=HYW9VPL8HWUYA&txn_type=web_accept&item_name=Teddy+Bear&mc_currency=USD&item_number=&residence_country=IN&test_ipn=1&handling_amount=0.00&transaction_subject=46&payment_gross=12.99&shipping=0.00&ipn_track_id=a7a2c1d3e08a2
到目前为止我做了什么,
确保我只使用沙盒而不是使用 paypal 的实时事物
更改了两个帐户的字符集(沙盒中的买方和卖方)
多次更改侦听器代码,但得到相同的结果
用 google 搜索了 Whosebug 和其他网站,但没有成功。
已经看过这些了,
Paypal SandBox IPN always returns INVALID
PayPal IPN returning INVALID
我很确定这只是 post 数据顺序的问题。
使用了 https://github.com/orderly/codeigniter-paypal-ipn 中的代码,效果非常好!
希望这个回答能帮助到别人并节省时间。
我被 paypal IPN 的问题困住了,当我使用 paypal 立即购买按钮时它总是无效,但是它与 IPN 模拟器完美配合。
我知道在 Whosebug 上有很多关于此的问题和答案可以提供帮助,但我已经从这里和其他网站尝试了很多东西,none 其中有效。
这是我正在使用的按钮代码,
<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick"><input type="hidden" name="business" value="xxx-facilitator@gmail.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="Teddy Bear">
<input type="hidden" name="amount" value="12.99">
<input type="hidden" name="notify_url" value="http://mysite/ipn">
<input type="hidden" name="custom" value="2">
<input type="hidden" name="return" value="http://mysite/success">
<input type="hidden" name="cancel_return" value="http://mysite/cancel">
<input type="image" src="http://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
这是 IPN 侦听器代码,
<?php
$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$postFields = 'cmd=_notify-validate';
foreach($_POST as $key => $value){
$value = urlencode(stripslashes($value));
$postFields .= "&$key=".$value;
}
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postFields
));
$result = curl_exec($ch);
curl_close($ch);
if($result == "VERIFIED"){
$handle = fopen('ipn.txt','w');
fwrite($handle,$result.'----'.$postFields);
fclose($handle);
}else{
$handle = fopen('ipn.txt','w');
fwrite($handle,$result.'----'.$postFields);
fclose($handle);
}
这是我从模拟器保存到 ipn.txt 的响应,
VERIFIED----cmd=_notify-validate&residence_country=US&invoice=abc1234&address_city=San+Jose&first_name=John&payer_id=TESTBUYERID01&shipping=3.04&mc_fee=0.44&txn_id=332239535&receiver_email=seller%40paypalsandbox.com&quantity=1&custom=xyz123&payment_date=17%3A48%3A59+9+Feb+2015+PST&address_country_code=US&address_zip=95131&tax=2.02&item_name=something&address_name=John+Smith&last_name=Smith&receiver_id=seller%40paypalsandbox.com&item_number=AK-1234&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31Aryx.id7DMD.5oDzhJYQOgjfGK2z&address_country=United+States&payment_status=Completed&address_status=confirmed&business=seller%40paypalsandbox.com&payer_email=buyer%40paypalsandbox.com¬ify_version=2.1&txn_type=web_accept&test_ipn=1&payer_status=verified&mc_currency=USD&mc_gross=12.34&address_state=CA&mc_gross1=9.34&payment_type=instant&address_street=123%2C+any+street
最后是通过按下按钮并在通过 paypal 沙盒帐户付款后的响应文本。
INVALID----cmd=_notify-validate&mc_gross=12.99&protection_eligibility=Eligible&address_status=unconfirmed&payer_id=K95EGBDGNUN8S&tax=0.00&address_street=Flat+no.+507+Wing+A+Raheja+Residency%0AFilm+City+Road%2C+Goregaon+East&payment_date=17%3A53%3A25+Feb+09%2C+2015+PST&payment_status=Completed&charset=UTF-8&address_zip=400097&first_name=Test&mc_fee=0.81&address_country_code=IN&address_name=Test+Buyer¬ify_version=3.8&custom=46&payer_status=verified&business=xxx-facilitator%40gmail.com&address_country=India&address_city=Mumbai&quantity=1&verify_sign=AlLjZyUxzvtq5pK4-AOSkTM98NV-AIiAPCkBL.N4R.UZINnl-aty.OZT&payer_email=xxx-buyer%40gmail.com&txn_id=4LG750650N267953C&payment_type=instant&last_name=Buyer&address_state=Maharashtra&receiver_email=xxx-facilitator%40gmail.com&payment_fee=0.81&receiver_id=HYW9VPL8HWUYA&txn_type=web_accept&item_name=Teddy+Bear&mc_currency=USD&item_number=&residence_country=IN&test_ipn=1&handling_amount=0.00&transaction_subject=46&payment_gross=12.99&shipping=0.00&ipn_track_id=a7a2c1d3e08a2
到目前为止我做了什么,
确保我只使用沙盒而不是使用 paypal 的实时事物
更改了两个帐户的字符集(沙盒中的买方和卖方)
多次更改侦听器代码,但得到相同的结果
用 google 搜索了 Whosebug 和其他网站,但没有成功。
已经看过这些了,
Paypal SandBox IPN always returns INVALID
PayPal IPN returning INVALID
我很确定这只是 post 数据顺序的问题。
使用了 https://github.com/orderly/codeigniter-paypal-ipn 中的代码,效果非常好!
希望这个回答能帮助到别人并节省时间。