We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit f8b022c4 authored by Aleffio's avatar Aleffio

PW-243: isDuplicate now checks for the 'original_reference' field, this allows...

PW-243: isDuplicate now checks for the 'original_reference' field, this allows now to process two notifications with the same billing agreement but different payment.
parent 1166041b
......@@ -287,9 +287,12 @@ class Json extends \Magento\Framework\App\Action\Action
$pspReference = trim($response['pspReference']);
$eventCode = trim($response['eventCode']);
$success = trim($response['success']);
$originalReference = null;
if(isset($response['originalReference'])) {
$originalReference = trim($response['originalReference']);
}
$notification = $this->_objectManager->create('Adyen\Payment\Model\Notification');
return $notification->isDuplicate($pspReference, $eventCode, $success);
return $notification->isDuplicate($pspReference, $eventCode, $success, $originalReference);
}
/**
......
......@@ -84,11 +84,12 @@ class Notification extends \Magento\Framework\Model\AbstractModel
* @param $pspReference
* @param $eventCode
* @param $success
* @param $originalReference
* @return bool (true if the notification is a duplicate)
*/
public function isDuplicate($pspReference, $eventCode, $success)
public function isDuplicate($pspReference, $eventCode, $success, $originalReference)
{
$result = $this->getResource()->getNotification($pspReference, $eventCode, $success);
$result = $this->getResource()->getNotification($pspReference, $eventCode, $success, $originalReference);
return (empty($result)) ? false : true;
}
......
......@@ -40,15 +40,17 @@ class Notification extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
* @param $pspReference
* @param $eventCode
* @param $success
* @param $originalReference
* @return array
*/
public function getNotification($pspReference, $eventCode, $success)
public function getNotification($pspReference, $eventCode, $success, $originalReference)
{
$select = $this->getConnection()->select()
->from(['notification' => $this->getTable('adyen_notification')])
->where('notification.pspreference=?', $pspReference)
->where('notification.event_code=?', $eventCode)
->where('notification.success=?', $success);
->where('notification.success=?', $success)
->where('notification.original_reference=?', $originalReference);
return $this->getConnection()->fetchAll($select);
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment