簡體   English   中英

PayPal沙箱IPN驗證始終返回INVALID

[英]PayPal sandbox IPN validation always return 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& string為前綴。

是的,我檢查過我使用了正確的沙盒網址。 以下是整個請求主體:

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&notify_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&notify_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 !!!!!!!! PayPal我只有臟話!!!!!!! 問題出現在charset領域的......(鼓聲...... tadam!)! 不,它的價值必須與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字段,例如authverify_signtest_ipn 但所有其他領域似乎必須相同。 唯一的區別在於charset字段的字符大小寫。 然后我嘗試驗證已修改的數據,並意外地成功!

這是最近的PayPal錯誤,當客戶完成付款並點擊“點擊此處返回..”而不是等待幾秒鍾時,傳遞到您網站上的PDT腳本的參數將以小寫形式發送。

這也會使區分大小寫或編碼的cm / custom參數變得混亂。

顯然PayPal意識到了這一點。

暫無
暫無

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

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