Search code examples
phppaypalpaypal-adaptive-paymentsadaptive-parallel-payment

PayPal hitting notification URL repeatedly


I have made a payment through paypal adaptive payment and its succecced

then i send validation request and i gotted status=VERIFIED

here is code :

function process_new() {
$req = 'cmd=_notify-validate&'.file_get_contents("php://input");
$ipnmsg=$this->decodePayPalIPN($req);
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
$res=curl_exec($ch);
curl_close($ch);
    //if ($this->InstantPaymentNotification->is_valid($req)) 
    if($res=='VERIFIED') // i got verified here
    {
        $txnIds=array();
        $notifications = $this->InstantPaymentNotification->buildAssociationsFromIPN_new($ipnmsg);
        foreach($notifications as $notification){
            $this->IpnNotification->create();
            $this->IpnNotification->save($notification);
            $txnIds[]=$this->IpnNotification->id;
            }
       //$this->InstantPaymentNotificationNew->saveAll($notification);
        $this->__processTransactionNew($txnIds);
    }

    //$this->redirect('/');
}

unable to find the reason why the notify_url keep hitting.

If more information needed i will post them too ...

This is IPN history :

enter image description here

  `$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);`

it return 200 but still paypal shows HTTP status code : 500

and the notification url :http://example.com/instant_payment_notifications/process_new doesn't return HTTP status code : 500

thanks.


Solution

  • Look closely at your PayPal screenshot: your server is returning HTTP code 500 on those requests, meaning that PayPal interprets this as a bad thing and that the HTTP transaction didn't complete successfully and it will try again until it receives a 200 OK.

    Check the configuration of your server. Did you recently make changes to your server's configuration? If you craft your own POST to your endpoint URL, does it return a 500 status code for you? Has it been down for maintenance for a time when these requests were put in? Set up some API monitoring to ensure that these 500 errors aren't being thrown often.