/** * {@inheritdoc] */ public function cancel() { if ($this->canCancel()) { Mage::dispatchEvent('order_cancel_before', array('order' => $this)); } return parent::cancel(); }
public function cancelaPedido(Mage_Sales_Model_Order $order) { $paymentMethod = $order->getPayment()->getMethodInstance()->getCode(); $listPaymentMethodsIdeasa = Mage::helper('base')->listPaymentMethods(); $this->logger->info('Processando cancelamento do pedido ' . $order->getRealOrderId() . ', do modulo: ' . $paymentMethod); try { if ($order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) { $order->cancel(); //força o cancelamento if ($order->getStatus() != Mage_Sales_Model_Order::STATE_CANCELED) { $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, Mage::helper('base')->__('Pedido cancelado'), $notified = false); } else { $order->addStatusToHistory($order->getStatus(), Mage::helper('base')->__('Pedido cancelado.')); } if ($order->hasInvoices() != '') { $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, Mage::helper('base')->__('O pagamento e o pedido foram cancelados, mas não foi possível retornar os produtos ao estoque pois já havia uma fatura gerada para este pedido.'), $notified = false); } $order->save(); } if (Mage::helper('base')->isIdeasaPaymentMethod($paymentMethod) && Mage::helper('base/module')->isPagSeguroDiretoExists() && $paymentMethod == $listPaymentMethodsIdeasa[0]) { Mage::getModel('pagsegurodireto/notification')->sendEmail($order); } } catch (Exception $e) { $this->logger->error("Erro ao cancelar pedido {$orderId} \n {$e->__toString}()"); } $this->logger->info('Cancelamento do pedido foi concluido ' . $order->getRealOrderId() . ', do modulo: ' . $paymentMethod); return; }
/** * Cancel the order if is in the current Magento store, otherwise, simply * set the state of the order to a state of canceled. * * @return self */ protected function _cancelOrder() { if ($this->_order->getId()) { // Only save order that's in this magento store $this->_order->cancel()->save(); } else { // The order is not in this magento store, simply set state of this empty order to cancel $this->_order->setState(Mage_Sales_Model_Order::STATE_CANCELED); } return $this; }
/** * Process a failed order. Sets its new state and status and cancels the order * if set in config. * * @param $newStates * @param bool $description * @return bool */ protected function _processFailed($newStates, $description = false) { $description = Mage::helper('buckaroo3extended')->__($description); $description .= " (#{$this->_postArray['brq_statuscode']})"; //sets the transaction key if its defined ('brq_transactions') //will retrieve it from the response array, if response actually is an array if (!$this->_order->getTransactionKey() && array_key_exists('brq_transactions', $this->_postArray)) { $this->_order->setTransactionKey($this->_postArray['brq_transactions']); } if (Mage::getStoreConfig('buckaroo/buckaroo3extended_advanced/cancel_on_failed', $this->_order->getStoreId()) && $this->_order->canCancel()) { $this->_order->cancel()->save(); } if ($this->_order->getState() == Mage_Sales_Model_Order::STATE_CANCELED) { $this->_order->addStatusHistoryComment($description, $newStates[1])->save(); $this->_order->setStatus($newStates[1])->save(); } else { $this->_order->addStatusHistoryComment($description)->save(); } return true; }
protected function _processConfirmState($state, $data) { switch ($state) { case 'SUCCESS': case 'PENDING': $this->_confirmOrder($data); break; case 'CANCEL': $this->_cancelOrder(); break; case 'FAILURE': $msg = !empty($data['message']) ? $data['message'] : ''; if (!$this->_succeeded($this->order)) { $this->order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, Mage::helper('wirecard_checkout_page')->__('An error occured during the payment process:') . ' ' . $msg)->save(); $this->order->cancel(); $payment = $this->order->getPayment(); $payment->setAdditionalInformation('consumerMessage', $data['consumerMessage']); } break; default: throw new Exception('Unhandled Wirecard Checkout Page action "' . $data['paymentState'] . '".'); } }
/** * Cancel the order * * @param Mage_Sales_Model_Order $order */ public function cancel(Mage_Sales_Model_Order $order) { $order->cancel()->save(); return $this; }
/** * Override cancel method to dispatch order * * @return unknown */ public function cancel() { parent::cancel(); //dispatch order in order preparation tab mage::helper('BackgroundTask')->AddTask('Dispatch order #' . $this->getId(), 'Orderpreparation', 'dispatchOrder', $this->getId()); return $this; }
/** * execute if transaction was loss * * @param SofortLib_TransactionData $transData * @param Mage_Sales_Model_Order $order * @return void */ private function _transactionLoss($transData, $order) { $payment = $order->getPayment(); if ($transData->isLastschrift()) { $payment->setParentTransactionId($transData->getTransaction())->setShouldCloseParentTransaction(true)->setIsTransactionClosed(0)->registerRefundNotification($transData->getAmount()); $order->addStatusHistoryComment(Mage::helper('pnsofortueberweisung')->__('Customer returned payment'))->setIsVisibleOnFront(true); $order->save(); } elseif ($transData->isSofortrechnung()) { // be sure that order can cancel $order->setState('sofort'); $order->cancel(); $order->addStatusHistoryComment(Mage::helper('pnsofortueberweisung')->__('Successfully canceled invoice: %s', $transData->getTransaction()))->setIsVisibleOnFront(true); } elseif ($transData->isSofortueberweisung()) { $lossStatus = Mage::getStoreConfig('payment/sofort/pnsofort_order_status_loss'); $order->setState('sofort'); if ($newStatus == 'unchanged') { $order->addStatusHistoryComment($transData->getStatus() . " " . $transData->getStatusReason()); } else { $order->addStatusHistoryComment($transData->getStatus() . " " . $transData->getStatusReason(), $lossStatus); } } else { // be sure that order can cancel $order->setState('sofort'); $order->cancel(); $order->addStatusHistoryComment(Mage::helper('pnsofortueberweisung')->__('Customer canceled payment'))->setIsVisibleOnFront(true); } $order->save(); }
/** * FALLS DIESE KLASSE AUFGRUND EINES KONFLIKTS (VERURSACHT Z.B. DURCH EIN ANDERES ADDON) NICHT AKTIV IST, * MUSS DIE KOMPLETTE METHODE IN DIE AKTIVE KLASSE KOPIERT WERDEN. SOLLTE DIE METHODE IN DER AKTIVEN KLASSE * BEREITS VORHANDEN SEIN, MUSS DIE 'Mage::dispatchEvent'-ANWEISUNG AN DEN ANFANG DER BEREITS VORHANDENEN * METHODE KOPIERT WERDEN. OB DIESE KLASSE AKTIV IST, KANN NACH INSTALLATION DES BILLPAY-ADDONS MIT HILFE * DES DIAGNOSESKRIPTS, WELCHES UNTER DER FOLGENDEN URL VERFÜGBAR IST, ÜBERPRÜFT WERDEN. * * http://<Ihr-Magento-Shop>/billpay/diagnostics/checkRewrites */ public function cancel() { Mage::dispatchEvent('billpay_before_cancel_order', array('order' => $this, 'useHTMLFormat' => true)); return parent::cancel(); }
/** * Cancel Magento order * * @param MageOrder $order Order * @param string $message Cancel message */ protected function cancelOrder(MageOrder $order, $message) { $order->cancel()->setState(MageOrder::STATE_CANCELED, true, $message, true)->sendOrderUpdateEmail()->setIsNotified(true)->save(); }
/** * Process decline action by ops decline url * * @param Mage_Sales_Model_Order $order Order * @param array $params Request params */ public function declineOrder($order, $params) { try { Mage::register('ops_auto_void', true); //Set this session value to true to allow cancel $order->cancel(); $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, Mage_Sales_Model_Order::STATE_CANCELED, Mage::helper('ops')->__('Order declined on ops side. Barclaycard status: %s, Payment ID: %s.', Mage::helper('ops')->getStatusText($params['STATUS']), $params['PAYID'])); $order->save(); $this->cancelInvoices($order); $this->setPaymentTransactionInformation($order->getPayment(), $params, 'decline'); } catch (Exception $e) { $this->_getCheckout()->addError(Mage::helper('ops')->__('Order can not be canceled for system reason.')); throw $e; } }
/** * Processed order cancelation * @param string $msg Order history message */ protected function _processCancel($msg) { $this->_order->cancel(); $this->_order->addStatusToHistory(Mage_Sales_Model_Order::STATE_CANCELED, $msg); $this->_order->save(); }
/** * Cancela la order anterior que se le pasa como parametro * * @param Mage_Sales_Model_Order $order * @return $this */ protected function _cancelOrder(Mage_Sales_Model_Order $order) { $order->cancel()->save(); return $this; }
/** * Attempt to cancel an order. * @param Mage_Sales_Model_Order $order * @param string $eventName * @return self * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function attemptCancelOrder(Mage_Sales_Model_Order $order, $eventName) { $logData = ['increment_id' => $order->getIncrementId()]; try { $order->cancel()->save(); $logMessage = 'Canceling order {increment_id}'; $this->_logger->info($logMessage, $this->_context->getMetaData(__CLASS__, $logData)); } catch (Exception $e) { // Catching any exception that might be thrown due to calling cancel method on the order object. $logMessage = 'An error occurred canceling order "{increment_id}". See the exception log for details.'; $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__, $logData)); $this->_logger->logException($e, $this->_context->getMetaData(__CLASS__, [], $e)); } return $this; }
/** * Handle Declined answer * * @throws Exception */ protected function _processDeclined() { $this->_order->cancel()->addStatusHistoryComment("WayForPay returned a Declined status. Code: #{$this->_data['reasonCode']}. Reason: {$this->_data['reason']}", Mage_Sales_Model_Order::STATE_CANCELED); $this->_order->save(); }
public function urlerrorAction() { Mage::log("init: " . __METHOD__); // este m�to es al que me dva a devolder el gateway en caso que algo salga mal $order_id = $this->getRequest()->get('Order'); Mage::log(__METHOD__ . " Modulo de pago - TodoPago ==> urlerror - orderid: " . $order_id); $answer = $this->getRequest()->get('Answer'); Mage::log(__METHOD__ . " Modulo de pago - TodoPago ==> urlerror - AnswerKey: " . $answer); $order = new Mage_Sales_Model_Order(); $order->loadByIncrementId($order_id); $status = Mage::getStoreConfig('payment/modulodepago2/estado_denegada'); if (empty($status)) { $status = Mage::getStoreConfig('payment/todopago_avanzada/estado_denegada'); } $state = $this->_get_new_order_state($status); if (Mage::getStoreConfig('payment/modulodepago2/modo_test_prod') == "test") { $message = "Todo Pago (TEST): error en el pago del formulario"; } else { $message = "OPERATIONID: {$order_id} - Todo Pago: error en el pago del formulario"; } $order->cancel(); Mage::log("Orden cancelada"); $order->setState($state, $status, $message); $order->save(); Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure' => true)); }