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 29c8d721 authored by Alessio Zampatti's avatar Alessio Zampatti Committed by attilak

PW-1173: Ignore OFFER_CLOSED for already authorised orders, or for or… (#436)

* PW-1173: Ignore OFFER_CLOSED for already authorised orders, or for orders that are not matching the paymentmethod of the notification
Set the ccType of boleto payments to the proper boleto variant.
reset order id on card placeorder

* PW-1173: use nonempty
parent a9a446ee
...@@ -907,6 +907,41 @@ class Cron ...@@ -907,6 +907,41 @@ class Cron
} }
break; break;
case Notification::OFFER_CLOSED: case Notification::OFFER_CLOSED:
$previousSuccess = $this->_order->getData('adyen_notification_event_code_success');
// Order is already Authorised
if (!empty($previousSuccess)) {
$this->_adyenLogger->addAdyenNotificationCronjob("Order is already authorised, skipping OFFER_CLOSED");
break;
}
/*
* For cards, it can be 'visa', 'maestro',...
* For alternatives, it can be 'ideal', 'directEbanking',...
*/
$notificationPaymentMethod = $this->_paymentMethod;
/*
* For cards, it can be 'VI', 'MI',...
* For alternatives, it can be 'ideal', 'directEbanking',...
*/
$orderPaymentMethod = $this->_order->getPayment()->getCcType();
$isOrderCc = strcmp($this->_paymentMethodCode(),
'adyen_cc') == 0 || strcmp($this->_paymentMethodCode(), 'adyen_oneclick') == 0;
/*
* If the order was made with an Alternative payment method,
* continue with the cancellation only if the payment method of
* the notification matches the payment method of the order.
*/
if (!$isOrderCc && strcmp($notificationPaymentMethod, $orderPaymentMethod) !== 0) {
$this->_adyenLogger->addAdyenNotificationCronjob("Order is not a credit card,
or the payment method in the notification does not match the payment method of the order,
skipping OFFER_CLOSED");
break;
}
if (!$this->_order->canCancel()) { if (!$this->_order->canCancel()) {
// Move the order from PAYMENT_REVIEW to NEW, so that can be cancelled // Move the order from PAYMENT_REVIEW to NEW, so that can be cancelled
$this->_order->setState(\Magento\Sales\Model\Order::STATE_NEW); $this->_order->setState(\Magento\Sales\Model\Order::STATE_NEW);
...@@ -1148,9 +1183,14 @@ class Cron ...@@ -1148,9 +1183,14 @@ class Cron
protected function _authorizePayment() protected function _authorizePayment()
{ {
$this->_adyenLogger->addAdyenNotificationCronjob('Authorisation of the order'); $this->_adyenLogger->addAdyenNotificationCronjob('Authorisation of the order');
// Set adyen_notification_event_code_success to true so that we ignore a possible OFFER_CLOSED
if (strcmp($this->_success, 'true') == 0) {
$this->_order->setData('adyen_notification_event_code_success', 1);
}
$fraudManualReviewStatus = $this->_getFraudManualReviewStatus(); $fraudManualReviewStatus = $this->_getFraudManualReviewStatus();
// If manual review is active and a seperate status is used then ignore the pre authorized status // If manual review is active and a separate status is used then ignore the pre authorized status
if ($this->_fraudManualReview != true || $fraudManualReviewStatus == "") { if ($this->_fraudManualReview != true || $fraudManualReviewStatus == "") {
$this->_setPrePaymentAuthorized(); $this->_setPrePaymentAuthorized();
} else { } else {
......
...@@ -46,6 +46,16 @@ class AdyenBoletoDataAssignObserver extends AbstractDataAssignObserver ...@@ -46,6 +46,16 @@ class AdyenBoletoDataAssignObserver extends AbstractDataAssignObserver
self::LASTNAME self::LASTNAME
]; ];
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
) {
$this->adyenHelper = $adyenHelper;
}
/** /**
* @param Observer $observer * @param Observer $observer
* @return void * @return void
...@@ -60,8 +70,11 @@ class AdyenBoletoDataAssignObserver extends AbstractDataAssignObserver ...@@ -60,8 +70,11 @@ class AdyenBoletoDataAssignObserver extends AbstractDataAssignObserver
} }
$paymentInfo = $this->readPaymentModelArgument($observer); $paymentInfo = $this->readPaymentModelArgument($observer);
if (!empty($additionalData[self::BOLETO_TYPE])) {
$paymentInfo->setCcType('boleto'); $paymentInfo->setCcType($additionalData[self::BOLETO_TYPE]);
} else {
$paymentInfo->setCcType($this->adyenHelper->getAdyenBoletoConfigData('boletotypes'));
}
foreach ($this->additionalInformationList as $additionalInformationKey) { foreach ($this->additionalInformationList as $additionalInformationKey) {
if (isset($additionalData[$additionalInformationKey])) { if (isset($additionalData[$additionalInformationKey])) {
......
...@@ -150,6 +150,8 @@ class PaymentInformationManagement ...@@ -150,6 +150,8 @@ class PaymentInformationManagement
// PaymentDataBuilder // PaymentDataBuilder
$currencyCode = $quote->getQuoteCurrencyCode(); $currencyCode = $quote->getQuoteCurrencyCode();
$amount = $quote->getGrandTotal(); $amount = $quote->getGrandTotal();
// Setting the orderid to null, so that we generate a new one for each /payments call
$quote->setReservedOrderId(null);
$reference = $quote->reserveOrderId()->getReservedOrderId(); $reference = $quote->reserveOrderId()->getReservedOrderId();
$request = $this->adyenRequestHelper->buildPaymentData($request, $amount, $currencyCode, $reference); $request = $this->adyenRequestHelper->buildPaymentData($request, $amount, $currencyCode, $reference);
......
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