Ejemplo n.º 1
0
 private function processOrder(Ess_M2ePro_Model_Order $order)
 {
     if ($order->getChildObject()->isPaymentCompleted()) {
         // unpaid order became paid
         // immediately created magento order should be canceled
         // and new magento order should be created instead
         if ($order->canCancelMagentoOrder()) {
             $message = 'Payment Status was updated to Paid on eBay. ' . 'As Magento Order #%order_id% can have wrong data, it have to be cancelled.';
             $order->addWarningLog($message, array('!order_id' => $order->getMagentoOrder()->getRealOrderId()));
             try {
                 $order->cancelMagentoOrder();
                 $this->totalCanceledMagentoOrders++;
             } catch (Exception $e) {
                 // magento order was not cancelled
                 // do not create new magento order to prevent oversell
                 return;
             }
         }
         $this->clearOrder($order);
         $this->createMagentoOrder($order);
     } else {
         // unpaid order did not become paid
         // immediately created magento order should be canceled
         // and unpaid item process should be opened for each order item
         if ($order->canCancelMagentoOrder()) {
             $message = 'Payment Status was not updated to Paid. Magento Order #%order_id% ' . 'have to be cancelled according to Account\'s Automatic Cancellation setting.';
             $order->addWarningLog($message, array('!order_id' => $order->getMagentoOrder()->getRealOrderId()));
             try {
                 $order->cancelMagentoOrder();
                 $this->totalCanceledMagentoOrders++;
             } catch (Exception $e) {
             }
         }
         $this->openUnpaidItemProcess($order);
     }
 }