PayPal ipnNotificationUrl Turned off and not sending notifications to URL

326 views Asked by At

I'm working with paypal adaptive payments API and all things were okay till last month.

The problem is ipnNotificationUrl is not sending any notifications to URL i provided in code.

Here is the code of PayPal adaptive payment,

<?php

class Paypal{



    private $api_user;

    private $api_pass;

    private $api_sig;

    private $app_id;

    private $apiUrl = 'https://svcs.sandbox.paypal.com/AdaptivePayments/';

    private $paypalUrl="https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=";

    private $headers;



    public function setDetails($api_u, $api_p, $api_s, $api_id){



        $this->api_user = $api_u;

        $this->api_pass = $api_p;

        $this->api_sig = $api_s;

        $this->app_id = $api_id;



        $this->headers = array(

            "X-PAYPAL-SECURITY-USERID: ".$this->api_user,

            "X-PAYPAL-SECURITY-PASSWORD: ".$this->api_pass,

            "X-PAYPAL-SECURITY-SIGNATURE: ".$this->api_sig,

            "X-PAYPAL-REQUEST-DATA-FORMAT: JSON",

            "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON",

            "X-PAYPAL-APPLICATION-ID: ".$this->app_id,

        );



    }



    public function getPaymentOptions($paykey){

        $pack = array(

            "requestEnvelope" => array(

                "errorLanguage" => "en_US",

                "detailLevel" => "ReturnAll",

            ),

            "payKey" => $paykey

        );

        return $this->_paypalSend($pack, "GetPaymentOptions");

    }



    public function setPaymentOptions(){



    }



    public function _paypalSend($data,$call){

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $this->apiUrl.$call);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

        curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);

        $response = json_decode(curl_exec($ch),true);

        return $response;



    }

    public function splitPay($currency, $r1_email, $r2_email, $r1_amount, $r2_amount, $returnUrl, $cancelUrl, $product_name, $indentifier){



        $createPacket = array(

            "actionType" =>"PAY",

            "currencyCode" => $currency,

            "receiverList" => array("receiver" => 

                array(

                    array(

                        "amount"=> $r1_amount,

                        "email"=> $r1_email

                    ),

                    array(

                        "amount"=> $r2_amount,

                        "email"=> $r2_email

                    )

            )

            ),

            "returnUrl" => $returnUrl,

            "cancelUrl" => $cancelUrl,

            "ipnNotificationUrl" => URL::to('/adaptive_payments'),

            "requestEnvelope" => array(

                "errorLanguage" => "en_US",

                "detailLevel" => "ReturnAll",

            ),

        );



        $response = $this->_paypalSend($createPacket,"Pay");



        $paykey = $response['payKey'];



        $detailsPack = array(

            "requestEnvelope" => array(

                "errorLanguage" => "en_US",

                "detailLevel" => "ReturnAll",

            ),

            "payKey" => $paykey,

            "receiverOptions" => array(

                array(

                    "receiver" => array("email" => $r1_email),

                    "invoiceData" => array(

                        "item" => array(

                            array(

                                array(

                                    "name" => $product_name,

                                    "price" => $r1_amount,

                                    "identifier" => $indentifier

                                )

                            )

                        )

                    )

                ),

                array(

                    "receiver" => array("email" => $r2_email),

                    "invoiceData" => array(

                        "item" => array(

                            array(

                                array(

                                    "name" => "product 2",

                                    "price" => $r2_amount,

                                    "identifier" => "p2"

                                )

                            )

                        )

                    )

                )

            )

        );



        $response = $this->_paypalSend($detailsPack, "SetPaymentOptions");



        $dets = $this->getPaymentOptions($paykey);



        return $this->paypalUrl.$paykey;



    }

}

And here the response i get,

array(3) { ["responseEnvelope"]=> array(4) { ["timestamp"]=> string(29) "2015-06-04T14:04:07.395-07:00" ["ack"]=> string(7) "Success" ["correlationId"]=> string(13) "6c472863c4053" ["build"]=> string(8) "15743565" } ["payKey"]=> string(20) "AP-5LN44020A0587750B" ["paymentExecStatus"]=> string(7) "CREATED" } 

Which is perfectly fine and i can use paykey, but ipnNotificationUrl not working as it should. it doesn't send anything at all at URL.

What t tried to solve the issue,

1) did change URL of ipnNotificationUrl even made hard coded

2) tested with IPN simulator (the listener), worked for test

3) changed return URL and cancel URL to test if others working, also made sure that i'm working with correct file and code

Please HELP!

1

There are 1 answers

0
Parth Parmar On

The code is working fine , it wasn't because paypal had put IPN as queued.

More details here https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNOperations/

Hope this answer will help others.