コード例 #1
0
 /**
  * Send PDF to customer, add status history comment to order.
  *
  * @param stdClass $response
  * @param Mage_Sales_Model_Order $order
  * @return Dhl_OnlineRetoure_AddressController
  */
 protected function _printPdf(stdClass $response, Mage_Sales_Model_Order $order)
 {
     $localeDate = Mage::app()->getLocale()->date($response->issueDate);
     $filenameDate = Mage::getSingleton('core/date')->date('Y-m-d', $response->issueDate);
     $this->_prepareDownloadResponse(sprintf("%s_Return_%s_%s.pdf", str_replace(" ", "_", Mage::app()->getStore()->getName()), $order->getIncrementId(), $filenameDate), base64_decode($response->label), 'application/pdf');
     $comment = 'Return label with ident code (IDC) %s successfully created on %s.';
     $order->addStatusHistoryComment($this->__($comment, $response->idc, $localeDate))->setIsVisibleOnFront(true)->save();
     Mage::helper("dhlonlineretoure/validate")->logSuccess();
     return $this;
 }
コード例 #2
0
ファイル: Ipn.php プロジェクト: quyip8818/Mag
 /**
  * Generate an "IPN" comment with additional explanation.
  * Returns the generated comment or order status history object
  *
  * @param string $comment
  * @param bool $addToHistory
  * @return string|Mage_Sales_Model_Order_Status_History
  */
 protected function _createIpnComment($comment = '', $addToHistory = false)
 {
     $paymentStatus = $this->getRequestData('payment_status');
     $message = Mage::helper('paypal')->__('IPN "%s".', $paymentStatus);
     if ($comment) {
         $message .= ' ' . $comment;
     }
     if ($addToHistory) {
         $message = $this->_order->addStatusHistoryComment($message);
         $message->setIsCustomerNotified(null);
     }
     return $message;
 }
コード例 #3
0
ファイル: Push.php プロジェクト: technomagegithub/olgo.nl
 /**
  * processes an order awaiting payment. Sets its new state and status.
  *
  * @param $newStates
  * @param bool $description
  * @return bool
  */
 protected function _processPendingPayment($newStates, $description = false)
 {
     $description = Mage::helper('buckaroo3extended')->__($description);
     $description .= " (#{$this->_postArray['brq_statuscode']})";
     //sets the transaction key if its defined ($trx)
     //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 ($this->_order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
         $this->_order->addStatusHistoryComment($description, $newStates[1])->save();
         $this->_order->setStatus($newStates[1])->save();
     } else {
         $this->_order->addStatusHistoryComment($description)->save();
     }
     return true;
 }
コード例 #4
0
 /**
  * Add comment to order
  *
  * @param  Mage_Sales_Model_Order   		$order
  * @param  string                   		$comment
  * @param  boolean  						$isShipmentSuccessfullyCreated
  *
  * @return void
  */
 public function addCommentToOrder(Mage_Sales_Model_Order $order, $comment, $isShipmentSuccessfullyCreated = false)
 {
     /*
      * for Magento 1.4.x.x
      */
     if (true === $this->getConfig()->isVersionRecommendedOrLarger()) {
         $order->addStatusHistoryComment($comment)->setIsVisibleOnFront(false)->setIsCustomerNotified(false)->save();
         /*
          * for Magento 1.3.x.x
          */
     } else {
         //Get existing order status
         $status = $order->getStatus();
         //If shipment was created successfully
         if (true === $isShipmentSuccessfullyCreated) {
             $status = Mage_Sales_Model_Order::STATE_PROCESSING;
         }
         //Is status is empty, take state
         if ($status == "") {
             $status = $order->getState();
         }
         if (false === $isShipmentSuccessfullyCreated) {
             /*
              * reload the order to avoid that unwanted order data is saved | SEE DHLIS-181
              *  Order Items are set as shipped in CE 1.3 even if there was an exception
              */
             $order = Mage::getModel('sales/order')->load($order->getId());
         }
         $order->addStatusToHistory($status, $comment)->save();
     }
 }
コード例 #5
0
ファイル: Base.php プロジェクト: xiaoguizhidao/storebaby.it
 /**
  *  Create invoice for order
  */
 protected function createInvoice(Mage_Sales_Model_Order $order)
 {
     if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
         try {
             if (!$order->canInvoice()) {
                 $order->addStatusHistoryComment('MultiSafepay: Order cannot be invoiced.', false);
                 $order->save();
                 return false;
             }
             //START Handle Invoice
             $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
             $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
             $invoice->register();
             $invoice->getOrder()->setCustomerNoteNotify(false);
             $invoice->getOrder()->setIsInProcess(true);
             $order->addStatusHistoryComment('Automatically invoiced by MultiSafepay invoicer.', false);
             $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
             $transactionSave->save();
             //END Handle Invoice
             //Send Invoice emails
             $mail_invoice = $this->getConfigData("mail_invoice");
             $send_bno_invoice = $this->getConfigData("bno_no_invoice");
             $gateway = $order->getPayment()->getMethodInstance()->_gateway;
             if ($mail_invoice && $gateway != 'PAYAFTER') {
                 $invoice->setEmailSent(true);
                 $invoice->sendEmail();
                 $invoice->save();
             } elseif ($gateway == 'PAYAFTER' && !$send_bno_invoice && $mail_invoice) {
                 $invoice->setEmailSent(true);
                 $invoice->sendEmail();
                 $invoice->save();
             }
             $order->setTotalPaid($order->getGrandTotal());
         } catch (Exception $e) {
             $order->addStatusHistoryComment('MultiSafepay invoicer: Exception occurred during the creation of the invoice. Exception message: ' . $e->getMessage(), false);
             $order->save();
         }
     }
     return false;
 }
コード例 #6
0
 /**
  * execute if transaction was refunded
  * 
  * @param SofortLib_TransactionData $transData
  * @param Mage_Sales_Model_Order $order
  * @return void
  */
 private function _transactionRefunded($transData, $order)
 {
     $payment = $order->getPayment();
     if (!$payment->getTransaction($transData->getTransaction() . '-refund')) {
         $payment->setParentTransactionId($transData->getTransaction())->setShouldCloseParentTransaction(true)->setIsTransactionClosed(0)->registerRefundNotification($transData->getAmountRefunded());
         // lastschrift by sofort
         if ($transData->isLastschrift()) {
             $refundStatus = Mage::getStoreConfig('payment/sofort/lastschriftsofort_order_status_refund');
             // Rechnung
         } else {
             $refundStatus = Mage::getStoreConfig('payment/sofort/sofortrechnung_order_status_refund');
         }
         if ($refundStatus == 'unchanged') {
             $order->addStatusHistoryComment(Mage::helper('pnsofortueberweisung')->__('The invoice has been canceled.'))->setIsVisibleOnFront(true);
         } else {
             $order->addStatusHistoryComment(Mage::helper('pnsofortueberweisung')->__('The invoice has been canceled.'), $refundStatus)->setIsVisibleOnFront(true);
         }
         $order->save();
     }
 }
コード例 #7
0
ファイル: Base.php プロジェクト: FranchuCorraliza/magento
 /**
  *  Create invoice for order
  */
 protected function createInvoice(Mage_Sales_Model_Order $order)
 {
     if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
         try {
             if (!$order->canInvoice()) {
                 $order->addStatusHistoryComment('MultiSafepay: Order cannot be invoiced.', false);
                 $order->save();
                 return false;
             }
             //START Handle Invoice
             $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
             $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
             $invoice->register();
             $invoice->getOrder()->setCustomerNoteNotify(false);
             $invoice->getOrder()->setIsInProcess(true);
             $order->addStatusHistoryComment('Automatically invoiced by MultiSafepay invoicer.', false);
             $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
             $transactionSave->save();
             $payment = $order->getPayment();
             $transaction = $payment->getTransaction($this->mspDetails['ewallet']['id']);
             if (is_object($transaction)) {
                 $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $this->transdetails);
                 $transaction->save();
             }
             if ($this->_config["updatetransaction"]) {
                 $invoiceId = $invoice->getIncrementId();
                 $msp = new MultiSafepay();
                 $msp->test = $this->_config["test_api"] == 'test';
                 $msp->merchant['account_id'] = $this->_config["account_id"];
                 $msp->merchant['site_id'] = $this->_config["site_id"];
                 $msp->merchant['site_code'] = $this->_config["secure_code"];
                 $msp->transaction['id'] = $_GET['transactionid'];
                 $msp->transaction['invoice_id'] = $invoiceId;
                 $msp->updateInvoice();
                 if ($msp->error) {
                     echo 'update trans error';
                 }
             }
             //END Handle Invoice
             //Send Invoice emails
             $mail_invoice = $this->getConfigData("mail_invoice");
             $send_bno_invoice = $this->getConfigData("bno_no_invoice");
             $gateway = $order->getPayment()->getMethodInstance()->_gateway;
             if ($mail_invoice && $gateway != 'PAYAFTER' && $gateway != 'KLARNA') {
                 $invoice->setEmailSent(true);
                 $invoice->sendEmail();
                 $invoice->save();
             } elseif (($gateway == 'PAYAFTER' || $gateway == 'KLARNA') && $send_bno_invoice && $mail_invoice) {
                 $invoice->setEmailSent(true);
                 $invoice->sendEmail();
                 $invoice->save();
             }
             $order->setTotalPaid($order->getGrandTotal());
         } catch (Exception $e) {
             $order->addStatusHistoryComment('MultiSafepay invoicer: Exception occurred during the creation of the invoice. Exception message: ' . $e->getMessage(), false);
             $order->save();
         }
     }
     return false;
 }
コード例 #8
0
ファイル: Order.php プロジェクト: roshu1980/add-computers
 /**
  * checks if the order's state is valid for the according Barclaycard's status. If not the order's state is reset
  * to it's previous state
  *
  * @param Mage_Sales_Model_Order $order
  *
  * @return $this
  */
 public function checkForOpsStateOnStatusUpdate(Mage_Sales_Model_Order $order)
 {
     $opsStatus = $order->getPayment()->getAdditionalInformation('status');
     $opsOrderStates = $this->getStatusMappingModel()->getStatusForOpsStatus($opsStatus);
     $origData = $order->getOrigData();
     if (0 < count($opsOrderStates) && !in_array($order->getStatus(), $opsOrderStates)) {
         $comment = $this->getDataHelper()->__('revert state update to it\'s original one because of Barclaycard\'s state restriction');
         $order->addStatusHistoryComment($comment, $origData['status']);
     }
     return $this;
 }
コード例 #9
0
 /**
  * Add risk dispute to order comment
  *
  * @param \PayPal\Api\WebhookEvent $webhookEvent
  */
 protected function riskDisputeCreated(\PayPal\Api\WebhookEvent $webhookEvent)
 {
     //Add IPN comment about registered dispute
     $this->_order->addStatusHistoryComment($webhookEvent->getSummary())->setIsCustomerNotified(false)->save();
 }
コード例 #10
0
ファイル: Order.php プロジェクト: buttasg/cowgirlk
 /**
  * Print comments inside order
  *
  * @param Mage_Sales_Model_Order $order
  * @param ShopgateOrder          $shopgateOrder
  * @return mixed
  */
 public function printCustomFieldComments($order, $shopgateOrder)
 {
     if (Mage::getStoreConfig(Shopgate_Framework_Model_Config::XML_PATH_SHOPGATE_ORDER_CUSTOMFIELDS_TO_STATUSHISTORY, Mage::helper('shopgate/config')->getConfig()->getStoreViewId())) {
         $comment = '';
         $customFieldSet = array($this->_getHelper()->__('[SHOPGATE] Custom fields:') => $shopgateOrder->getCustomFields(), $this->_getHelper()->__('Shipping Address fields:') => $shopgateOrder->getDeliveryAddress()->getCustomFields(), $this->_getHelper()->__('Billing Address fields:') => $shopgateOrder->getInvoiceAddress()->getCustomFields());
         foreach ($customFieldSet as $title => $set) {
             $comment .= '<strong>' . $title . '</strong><br/>';
             foreach ($set as $field) {
                 $comment .= '"' . addslashes($field->getLabel()) . '" => "' . addslashes($field->getValue()) . '"<br />';
             }
         }
         $order->addStatusHistoryComment($comment, false);
     }
     return $order;
 }
コード例 #11
0
ファイル: Plugin.php プロジェクト: buttasg/cowgirlk
 /**
  * @param Mage_Sales_Model_Order $order
  * @param ShopgateOrder          $shopgateOrder
  *
  * @return Mage_Sales_Model_Order
  */
 protected function _setOrderStatusHistory($order, $shopgateOrder)
 {
     $order->addStatusHistoryComment($this->_getHelper()->__("[SHOPGATE] Order added by Shopgate."), false);
     $order->addStatusHistoryComment($this->_getHelper()->__("[SHOPGATE] Shopgate order number: %s", $shopgateOrder->getOrderNumber()), false);
     Mage::helper('shopgate/import_order')->printCustomFieldComments($order, $shopgateOrder);
     return $order;
 }
コード例 #12
0
 public function urlerrorAction()
 {
     // 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("Modulo de pago - TodoPago ==> urlerror - orderid: " . $order_id);
     $answer = $this->getRequest()->get('Answer');
     Mage::log("Modulo de pago - TodoPago ==> urlerror - AnswerKey: " . $answer);
     $order = new Mage_Sales_Model_Order();
     $order->loadByIncrementId($order_id);
     if (Mage::getStoreConfig('payment/modulodepago2/modo_test_prod') == "test") {
         $order->setStatus('test_todopago_canceled');
         $order->addStatusHistoryComment("Todo Pago (TEST): error en el pago del formulario");
     } else {
         $order->setStatus(Mage::getStoreConfig('payment/todopago_avanzada/estado_denegada'));
         $order->addStatusHistoryComment("Todo Pago: error en el pago del formulario");
     }
     $order->save();
     Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure' => true));
 }
コード例 #13
0
 /**
  * @param Mage_Sales_Model_Order $order
  * @param string $comment
  * @return Mage_Sales_Model_Order_Status_History
  */
 protected function addCommentToOrder(Mage_Sales_Model_Order $order, $comment)
 {
     $comment = $this->helper()->__($comment);
     return $order->addStatusHistoryComment($comment);
 }
コード例 #14
0
 protected function processOrderNotifications(Mage_Sales_Model_Order $magentoOrder)
 {
     if ($this->getOrder()->getAccount()->isCustomerOrderNotificationEnabled()) {
         $magentoOrder->sendNewOrderEmail();
     }
     $checkoutMessage = $this->getOrder()->getData('checkout_message');
     $orderCommentsArray = $this->_proxyQuote->getOrderComments();
     if (!$checkoutMessage && !count($orderCommentsArray)) {
         return;
     }
     $comments = '<br /><b><u>' . Mage::helper('M2ePro')->__('M2E Pro Notes') . ':</u></b><br /><br />';
     if ($checkoutMessage) {
         $comments .= '<b>' . Mage::helper('M2ePro')->__('Checkout Message From Buyer') . ': </b>';
         $comments .= $checkoutMessage . '<br />';
     }
     foreach ($orderCommentsArray as $comment) {
         $comments .= $comment . '<br /><br />';
     }
     $magentoOrder->addStatusHistoryComment($comments)->save();
 }
コード例 #15
0
ファイル: Abstract.php プロジェクト: buttasg/cowgirlk
 /**
  * Generic order manipulation, taken originally from Plugin::_setOrderPayment()
  *
  * @param Mage_Sales_Model_Order $magentoOrder
  *
  * @return Mage_Sales_Model_Order
  */
 public function manipulateOrderWithPaymentData($magentoOrder)
 {
     $shopgateOrder = $this->getShopgateOrder();
     if ($shopgateOrder->getIsPaid()) {
         if ($magentoOrder->getBaseTotalDue()) {
             $magentoOrder->getPayment()->setShouldCloseParentTransaction(true);
             $magentoOrder->getPayment()->registerCaptureNotification($shopgateOrder->getAmountComplete());
             $magentoOrder->addStatusHistoryComment($this->_getHelper()->__("[SHOPGATE] Payment received."), false)->setIsCustomerNotified(false);
         }
     }
     $magentoOrder->getPayment()->setLastTransId($shopgateOrder->getPaymentTransactionNumber());
     return $magentoOrder;
 }
コード例 #16
0
 /**
  * @param Mage_Sales_Model_Order $order
  * @param string                 $status
  *
  * @return string
  *
  * @throws Exception
  */
 public function processOrderStatus(Mage_Sales_Model_Order $order, $status, $transactionId = null, $processType = null)
 {
     if (empty($status)) {
         /** @var Mage_Sales_Model_Order_Status_History $history */
         $message = $this->_helper()->__('Status sent is empty and will bot be processed.');
         $history = $order->addStatusHistoryComment($message);
         $history->save();
         return self::REDIRECT_STATE;
     }
     $processLabel = $this->_getProcessTypeLabel($processType);
     /** @var Mage_Sales_Model_Order_Status_History $history */
     $history = $order->addStatusHistoryComment($this->_helper()->__('Order Status Change by %s Process from ClickPag: %s.', $processLabel, $status));
     $history->save();
     $result = null;
     try {
         switch ($status) {
             case Rede_ClickPag_Model_Api::STATUS_APPROVED:
                 if (!$order->canInvoice()) {
                     return self::REDIRECT_STATE;
                 }
                 /** @var Mage_Sales_Model_Order_Invoice $invoice */
                 $invoice = $this->_initInvoice($order);
                 $message = $this->_helper()->__('Order Invoiced By %s Process From ClickPag.', $processLabel);
                 if ($invoice) {
                     $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE)->setTransactionId($transactionId)->addComment($message)->register()->sendEmail(true);
                 }
                 /**
                  * @var string                        $orderState
                  * @var string                        $orderStatus
                  * @var Mage_Sales_Model_Order_Status $statusModel
                  */
                 $orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
                 $statusModel = Mage::getModel('sales/order_status')->loadDefaultByState($orderState);
                 $orderStatus = $statusModel->getStatus() ? $statusModel->getStatus() : $orderState;
                 $order->setIsInProcess(true);
                 $order->setStatus($orderStatus);
                 /** @var Mage_Sales_Model_Order_Status_History $history */
                 $history = $order->addStatusHistoryComment($message);
                 $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($order)->addObject($history);
                 $transactionSave->save();
                 $result = self::REDIRECT_SUCCESS;
                 break;
             case Rede_ClickPag_Model_Api::STATUS_REVERSED:
                 if (!$order->canCreditmemo()) {
                     return self::REDIRECT_REVERSED;
                 }
                 $message = $this->_helper()->__('Order Refunded By %s Process From ClickPag.', $processLabel);
                 /** @var Mage_Sales_Model_Resource_Order_Invoice_Collection $invoiceCollection */
                 $invoiceCollection = $order->getInvoiceCollection();
                 /** @var Mage_Sales_Model_Service_Order $service */
                 $service = Mage::getModel('sales/service_order', $order);
                 /** @var Mage_Core_Model_Resource_Transaction $transaction */
                 $transaction = Mage::getModel('core/resource_transaction');
                 foreach ($invoiceCollection as $invoice) {
                     $invoice->addComment($message);
                     /** @var Mage_Sales_Model_Order_Creditmemo $creditmemo */
                     $creditmemo = $service->prepareInvoiceCreditmemo($invoice);
                     $creditmemo->setOfflineRequested(true);
                     $creditmemo->setTransactionId($invoice->getTransactionId());
                     $creditmemo->addComment($message);
                     $creditmemo->register();
                     foreach ($creditmemo->getAllItems() as $creditmemoItems) {
                         /**
                          * @var  $creditmemoItems
                          * @var  $orderItem
                          */
                         $orderItem = $creditmemoItems->getOrderItem();
                         if (!$orderItem->getParentItemId()) {
                             $orderItem->setBackToStock(true);
                         }
                     }
                     $transaction->addObject($invoice);
                     $transaction->addObject($creditmemo);
                 }
                 /** @var Mage_Sales_Model_Order_Status_History $history */
                 $history = $order->addStatusHistoryComment($message);
                 $transaction->addObject($history);
                 $transaction->addObject($order);
                 $transaction->save();
                 $result = self::REDIRECT_REVERSED;
                 break;
             case Rede_ClickPag_Model_Api::STATUS_DENIED:
                 if (!$order->canCancel()) {
                     return self::REDIRECT_DENIED;
                 }
                 $message = $this->_helper()->__('Order Canceled By %s Process From ClickPag.', $processLabel);
                 $order->getPayment()->cancel();
                 $order->registerCancellation($message);
                 Mage::dispatchEvent('order_cancel_after', array('order' => $this));
                 $order->save();
                 $result = self::REDIRECT_DENIED;
                 break;
             case Rede_ClickPag_Model_Api::STATUS_IN_DISPUTE:
             case Rede_ClickPag_Model_Api::STATUS_IN_ANALISYS:
             case Rede_ClickPag_Model_Api::STATUS_CHARGEBACK:
                 $result = self::REDIRECT_STATE;
                 break;
             case self::STATUS_ERROR:
             default:
                 if (!$order->canCancel()) {
                     return self::REDIRECT_STATE;
                 }
                 $message = $this->_helper()->__('Canceling order. Error when trying to process the order payment.');
                 $order->getPayment()->cancel();
                 $order->registerCancellation($message);
                 Mage::dispatchEvent('order_cancel_after', array('order' => $this));
                 $order->save();
                 $result = self::REDIRECT_ERROR;
                 break;
         }
     } catch (Exception $e) {
         Mage::logException($e);
         $result = self::REDIRECT_STATE;
     }
     return $result;
 }