且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

未通过PHP中的paypal IPN验证或未经验证的响应

更新时间:2023-12-01 20:10:34

header = POST / cgi-bin / webscr HTTP / 1.1 \\\\ n; // HTTP POST请求


header。= Content-Type:application / x-www-form-urlencoded\r\ n;

header。= 主持人:www.sandbox.paypal.com\\\\ N跨度>;

I am using the following code to get response from paypal regarding payment:
 

    $header = "POST /cgi-bin/webscr HTTP/1.1\r\n"; // HTTP POST request
    $header.= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header.= "Host: www.sandbox.paypal.com\r\n";
    $header.= "Content-Length: " . strlen($req) . "\r\n";
    $header.= "Connection: Close\r\n\r\n";
    
    $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
    var_dump(fputs($fp, $header . $req));
    $res = stream_get_contents($fp, 1024); 	

The response that I am receiving in $res is:

    HTTP/1.1 200 OK
    
    Date: Thu, 29 Dec 2016 10:40:20 GMT
    
    Server: Apach
    X-Frame-Options: SAMEORIGIN
    
    Set-Cookie: c9MWDuvPtT9GIMyPc3jwol1VSlO=qjMaqOzpxaPLPcyXOYWKZ-NX5MRwtYFCSIrPVHYGfoTJaKNmNnuSbyrOiWKzKaWfLfeHiVTx-XDIcY1d2e6A3ZRai-nHOR80ofVToWBq0aejvYegkL0PLifF9nVYOxwPP-nvoxO0LgRbSmwyUCmm4NG7bTfashi4cLPmgKMkklGZNgINaNe9RtAsEDW2NJI59asn6R1yFLkcLEG9HKawDTBGwkNs-G3B03IlC-0w0GCiEvKTsPGo3xUDxWAa-crufhxSDnsJq0-8YXAaFbMIzyCOOcZKDT3tMo3-vn5mapjwRcdnN7BUCzJ3MbaDF0CNdKYO-b3cSU-0DGHiQo7tpUH_58JEvWLJVxHxfh4G2Oyz-bjcliyo9vzJ5JLdRV1pR-o2FdzfHjq8hriVraMaMbtS9-jzeaVdTuuyAKdYOi_XJXZH-6YDQcgYn0a; domain=.paypal.com; path=/; Secure; HttpOnly
    
    Set-Cookie: cookie_check=yes; expires=Sun, 27-Dec-2026 10:40:21 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
    
    Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/; Secure; HttpOnly
    
    Set-Cookie: navlns=0.0; expires=Sat, 29-Dec-2018 10:40:21 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
    
    Set-Cookie: Apache=10.72.108.11.1483008020869641; path=/; expires=Sat, 22-Dec-46 10:40:

As far as I understand I should get "VERIFIED" but I am unable to get that. Can anyone point out what the problem is?

What I have tried:

I changed my code according to an answer in *** regarding the same question. Initially when I was using below code, I wasn't getting anything in response, it was NULL:

    fputs($fp, $header . $req);
    while (!feof($fp)) {
                    $res = fgets ($fp, 1024); 
    }

header = "POST /cgi-bin/webscr HTTP/1.1\r\n"; // HTTP POST request


header.= "Content-Type: application/x-www-form-urlencoded\r\n";


header.= "Host: www.sandbox.paypal.com\r\n";