Example #1
0
 /**
  * @param $ignoreHasInvoice
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _holdCancelOrder($ignoreHasInvoice)
 {
     $orderStatus = $this->_getConfigData('payment_cancelled', 'adyen_abstract', $this->_order->getStoreId());
     // check if order has in invoice only cancel/hold if this is not the case
     if ($ignoreHasInvoice || !$this->_order->hasInvoices()) {
         if ($orderStatus == \Magento\Sales\Model\Order::STATE_HOLDED) {
             // Allow magento to hold order
             $this->_order->setActionFlag(\Magento\Sales\Model\Order::ACTION_FLAG_HOLD, true);
             if ($this->_order->canHold()) {
                 $this->_order->hold();
             } else {
                 $this->_adyenLogger->addAdyenNotificationCronjob('Order can not hold or is already on Hold');
                 return;
             }
         } else {
             // Allow magento to cancel order
             $this->_order->setActionFlag(\Magento\Sales\Model\Order::ACTION_FLAG_CANCEL, true);
             if ($this->_order->canCancel()) {
                 $this->_order->cancel();
             } else {
                 $this->_adyenLogger->addAdyenNotificationCronjob('Order can not be canceled');
                 return;
             }
         }
     } else {
         $this->_adyenLogger->addAdyenNotificationCronjob('Order has already an invoice so cannot be canceled');
     }
 }
Example #2
0
 /**
  * @param $order
  * @return bool
  * @deprecate not needed already cancelled in ProcessController
  */
 protected function _holdCancelOrder($ignoreHasInvoice)
 {
     $orderStatus = $this->_getConfigData('payment_cancelled', 'adyen_abstract', $this->_order->getStoreId());
     // check if order has in invoice only cancel/hold if this is not the case
     if ($ignoreHasInvoice || !$this->_order->hasInvoices()) {
         $this->_order->setActionFlag($orderStatus, true);
         if ($orderStatus == \Magento\Sales\Model\Order::STATE_HOLDED) {
             if ($this->_order->canHold()) {
                 $this->_order->hold();
             } else {
                 $this->_debugData['warning'] = 'Order can not hold or is already on Hold';
                 return;
             }
         } else {
             if ($this->_order->canCancel()) {
                 $this->_order->cancel();
             } else {
                 $this->_debugData['warning'] = 'Order can not be canceled';
                 return;
             }
         }
     } else {
         $this->_debugData['warning'] = 'Order has already an invoice so cannot be canceled';
     }
 }
 /**
  * delete failed order
  *
  * @param \Magento\Sales\Model\Order $order
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function deleteOrder($order)
 {
     if ($order->canUnhold()) {
         $order->unhold();
     }
     $order->cancel();
     /* hack isSecureArea flag, otherwise actionValidator fails */
     $this->_registry->unregister('isSecureArea');
     $this->_registry->register('isSecureArea', true);
     $order->delete();
 }