/** * @throws Payone_Core_Exception_InvoicePreparationNoItems|Payone_Core_Exception_InvoiceSave * @param Mage_Sales_Model_Order $order * @param array $itemsQty * @param null $invoiceIncrementId * @return Mage_Sales_Model_Order_Invoice */ protected function create(Mage_Sales_Model_Order $order, array $itemsQty = array(), $invoiceIncrementId = null) { /* @var $invoice Mage_Sales_Model_Order_Invoice */ $invoice = $order->prepareInvoice($itemsQty); if ($invoiceIncrementId) { $invoice->setIncrementId($invoiceIncrementId); } $invoice->setTransactionId($order->getPayment()->getLastTransId()); if (count($invoice->getAllItems()) <= 0) { throw new Payone_Core_Exception_InvoicePreparationNoItems($order->getIncrementId()); } if ($invoice) { $invoice->register(); $invoice->setEmailSent(false); $invoice->getOrder()->setIsInProcess(true); try { $transactionSave = $this->getFactory()->getModelResourceTransaction(); $transactionSave->addObject($invoice); $transactionSave->addObject($invoice->getOrder()); $transactionSave->save(); } catch (Mage_Core_Exception $e) { throw new Payone_Core_Exception_InvoiceSave($e->getMessage()); } return $invoice; } return null; }
/** * Builds invoice for order */ protected function _createInvoice() { if (!$this->_order->canInvoice()) { return; } $invoice = $this->_order->prepareInvoice(); $invoice->register()->capture(); $this->_order->addRelatedObject($invoice); }
/** * Create invoice */ protected function _createInvoice(Mage_Sales_Model_Order $order, $captureReferenceIds) { if ($order->canInvoice()) { $transactionSave = Mage::getModel('core/resource_transaction'); // Create invoice $invoice = $order->prepareInvoice()->register(); $invoice->setTransactionId(current($captureReferenceIds)); $transactionSave->addObject($invoice)->addObject($invoice->getOrder()); return $transactionSave->save(); } return false; }
/** * @param Mage_Sales_Model_Order $order * @return bool|Mage_Sales_Model_Order_Invoice */ public function createInvoiceForOrder(Mage_Sales_Model_Order $order) { if (!Mage::getStoreConfig('payment/lliqpay_cc/create_invoice') || !$order->canInvoice()) { return false; } $invoice = $order->prepareInvoice(); if (!$invoice) { return false; } $invoice->register()->pay(); Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save(); return $invoice; }
/** * Confirm the payment of an order * * @param array $data */ protected function _confirmOrder($data) { if (!$this->_succeeded($this->order)) { if ($data['paymentState'] == 'PENDING') { $this->order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, Mage::helper('wirecard_checkout_page')->__('The payment authorization is pending.'))->save(); } else { $this->order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, Mage::helper('wirecard_checkout_page')->__('The amount has been authorized and captured by Wirecard Checkout Page.'))->save(); // invoice payment if ($this->order->canInvoice()) { $invoice = $this->order->prepareInvoice(); $invoice->register()->capture(); Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save(); } // send new order email to customer $this->order->sendNewOrderEmail(); } } $payment = $this->order->getPayment(); $additionalInformation = array(); $additionalInformationString = ''; foreach ($data as $fieldName => $fieldValue) { switch ($fieldName) { case 'amount': case 'currency': case 'language': case 'responseFingerprint': case 'responseFingerprintOrder': case 'form_key': case 'paymentState': case 'orderId': break; default: $additionalInformation[htmlentities($fieldName)] = htmlentities($fieldValue); $additionalInformationString .= ' | ' . $fieldName . ' - ' . $fieldValue; } } if (count($additionalInformation) != 0) { $payment->setAdditionalInformation($additionalInformation); $payment->setAdditionalData(serialize($additionalInformation)); if ($payment->hasAdditionalInformation()) { Mage::log('Added Additional Information to Order ' . $data['orderId'] . ' :' . $additionalInformationString); } } $payment->save(); }
/** * Save an invoice for the order. * * @param Mage_Sales_Model_Order $order * * @return bool */ protected function _savePaidInvoice(Mage_Sales_Model_Order $order, $transaction_id = null) { $invoice = $order->prepareInvoice()->register()->setTransactionId($transaction_id)->pay(); Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save(); if (!Mage::Helper('mpm/data')->getConfig('mollie', 'skip_invoice_mails')) { $invoice->sendEmail(); } return TRUE; }
public function invoice(Mage_Sales_Model_Order $order, $transactionId, $mail) { if ($order->canInvoice()) { $invoice = $order->prepareInvoice(); $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE); $invoice->register(); Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save(); $invoice->setTransactionId($transactionId); $invoice->pay(); $invoice->save(); $invoice->sendEmail($mail, ''); } else { foreach ($order->getInvoiceCollection() as $invoice) { $invoice->pay()->save(); } } }
/** * Save invoice for order * * @param Mage_Sales_Model_Order $order * @return boolean Can save invoice or not */ protected function saveInvoice(Mage_Sales_Model_Order $order) { if ($order->canInvoice()) { $invoice = $order->prepareInvoice(); $invoice->register()->capture(); Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save(); return true; } return false; }
public function registerPaymentCapture(Mage_Sales_Model_Order $order, $transactionId, $amount, array $post) { $payment = $order->getPayment(); foreach ($post as $key => $value) { $payment->setTransactionAdditionalInfo($key, $value); } $payment->setTransactionId($transactionId)->setShouldCloseParentTransaction(true)->setIsTransactionClosed(true)->setIsTransactionPending(false)->save(); $invoice = $order->prepareInvoice(); $invoice->register(); $order->setIsCustomerNotified(false)->setIsInProcess(true)->save(); $formattedAmount = $order->getOrderCurrency()->format($amount, null, false); $this->_addTransaction($order, $invoice, $payment, $transactionId); $order->addStatusHistoryComment($this->_helper()->__("Registered notification about captured amount of %s. Transaction ID: %s.", $formattedAmount, $transactionId))->setIsCustomerNotified(false)->save(); /** @var $transactionSave Mage_Core_Model_Resource_Transaction */ $transactionSave = Mage::getModel('core/resource_transaction'); $transactionSave->addObject($invoice)->addObject($invoice->getOrder())->save(); # Notify customer if ($invoice && !$order->getEmailSent()) { $order->sendNewOrderEmail()->addStatusHistoryComment($this->_helper()->__('Notified customer about invoice #%s.', $invoice->getIncrementId()))->setIsCustomerNotified(true)->save(); } }
/** * Depending on the settings we create an invoice and capture it. * * @param Mage_Sales_Model_Order $order * @param boolean Returns true if an invoice has been created. */ protected function createInvoice(Mage_Sales_Model_Order $order, Customweb_SaferpayCw_Model_Transaction $transaction) { try { $isSettlementAfterOrder = $this->getPaymentMethodConfigurationValue('settlement'); $isCaptureAfterOrder = $transaction->getTransactionObject()->isCaptured(); $this->getHelper()->log("Payment config: settlement='" . $isSettlementAfterOrder . "' capturing='" . $isCaptureAfterOrder . "'"); if ($isSettlementAfterOrder != 'settlement_direct') { return false; } // Do not create multiple invoices if ($order->hasInvoices()) { return false; } $invoice = $order->prepareInvoice(); if ($isCaptureAfterOrder) { $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE); } $invoice->register(); $invoice->setTransactionId($transaction->getTransactionObject()->getPaymentId()); $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder()); $transactionSave->save(); if ($this->getConfigData('invoice_send_email')) { $invoice->sendEmail(); } return true; } catch (Exception $e) { $this->getHelper()->log("Create Invoice: " . $e->getMessage()); return false; } }
/** * @param Mage_Sales_Model_Order $order * @param array $itemsQty * @param string $comment * @param bool $email * @param bool $includeComment * @return string */ protected function _createInvoiceAndCapture($order, $itemsQty, $comment = null, $email = false, $includeComment = false) { /** @var $helper RetailOps_Api_Helper_Data */ $helper = Mage::helper('retailops_api'); try { $itemsQtyFomratted = array(); if ($itemsQty) { foreach ($order->getAllItems() as $item) { $itemsQtyFomratted[$item->getId()] = isset($itemsQty[$item->getId()]) ? $itemsQty[$item->getId()] : 0; } } $invoice = $order->prepareInvoice($itemsQtyFomratted); $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE); $invoice->register(); if ($comment !== null) { $invoice->addComment($comment, $email); } if ($email) { $invoice->setEmailSent(true); } $invoice->getOrder()->setIsInProcess(true); $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save(); $invoice->sendEmail($email, $includeComment ? $comment : ''); $result['invoice'] = $helper->removeObjectsFromResult($this->_getAttributes($invoice, 'invoice')); $result['items'] = array(); foreach ($invoice->getAllItems() as $item) { $result['items'][] = $helper->removeObjectsFromResult($this->_getAttributes($item, 'invoice_item')); } $result['status'] = RetailOps_Api_Helper_Data::API_STATUS_SUCCESS; } catch (Exception $e) { $result['status'] = RetailOps_Api_Helper_Data::API_STATUS_FAIL; $result['message'] = $e->getMessage(); } return $result; }
/** * Process Configured Payment Action: Direct Sale, create invoice if state is Pending * * @param Mage_Sales_Model_Order $order Order * @param array $params Request params */ protected function _processDirectSale($order, $params, $instantCapture = 0) { Mage::register('ops_auto_capture', true); $status = $params['STATUS']; if ($status == Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT) { $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('ops')->__('Waiting for the payment of the customer')); // send new order mail for bank transfer, since it is 'successfully' authorized at this point if ($order->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_BankTransfer && $order->getEmailSent() != 1) { $order->sendNewOrderEmail(); } $order->save(); } elseif ($status == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING) { $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('ops')->__('Authorization waiting from Barclaycard')); $order->save(); } elseif ($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT || $instantCapture) { if ($status == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED) { if ($order->getStatus() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) { $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, Mage::helper('ops')->__('Processed by Barclaycard')); } } else { $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, Mage::helper('ops')->__('Processed by Barclaycard')); $order->save(); } if (!$order->getInvoiceCollection()->getSize() && $order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING && $order->canInvoice()) { $invoice = $order->prepareInvoice(); $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE); $invoice->register(); $invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID); $invoice->getOrder()->setIsInProcess(true); $invoice->save(); $this->sendInvoiceToCustomer($invoice); $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save(); /* * If the payment method is a redirect-payment-method send the email * In any other case Magento sends an email automatically in Mage_Checkout_Model_Type_Onepage::saveOrder */ if ($this->isRedirectPaymentMethod($order) === true && $order->getEmailSent() != 1) { $order->sendNewOrderEmail(); } $eventData = array('data_object' => $order, 'order' => $order); Mage::dispatchEvent('ops_sales_order_save_commit_after', $eventData); } if ($this->isInlinePayment($order->getPayment()) && 0 < strlen(trim($order->getPayment()->getAdditionalInformation('HTML_ANSWER'))) && $order->getPayment()->getAdditionalInformation('status') == Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED) { $order->getPayment()->setIsTransactionApproved(true)->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, true)->save(); $this->setInvoicesToPaid($order); $order->getPayment()->getAuthorizationTransaction()->setIsClosed(true)->save(); $order->getPayment()->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $order->getPayment())->setIsClosed(true)->save(); $order->sendNewOrderEmail(); $order->save(); } if ($this->isInlinePayment($order->getPayment()) && Mage::getModel('ops/config')->getSendInvoice() && Mage::getModel('ops/config')->getPaymentAction($order->getStoreId()) === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) { foreach ($order->getInvoiceCollection() as $invoice) { $this->sendInvoiceToCustomer($invoice); } } } else { $order->save(); } }
/** * Create object invoice * @param Mage_Sales_Model_Order $order * @param string $transactionReference * @param boolean $capture * @param boolean $paid * @return Mage_Sales_Model_Order_Invoice $invoice */ protected function create_invoice($order, $transactionReference, $capture = true, $paid = false) { /* @var $invoice Mage_Sales_Model_Order_Invoice */ $invoice = $order->prepareInvoice(); $invoice->setTransactionId($transactionReference); $capture_case = Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE; if ($capture) { $capture_case = Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE; } $invoice->setRequestedCaptureCase($capture_case); $invoice->register(); $invoice->getOrder()->setIsInProcess(true); if ($paid) { $invoice->setIsPaid(1); } return $invoice; }
/** * Process Configured Payment Action: Direct Sale, create invoce if state is Pending * * @param Mage_Sales_Model_Order $order Order * @param array $params Request params */ protected function _processDirectSale($order, $params, $instantCapture = 0) { Mage::register('postfinance_auto_capture', true); $status = $params['STATUS']; if ($status == PostFinance_Payment_Model_Payment_Abstract::POSTFINANCE_AWAIT_CUSTOMER_PAYMENT) { $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('postfinance')->__('Waiting for the payment of the customer')); $order->save(); } elseif ($status == PostFinance_Payment_Model_Payment_Abstract::POSTFINANCE_AUTHORIZED_WAITING) { $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('postfinance')->__('Authorization waiting from PostFinance')); $order->save(); } elseif ($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT || $instantCapture) { if ($status == PostFinance_Payment_Model_Payment_Abstract::POSTFINANCE_AUTHORIZED) { if ($order->getStatus() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) { $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, Mage::helper('postfinance')->__('Processed by PostFinance')); } } else { $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, Mage::helper('postfinance')->__('Processed by PostFinance')); } if (!$order->getInvoiceCollection()->getSize()) { $invoice = $order->prepareInvoice(); $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE); $invoice->register(); $invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID); $invoice->getOrder()->setIsInProcess(true); $invoice->save(); $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save(); /* * If the payment method is a redirect-payment-method send the email * In any other case Magento sends an email automatically in Mage_Checkout_Model_Type_Onepage::saveOrder */ if ($this->isRedirectPaymentMethod($order) === true && $order->getEmailSent() !== '1') { $order->sendNewOrderEmail(); } } } else { $order->save(); } }
/** * @param Mage_Sales_Model_Order $order * * @return bool */ public function createInvoice($order) { if (!$order->getId()) { return false; } $this->log(sprintf('Gerando fatura para o pedido: %s.', $order->getId())); $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'O pagamento foi confirmado e o pedido está sendo processado.', true); if (!$order->canInvoice()) { $this->log(sprintf('ImpossÃvel gerar fatura para o pedido %s.', $order->getId()), 4); // TODO define how to handle this return false; } $invoice = $order->prepareInvoice(); $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE); $invoice->register(); Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save(); $invoice->sendEmail(true); $this->log('Fatura gerada com sucesso.'); return true; }
public function lastStep($order_key, $answer_key) { /*COMENTO LAS PARTES DONDE SE UTILIZAN LOS ESTADOS CREADOS POR EL MODULO*/ Mage::log("init: " . __METHOD__); $todopago_connector = Mage::helper('modulodepago2/connector')->getConnector(); // /a este metodo es al que me va a devolver el gateway en caso que todo salga ok Mage::log("Modulo de pago - TodoPago ==> secondStep - orderid: " . $order_key); Mage::log("Modulo de pago - TodoPago ==> secondStep - AnswerKey: " . $answer_key); $order = new Mage_Sales_Model_Order(); $order->loadByIncrementId($order_key); //merchant $merchant = Mage::helper('modulodepago2/ambiente')->get_merchant(); // Security $security = Mage::helper('modulodepago2/ambiente')->get_security_code(); $requestkey = $order->getTodopagoclave(); // ahora vuelvo a consumir web service para confirmar la transaccion $optionsAnswer = array('Security' => $security, 'Merchant' => $merchant, 'RequestKey' => $requestkey, 'AnswerKey' => $answer_key); Mage::log("Modulo de pago - TodoPago ==> secondStep (" . $order_key . ") - AnswerKey: " . json_encode($optionsAnswer)); try { Mage::log("try " . __METHOD__); $second_step = $todopago_connector->getAuthorizeAnswer($optionsAnswer); Mage::log("Modulo de pago - TodoPago ==> secondStep (" . $order_key . ") - second_step: " . json_encode($second_step)); $todopagotable = new Todopago_Modulodepago2_Model_Todopagotable(); $todopagotable->load($order_key, "order_id"); $todopagotable->setAnswerKey($answer_key); $todopagotable->setGetauthorizeanswerStatus(Mage::getModel('core/date')->date('Y-m-d H:i:s') . " - " . $second_step["StatusCode"] . " - " . $second_step['StatusMessage']); $todopagotable->save(); //para saber si es un cupon if (strlen($second_step['Payload']['Answer']["BARCODE"]) > 0) { $status = Mage::getStoreConfig('payment/modulodepago2/estado_offline'); if (empty($status)) { $status = Mage::getStoreConfig('payment/todopago_avanzada/estado_offline'); } $state = $this->_get_new_order_state($status); if (Mage::getStoreConfig('payment/modulodepago2/modo_test_prod') == "test") { $message = "Todo Pago (TEST): " . $second_step['StatusMessage']; } else { $message = "Todo Pago: " . $second_step['StatusMessage']; } $order->setState($state, $status, $message); try { $order->sendNewOrderEmail(); } catch (Exception $e) { Mage::log("catch : " . __METHOD__); Mage::log("message: " . var_export($e, true)); $order->sendOrderUpdateEmail(true, $message); } $order->save(); Mage_Core_Controller_Varien_Action::_redirect('modulodepago2/cupon/index', array('_secure' => true, 'nroop' => $order_key, 'venc' => $second_step['Payload']['Answer']["COUPONEXPDATE"], 'total' => $second_step['Payload']['Request']['AMOUNT'], 'code' => $second_step['Payload']['Answer']["BARCODE"], 'tipocode' => $second_step['Payload']['Answer']["BARCODETYPE"], 'empresa' => $second_step['Payload']['Answer']["PAYMENTMETHODNAME"])); } elseif ($second_step['StatusCode'] == -1) { $status = Mage::getStoreConfig('payment/modulodepago2/order_aprov'); if (empty($status)) { $status = Mage::getStoreConfig('payment/todopago_avanzada/order_aprov'); } $state = $this->_get_new_order_state($status); if (Mage::getStoreConfig('payment/modulodepago2/modo_test_prod') == "test") { $message = "Todo Pago (TEST): " . $second_step['StatusMessage']; } else { $message = "Todo Pago: " . $second_step['StatusMessage']; } $order->setState($state, $status, $message); try { $order->sendNewOrderEmail(); } catch (Exception $e) { Mage::log("catch : " . __METHOD__); Mage::log("message: " . var_export($e, true)); $order->sendOrderUpdateEmail(true, $message); } $payment = $order->getPayment(); $payment->setTransactionId($second_step['AuthorizationKey']); $payment->setParentTransactionId($payment->getTransactionId()); $payment->save(); $order->save(); $invoice = $order->prepareInvoice()->setTransactionId(1)->addComment("Invoice created.")->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE)->register()->pay(); Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save(); Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure' => true)); } elseif ($second_step['StatusCode'] != -1) { $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): " . $second_step['StatusMessage']; } else { $message = "Todo Pago: " . $second_step['StatusMessage']; } $order->cancel(); Mage::log("Orden cancelada"); $order->setState($state, $status, $message); $order->sendOrderUpdateEmail(true, $message); $order->save(); Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure' => true)); } } catch (Exception $e) { Mage::log("catch : " . __METHOD__); $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)(Exception): " . $e; } else { $message = "Todo Pago (Exception): " . $e; } $order->cancel(); Mage::log("Orden cancelada"); $order->setState($state, $status, $message); $order->sendOrderUpdateEmail(true, $message); $order->save(); Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure' => true)); } }