/**
  * Return an instance of `sales/order` when the payload have a valid customer increment id,
  * the order increment id correspond to a sales order in the Magento store, and the order in the Magento
  * store is shippable. However, if any of these conditions are not met a null value will be returned.
  * @return Mage_Sales_Model_Order | null
  */
 protected function _getOrder()
 {
     $incrementId = $this->_payload->getCustomerOrderId();
     $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
     if (!$order->getId()) {
         $logMsgOrderNotFound = "The shipment could not be added. The order (id: {$incrementId}) was not found in this Magento store.";
         $this->_logger->warning($logMsgOrderNotFound, $this->_context->getMetaData(__CLASS__));
         return null;
     }
     if (!$order->canShip()) {
         $logMsgOrderNotShippable = "Order ({$incrementId}) can not be shipped.";
         $this->_logger->warning($logMsgOrderNotShippable, $this->_context->getMetaData(__CLASS__));
         return null;
     }
     return $order;
 }
 /**
  * Taking a 'sales/order' instance and an instance of 'OrderEvents\IOrderShipped' as parameters and then adding
  * the shipment and tracking information to the 'sales/order' instance. Reconcile any discrepancies
  * by validating the expected shipment data is indeed in the Magento order; otherwise, log the
  * discrepancies.
  * @param  Mage_Sales_Model_Order $order
  * @param  OrderEvents\IOrderShipped $payload
  * @return self
  */
 public function process(Mage_Sales_Model_Order $order, OrderEvents\IOrderShipped $payload)
 {
     $orderItems = $payload->getOrderItems();
     $qtys = $this->_buildShipmentQtys($orderItems, $order->getItemsCollection());
     if (!empty($qtys)) {
         $incrementId = $order->getIncrementId();
         $shipmentId = $this->_getNewShipmentIncrementId($order);
         $shipment = $this->_addShipmentToOrder($qtys, $order)->setData('increment_id', $shipmentId);
         $this->_addTrackingToShipment($orderItems, $shipment)->_registerShipment($shipment, $incrementId)->_saveShipment($shipment, $incrementId)->_reconcileShipment($orderItems, $shipmentId, $incrementId);
     }
     return $this;
 }