簡體   English   中英

貝寶IPN使用“立即購買”按鈕返回“無效”,但已通過IPN Simulator驗證

[英]Paypal IPN returns INVALID with buy now button But VERIFIED with IPN Simulator

我被貝寶(Paypal)IPN困擾,當我使用貝寶(Paypal)立即購買按鈕時,它總是無效,但是它與IPN模擬器完美配合。

我知道在stackoverflow上有很多關於此的問題和答案可以幫助您,但是我從這里以及從其他站點嘗試了很多事情,但沒有一個起作用。

這是我正在使用的按鈕代碼,

<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&notify_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&notify_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搜索了stackoverflow和其他網站。

已經看過這些了,

Paypal SandBox IPN始終返回INVALID

PayPal IPN返回無效

我很確定這只是發布數據順序的問題。

來自https://github.com/orderly/codeigniter-paypal-ipn的使用代碼,它就像魅力一樣工作!

希望這個答案可以幫助某人並節省時間。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM