Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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 stackoverflow 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); 
    }
Posted
Updated 9-Jan-17 10:27am
v2

1 solution

I would recommend you contact PayPal to find out what is happening.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900