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 ...@@ -287,9 +287,12 @@ class Json extends \Magento\Framework\App\Action\Action
$pspReference = trim($response['pspReference']); $pspReference = trim($response['pspReference']);
$eventCode = trim($response['eventCode']); $eventCode = trim($response['eventCode']);
$success = trim($response['success']); $success = trim($response['success']);
$originalReference = null;
if(isset($response['originalReference'])) {
$originalReference = trim($response['originalReference']);
}
$notification = $this->_objectManager->create('Adyen\Payment\Model\Notification'); $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 ...@@ -84,11 +84,12 @@ class Notification extends \Magento\Framework\Model\AbstractModel
* @param $pspReference * @param $pspReference
* @param $eventCode * @param $eventCode
* @param $success * @param $success
* @param $originalReference
* @return bool (true if the notification is a duplicate) * @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; return (empty($result)) ? false : true;
} }
......
...@@ -40,15 +40,17 @@ class Notification extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb ...@@ -40,15 +40,17 @@ class Notification extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
* @param $pspReference * @param $pspReference
* @param $eventCode * @param $eventCode
* @param $success * @param $success
* @param $originalReference
* @return array * @return array
*/ */
public function getNotification($pspReference, $eventCode, $success) public function getNotification($pspReference, $eventCode, $success, $originalReference)
{ {
$select = $this->getConnection()->select() $select = $this->getConnection()->select()
->from(['notification' => $this->getTable('adyen_notification')]) ->from(['notification' => $this->getTable('adyen_notification')])
->where('notification.pspreference=?', $pspReference) ->where('notification.pspreference=?', $pspReference)
->where('notification.event_code=?', $eventCode) ->where('notification.event_code=?', $eventCode)
->where('notification.success=?', $success); ->where('notification.success=?', $success)
->where('notification.original_reference=?', $originalReference);
return $this->getConnection()->fetchAll($select); 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