PHP Curl return FAIL from Live Paypal PDT URL

MariaMiArt
Contributor
Contributor

Hello, I have a code for postback that returns me FAIL on live URL, but it works fine in sandbox. What I need to do to get it working? Thank you!

 

            curl_setopt_array($request, array
            (
                CURLOPT_URL => 'https://www.paypal.com/cgi-bin/webscr',
                CURLOPT_POST => TRUE,
                CURLOPT_TIMEOUT => 10,
                CURLOPT_CONNECTTIMEOUT => 10,
                CURLOPT_POSTFIELDS => http_build_query(array
                (
                    'cmd' => '_notify-synch',
                    'tx' => $GET['tx'],
                    'at' => 'my_token_here',
                )),
                CURLOPT_RETURNTRANSFER => TRUE,
                CURLOPT_HEADER => FALSE
            ));
Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

MariaMiArt
Contributor
Contributor

After 16 hours of searching I found the solution here - https://github.com/apih/paypal-ipn-pdt

Here is the code:

        $query_data = [
            'cmd' => '_notify-synch',
            'tx' => $GET['tx'],
            'at' => $this->token
        ];
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_USERAGENT, 'PayPal');
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($query_data));
        curl_setopt($ch, CURLOPT_URL, $this->url);
        $response = curl_exec($ch);
        $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);

View solution in original post

Login to Me Too
1 REPLY 1
Solved

MariaMiArt
Contributor
Contributor

After 16 hours of searching I found the solution here - https://github.com/apih/paypal-ipn-pdt

Here is the code:

        $query_data = [
            'cmd' => '_notify-synch',
            'tx' => $GET['tx'],
            'at' => $this->token
        ];
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_USERAGENT, 'PayPal');
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($query_data));
        curl_setopt($ch, CURLOPT_URL, $this->url);
        $response = curl_exec($ch);
        $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.