webtechnick / CakePHP-Paypal-IPN-Plugin

CakePHP Paypal Instant Payment Notification Plugin

Home Page:http://www.webtechnick.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PayPal IPN Failed Handshake Fix

Camasoft opened this issue · comments

I recently received a notification that PayPal IPN notifications sent to my website PayPal listener were failing. I was able to determine that all of the data was successfully received and stored in the database table, along with the VERIFIED response from PayPal, but they were receiving a 302 instead of a 200 response from my website. This turned out to be a needed fix in the return from the InstantPaymentNotificationsController::process method:

public function process() {
$this->autoRender = false;
$this->log('Process accessed', 'paypal');
if ($this->request->is('post')) {
$this->log('POST ' . print_r($_POST, true), 'paypal');
}
if ($this->InstantPaymentNotification->isValid($_POST)) {
$this->log('POST Valid', 'paypal');
$notification = $this->InstantPaymentNotification->buildAssociationsFromIPN($_POST);
$existingIPNId = $this->InstantPaymentNotification->searchIPNId($notification);
if ($existingIPNId !== false) {
$notification['InstantPaymentNotification']['id'] = $existingIPNId;
}
$this->InstantPaymentNotification->saveAll($notification);
$this->__processTransaction($this->InstantPaymentNotification->id);
} else {
$this->log('POST Not Validated', 'paypal');
}
return $this->redirect('/');
}

Specifically line 50: return $this->redirect('/');. This needs to be changed to

return CURLOPT_HTTP200ALIASES;

I am opening this issue and supplying the resolution in the hopes that anyone else who is still using CakePHP 2 and this plugin will find it helpful, since it appears this plugin has not been updated for a long time.

Thank you very much for your contribution. I would encourage you to fork and issue a pull request so that I may review it and get it checked in.

This fix worked for me. Thanks so much!