2010-12-01 108 views
1

我試圖用CURL設置我的PayPal IPN監聽器。我剛收到來自PayPal的POST數據,但我在發回我的回覆時卡住了。PayPal IPN監聽器 - 發送響應w/CURL

這是一個測試,我試圖發回貝寶,尋找預期的「VERIFIED」或「INVALID」響應。

$string = 'cmd=_notify-validate&test_ipn=1&payment_type=instant&payment_date=13%3A49%3A46+Dec+01%2C+2010+PST&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer%40paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John+Smith&address_country=United+States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San+Jose&address_street=123%2C+any+street&business=seller%40paypalsandbox.com&receiver_email=seller%40paypalsandbox.com&receiver_id=TESTSELLERID1&residence_country=US&item_name=something&item_number=AK-1234&quantity=1&shipping=3.04&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=9.34&txn_type=web_accept&txn_id=461212149&notify_version=2.1&custom=xyz123&charset=windows-1252&verify_sign=AHaXyf3zaDTb0y4MveMg3L5zjpqNAElZcXU6rvpq5jsGR30FGG6OehkN'; 

    $endpoint = 'https://www.sandbox.paypal.com/'; 

    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $endpoint); 
    curl_setopt($ch, CURLOPT_HEADER, TRUE); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch, CURLOPT_POST, TRUE); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $string); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 30); 
    $result = curl_exec($ch); 
    curl_close($ch); 

    echo $result; 

我正在使用沙盒IPN測試模擬器向我的偵聽器發送IPN信號。我正在將我的回覆發送給https://www.sandbox.paypal.com/

我從貝寶這種反應,不管我發送給它什麼樣的數據:

HTTP/1.1 301 Moved Permanently 
Date: Wed, 01 Dec 2010 23:34:30 GMT 
Server: Apache 
Set-Cookie: c9MWDuvPtT9GIMyPc3jwol1VSlO=%7cPwtfdnvWZ1WVsa34w2F4FnUT4lXZCFSynqbMXEb4n-DLVEWN-dbmDX86YMRj6lgQyDfDGW%7cgeDqSysrRWP1DZZKq9pFf2j5ZBlu0nORtDS4-uXC_YGN8BtbwSBf1d6vq-77_078ySZeRG%7c; domain=.paypal.com; path=/ 
Set-Cookie: -1ILhdyICORs4hS4xTUr41S8iP0=cH14qDWDhwMs_KbBH2sE-6AG-wKvoQqYPWtsICHmeL1gU49_4McpLl14aXD3KVyvQsmhfiPzKd-Ekiwm; expires=Tue, 26-Nov-2030 23:34:31 GMT; domain=.paypal.com; path=/ 
Set-Cookie: cookie_check=yes; expires=Sat, 28-Nov-2020 23:34:31 GMT; domain=.paypal.com; path=/ 
Set-Cookie: Apache=10.191.196.11.135781291246470532; path=/; expires=Tue, 18-Oct-04 17:06:14 GMT 
Location: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_home&country_lang.x=true 
Cneonction: close 
Transfer-Encoding: chunked 
Content-Type: text/plain; charset=ISO-8859-1 

這讓我覺得我只是普通的張貼到了錯誤的網址,但是這是我應該的網址使用。貝寶

+0

你爲什麼關掉了SSL主機驗證? – s3v3n 2012-11-11 18:55:30

回答

0

沙盒網址是:

https://www.sandbox.paypal.com/cgi-bin/webscr 
+0

雅,我以爲我也嘗試過這個URL,它不起作用 - 這次它做到了。謝謝。 – swt83 2010-12-02 02:02:15