protected function copyShipFromAddressTo(Mage_Customer_Model_Address_Abstract $address, EbayEnterprise_Inventory_Model_Details_Item $detail)
 {
     if ($detail->isAvailable()) {
         $meta = ['sku' => $detail->getSku(), 'item_id' => $detail->getItemId()];
         $this->logger->debug('applying details for item "{sku}" [{item_id}]', $this->logContext->getMetaData(__CLASS__, $meta));
         $address->addData($this->exportShipFromAddress($detail));
     }
 }
 /**
  * get allocation information for an item
  *
  * @param  Mage_Sales_Model_Order_Item
  * @return EbayEnterprise_Inventory_Model_Allocation|null
  */
 public function getItemAllocationInformation(Mage_Sales_Model_Order_Item $item)
 {
     $result = $this->getInventorySession()->getAllocationResult();
     if ($result) {
         return $result->lookupAllocationByItemId($item->getQuoteItemId());
     }
     $this->logger->debug('Unable to get allocation information for item {sku} id {item_id}', $this->logContext->getMetaData(__CLASS__, ['sku' => $item->getSku(), 'item_id' => $item->getQuoteItemId()]));
     return null;
 }
 /**
  * attempt to do an inventory detail operation
  *
  * @param Mage_Sales_Model_Quote
  * @return EbayEnterprise_Inventory_Model_Details_Result
  */
 protected function tryOperation(Mage_Sales_Model_Quote $quote)
 {
     $logger = $this->logger;
     $logContext = $this->logContext;
     try {
         $api = $this->prepareApi();
         $request = $this->prepareRequest($api, $quote);
         if (count($request->getItems())) {
             $this->logger->debug('Trying inventory details operation', $this->logContext->getMetaData(__CLASS__));
             $api->send();
         }
         return $this->prepareResult($api);
     } catch (InvalidPayload $e) {
         $logger->warning('Invalid payload for inventory details. See exception log for more details.', $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()]));
         $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e));
     } catch (NetworkError $e) {
         $logger->warning('Caught a network error sending the inventory details request. See exception log for more details.', $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()]));
         $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e));
     } catch (UnsupportedOperation $e) {
         $logger->critical('The inventory details operation is unsupported in current configuration. See exception log for more details.', $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()]));
         $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e));
     } catch (UnsupportedHttpAction $e) {
         $logger->critical('The inventory details operation is configured with an unsupported HTTP action. See exception log for more details.', $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()]));
         $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e));
     }
     // if we got here there was a problem
     throw Mage::exception('EbayEnterprise_Inventory_Exception_Details_Operation', 'Failed to fetch inventory details');
 }
 /**
  * Update session data with a new quote object. Method should get a diff of the
  * current/old quote data and diff it with the new quote data. This data should
  * then be used to update flags as needed. Finally, the new data should replace
  * existing data.
  * @param  Mage_Sales_Model_Quote $quote New quote object
  * @return self
  */
 public function updateWithQuote(Mage_Sales_Model_Quote $quote)
 {
     $oldData = $this->getCurrentQuoteData();
     $newData = $this->_extractQuoteData($quote);
     // Copy over the last_updated timestamp from the old quote data. This will
     // persist the timestamp from one set of data to the next preventing
     // the new data from auto expiring.
     $newData['last_updated'] = $oldData['last_updated'];
     $this->_logger->debug('Comparing quote data', $this->_context->getMetaData(__CLASS__, ['old' => json_encode($oldData), 'new' => json_encode($newData)]));
     $quoteDiff = $this->_diffQuoteData($oldData, $newData);
     // if nothing has changed in the quote, no need to update flags, or
     // quote data as none of them will change
     if (!empty($quoteDiff)) {
         $changes = implode(', ', array_keys($quoteDiff));
         $logData = ['changes' => $changes, 'diff' => json_encode($quoteDiff)];
         $logMessage = 'Changes found in quote for: {changes}';
         $this->_logger->debug($logMessage, $this->_context->getMetaData(__CLASS__, $logData));
         $this->setTaxUpdateRequiredFlag($this->_changeRequiresTaxUpdate($newData, $quoteDiff))->setDetailsUpdateRequiredFlag($this->_changeRequiresDetailsUpdate($newData, $quoteDiff))->setCurrentQuoteData($newData);
     } else {
         $this->_logger->debug('No changes in quote.', $this->_context->getMetaData(__CLASS__));
     }
     // always update the changes - could go from having changes to no changes
     $this->setQuoteChanges($quoteDiff);
     return $this;
 }
 /**
  * Process the file - making necessary deletes and adds/updates.
  * @param EbayEnterprise_Catalog_Interface_Import_Config $config
  *        is a concrete class that implement the interface class and implement
  *        the method getImportConfigData which will return an array of key/value pair
  *        of configuration specific to the feed running this method
  * @param EbayEnterprise_Catalog_Interface_Import_Items $items
  *        is a concrete class that implements this interface class that has two
  *        methods ('buildCollection', and 'createNewItem')
  * @return self
  */
 public function process(EbayEnterprise_Catalog_Interface_Import_Config $config, EbayEnterprise_Catalog_Interface_Import_Items $items)
 {
     $cfgData = $config->getImportConfigData();
     $skusToReport = array();
     $this->_removeItemsFromWebsites($cfgData, $items);
     $siteFilters = $this->_helper->loadStoreviewFilters();
     $processedWebsites = array();
     foreach ($siteFilters as $siteFilter) {
         $this->_logger->debug('Importing products into storeview: {mage_store_id}', $this->_context->getMetaData(__CLASS__, $siteFilter));
         $this->_importedSkus = array();
         if (!in_array($siteFilter['mage_website_id'], $processedWebsites)) {
             // prevent treating each store view as a website
             $this->_processWebsite($siteFilter, $cfgData, $items);
             $processedWebsites[] = $siteFilter['mage_website_id'];
         }
         $this->_processTranslations($siteFilter, $cfgData, $items);
         $skusToReport = array_unique(array_merge($skusToReport, $this->_importedSkus));
     }
     $details = ['feed_detail' => $this->_feedDetails, 'skus' => $skusToReport, 'operation_type' => 'import'];
     if (count($skusToReport) && $cfgData['feed_type'] === 'product') {
         Mage::dispatchEvent('product_feed_process_operation_type_error_confirmation', $details);
     }
     Mage::dispatchEvent('ebayenterprise_product_feed_process_complete', $details);
     return $this;
 }
 /**
  * Log the different requests consistently.
  *
  * @param string $type 'do authorization', 'do express', 'do void', 'get express', 'set express'
  * @param string $body the serialized xml body
  * @param string $direction 'request' or 'response'
  */
 protected function logApiCall($type, $body, $direction)
 {
     $logData = ['type' => $type, 'direction' => $direction];
     $logMessage = 'Processing PayPal {type} {direction}';
     $this->logger->info($logMessage, $this->logContext->getMetaData(__CLASS__, $logData));
     $logData = ['rom_request_body' => $body];
     $logMessage = 'Request Data';
     $this->logger->debug($logMessage, $this->logContext->getMetaData(__CLASS__, $logData));
 }
 /**
  * Retry order create requests on unsubmitted orders.
  * Run this on cron.
  *
  * @return void
  */
 public function handleEbayEnterpriseOrderCreateRetryJob()
 {
     $orders = $this->getUnsubmittedOrders();
     $this->logger->debug('Found {order_retry_count} order(s) to be resubmitted.', $this->logContext->getMetaData(__CLASS__, ['order_retry_count' => $orders->getSize()]));
     $api = $this->coreHelper->getSdkApi($this->orderCfg->apiService, $this->orderCfg->apiCreateOperation);
     $createArgs = ['api' => $api, 'config' => $this->orderCfg, 'payload' => $api->getRequestBody(), 'is_payload_prebuilt' => true];
     foreach ($orders as $order) {
         $this->resubmit($order, $createArgs);
     }
     $this->logger->debug('Order retry complete.', $this->logContext->getMetaData(__CLASS__));
 }
 /**
  * Log any unexpected behavior that may indicate issues in the request
  * or the address validation provider.
  *
  * @return self
  */
 protected function logResultCode()
 {
     $resultCode = $this->getResultCode();
     $message = $this->nullCoalesce($this->resultCodeWarningMap, $resultCode, 'Response message did not contain a known result code. Result Code: {result_code}');
     if ($message) {
         $this->logger->warning($message, $this->getMetaData($resultCode));
     }
     $logData = ['result_code' => $resultCode, 'validation' => $this->isAddressValid() ? 'valid' : 'invalid'];
     $logMessage = 'Response with status code "{result_code}" is {validation}.';
     $this->logger->debug($logMessage, $this->context->getMetaData(__CLASS__, $logData));
     return $this;
 }
 /**
  * add a giftcard.
  *
  * @param string $cardNumber
  * @param string $pin
  * @return self
  */
 protected function addGiftCard($cardNumber, $pin)
 {
     $giftcard = $this->container->getGiftCard($cardNumber)->setPin($pin);
     try {
         $this->helper->addGiftCardToOrder($giftcard, $this->container);
         $this->getSession()->addSuccess($this->helper->__(EbayEnterprise_GiftCard_Helper_Data::GIFT_CARD_ADD_SUCCESS, $cardNumber));
     } catch (EbayEnterprise_GiftCard_Exception $e) {
         $this->getSession()->addError($this->helper->__($e->getMessage()));
         $this->logger->debug('Failed to add gift card to admin order. See exception log for more details.', $this->logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()]));
         $this->logger->logException($e, $this->logContext->getMetaData(__CLASS__, [], $e));
     }
     return $this;
 }
 /**
  * Retry order create requests on unsubmitted orders.
  * Run this on cron.
  *
  * @return void
  */
 public function handleEbayEnterpriseOrderCreateRetryJob()
 {
     $logMeta = $this->logContext->getMetaData(__CLASS__);
     $this->logger->debug('Order retry start.', $logMeta);
     $orders = $this->getUnsubmittedOrders();
     $numOrders = $orders->getSize();
     if ($numOrders > 0) {
         $this->logger->warning('Found {order_retry_count} order(s) to be resubmitted.', $this->logContext->getMetaData(__CLASS__, ['order_retry_count' => $numOrders]));
     }
     foreach ($orders as $order) {
         $this->resubmit($order);
     }
     $this->logger->debug('Order retry complete.', $logMeta);
 }
 /**
  * Log request and response of stored value various service API calls.
  *
  * @param Api\IBidirectionalApi
  * @param bool
  * @param string
  */
 protected function _logStoredValuePayload(Api\IBidirectionalApi $api, $isRequest, $logMessage)
 {
     /** @var string */
     $method = 'getRequestBody';
     /** @var string */
     $metaDataKey = 'rom_request_body';
     if (!$isRequest) {
         $method = 'getResponseBody';
         $metaDataKey = 'rom_response_body';
     }
     /** @var string */
     $cleanedXml = $this->_mask->maskXmlNodes($api->{$method}()->serialize());
     $this->_logger->debug($logMessage, $this->_context->getMetaData(__CLASS__, [$metaDataKey => $cleanedXml]));
     return $this;
 }
 /**
  * fill out the request payload to send
  *
  * @param IBidirectionalApi
  * @param EbayEnterprise_Inventory_Model_Allocation_Item_Selector
  * @return self
  */
 protected function prepareRequest(IBidirectionalApi $api, EbayEnterprise_Inventory_Model_Allocation_Item_Selector $selector)
 {
     $this->logger->debug('Building inventory allocation request reservation id {reservation_id}', $this->logContext->getMetaData(__CLASS__, ['reservation_id' => $this->reservation->getId()]));
     try {
         $request = $api->getRequestBody();
         $builder = $this->createRequestBuilder($request, $selector, $this->reservation);
         $builder->buildOutRequest();
         $api->setRequestBody($request);
         return $this;
     } catch (UnsupportedOperation $e) {
         $this->logger->critical('The inventory allocation operation is unsupported in the current configuration. See exception log for more details.', $this->logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()]));
         $this->logger->logException($e, $this->logContext->getMetaData(__CLASS__, [], $e));
     }
     $this->handleAllocationFailure();
 }
 /**
  * Update the address totals with tax amounts.
  *
  * @param Mage_Sales_Model_Quote_Address
  * @return self
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     // Necessary for inherited `self::_setAmount` and `self::_setBaseAmount` to behave.
     $this->_setAddress($address);
     $addressId = $address->getId();
     $taxTotal = $this->_totalTaxRecordsCalculatedTaxes($this->_taxCollector->getTaxRecordsByAddressId($addressId));
     $dutyTotal = $this->_totalDuties($this->_taxCollector->getTaxDutiesByAddressId($addressId));
     $feeTotal = $this->_totalFees($this->_taxCollector->getTaxFeesByAddressId($addressId));
     $total = $taxTotal + $dutyTotal + $feeTotal;
     $this->_logger->debug("Collected tax totals of: tax - {$taxTotal}, duty - {$dutyTotal}, fee - {$feeTotal}, total - {$total}.", $this->_logContext->getMetaData(__CLASS__));
     // Always overwrite amounts for this total. The total calculated from
     // the collector's tax records will be the complete tax amount for
     // the address.
     $this->_setAmount($total)->_setBaseAmount($total);
     return $this;
 }
 /**
  * Check the inventory status of each item in the quote. Will add errors
  * to the quote and items if any are not currently available at the
  * requested quantity. Will throw an exception if any item not yet added
  * to the quote should be prevented from being added.
  *
  * @param Mage_Sales_Model_Quote
  * @return self
  * @throws EbayEnterprise_Inventory_Exception_Quantity_Unavailable_Exception If any items should not be added to the quote.
  */
 public function checkQuoteInventory(Mage_Sales_Model_Quote $quote)
 {
     $inventoryItems = $this->_inventoryItemSelection->selectFrom($quote->getAllItems());
     if (empty($inventoryItems)) {
         $this->_logger->debug('no items to check, clearing collected quantities', $this->_logContext->getMetaData(__CLASS__));
         $this->_quantityCollector->clearResults();
     }
     foreach ($inventoryItems as $item) {
         if (!$this->isItemAvailable($item)) {
             $this->_handleUnavailableItem($item);
         } else {
             $this->_notifyCustomerIfItemBackorderable($item);
         }
     }
     return $this;
 }
 /**
  * Loads the relevant config fields of each Magento Web Site that allows us
  * to match an incoming feed to the appropriate destination.
  *
  * @TODO Should this actually return filters for every storeview or should
  * it just be websites?
  *
  * @return array of unique key/value pairs mapping an inbound feed to a Magento Web Site.
  */
 public function loadWebsiteFilters()
 {
     $allWebsites = [];
     // Default Store it has its own special configuration.
     $allWebsites[Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID] = $this->loadStoreviewConfig(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);
     foreach (Mage::app()->getWebsites() as $website) {
         foreach ($website->getGroups() as $group) {
             foreach ($group->getStores() as $store) {
                 $filter = $this->loadStoreviewConfig($store->getId());
                 $this->logger->debug('Adding filter for storeview.', $this->context->getMetaData(__CLASS__, $filter));
                 $allWebsites[$store->getId()] = $filter;
             }
         }
     }
     return $allWebsites;
 }
 /**
  * fill out the request payload to send
  *
  * @param IBidirectionalApi
  * @param EbayEnterprise_Inventory_Model_Allocation_Item_Selector
  * @return self
  */
 protected function prepareRequest(IBidirectionalApi $api, EbayEnterprise_Inventory_Model_Allocation_Item_Selector $selector)
 {
     $this->logger->debug('Building inventory allocation request reservation id {reservation_id}', $this->logContext->getMetaData(__CLASS__, ['reservation_id' => $this->reservation->getId()]));
     try {
         $request = $api->getRequestBody();
         $builder = $this->createRequestBuilder($request, $selector, $this->reservation);
         $builder->buildOutRequest();
         // rule out the possibility of exceptions from the request
         // being thrown during the send.
         $request->serialize();
         $api->setRequestBody($request);
         return $request;
     } catch (UnsupportedOperation $e) {
         $this->logger->critical('The allocation operation is unsupported by the currently configured SDK', $this->logContext->getMetaData(__CLASS__, [], $e));
     } catch (InvalidPayload $e) {
         $this->logger->error('The allocation request is invalid', $this->logContext->getMetaData(__CLASS__, [], $e));
     }
     $this->handleAllocationFailure();
 }
 /**
  * log the response and return the result of the configured handler method.
  *
  * @param  Zend_Http_Response $response
  * @param  string $uri
  * @return string response body or empty
  */
 protected function _processResponse(Zend_Http_Response $response, $uri)
 {
     $this->_status = $response->getStatus();
     $config = $this->_getHandlerConfig($this->_getHandlerKey($response));
     $logMethod = isset($config['logger']) ? $config['logger'] : 'debug';
     $logData = array_merge(['rom_request_url' => $uri], $this->_logAppContext);
     $this->_logger->{$logMethod}('Received response from.', $this->_context->getMetaData(__CLASS__, $logData));
     $responseData = $logData;
     $responseData['rom_response_body'] = $response->asString();
     $logMessage = 'Response data.';
     $this->_logger->debug($logMessage, $this->_context->getMetaData(__CLASS__, $responseData));
     if (!$response->getBody()) {
         $logMessage = "Received response with no body from {$uri} with status {$this->_status}.";
         $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__, $logData));
     }
     $callbackConfig = isset($config['callback']) ? $config['callback'] : array();
     $callbackConfig['parameters'] = array($response);
     return Mage::helper('eb2ccore')->invokeCallBack($callbackConfig);
 }
 /**
  * @see EbayEnterprise_Catalog_Model_Error_IConfirmations::process()
  */
 public function process(Varien_Event_Observer $observer)
 {
     /** @var Varien_Event */
     $event = $observer->getEvent();
     /** @var array */
     $feedDetails = (array) $event->getFeedDetails();
     foreach ($feedDetails as $detail) {
         /** @var string */
         $fileName = $detail['error_file'];
         $this->loadFile($fileName);
         // If no in-progress error file exists for the feed detail, it was
         // either never created and nothing was written to it, or it was
         // already processed. Don't attempt to process it again, move on.
         if (!$this->fileStream->isFile()) {
             $this->logger->debug('Error confirmation file does not exist: {file_name}', $this->context->getMetaData(__CLASS__, ['file_name' => $fileName]));
             continue;
         }
         // If the file exists but nothing was ever written to it, was not
         // initialized and no errors written to it, no need to send the empty
         // error file so simply remove it and move on.
         if ($this->fileStream->getSize() === 0) {
             $this->removeFile($fileName);
             $this->logger->debug('Error confirmation file is empty: {file_name}', $this->context->getMetaData(__CLASS__, ['file_name' => $fileName]));
             continue;
         }
         // If the error file exists and has had data written to it, close
         // the file - append closing XML tag.
         $this->close();
         // Ensure that only valid files are sent - may have had bad data
         // written to the file or in some other way be invalid. ProductHub
         // will be unable to do anything with invalid files and may cause
         // issues for the system if it receives any.
         if ($this->isValidPayload($fileName)) {
             $this->coreFeed->mvToLocalDirectory($fileName);
             $this->logger->debug('Sending Error confirmation File: {file_name}', $this->context->getMetaData(__CLASS__, ['file_name' => $fileName]));
         } else {
             $this->removeFile($fileName);
             $this->logger->debug('Error confirmation File: {file_name} has invalid XML', $this->context->getMetaData(__CLASS__, ['file_name' => $fileName]));
         }
     }
     return $this;
 }
 /**
  * Authorize payment abstract method
  *
  * @param Varien_Object $payment
  * @param float         $amount unused; only here to maintain signature
  * @return self
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function authorize(Varien_Object $payment, $amount)
 {
     $api = $this->_getApi($payment);
     $this->_prepareApiRequest($api, $payment);
     // Log the request instead of expecting the SDK to have logged it.
     // Allows the data to be properly scrubbed of any PII or other sensitive
     // data prior to writing the log files.
     $logMessage = 'Sending credit card auth request.';
     $cleanedRequestXml = $this->_helper->cleanAuthXml($api->getRequestBody()->serialize());
     $this->_logger->debug($logMessage, $this->_context->getMetaData(__CLASS__, ['rom_request_body' => $cleanedRequestXml]));
     $this->_sendAuthRequest($api);
     // Log the response instead of expecting the SDK to have logged it.
     // Allows the data to be properly scrubbed of any PII or other sensitive
     // data prior to writing the log files.
     $logMessage = 'Received credit card auth response.';
     $cleanedResponseXml = $this->_helper->cleanAuthXml($api->getResponseBody()->serialize());
     $this->_logger->debug($logMessage, $this->_context->getMetaData(__CLASS__, ['rom_request_body' => $cleanedResponseXml]));
     $this->_handleApiResponse($api, $payment);
     return $this;
 }
 /**
  * Collect new tax totals if necessary after collecting quote totals.
  * Tax totals collected after all other quote totals so tax totals for the
  * entire quote may be collected at one - all other totals for all other
  * addresses must have already been collected.
  *
  * If new taxes are collected, all quote totals must be recollected.
  *
  * @param Varien_Event_Observer
  * @return self
  */
 public function handleSalesQuoteCollectTotalsAfter(Varien_Event_Observer $observer)
 {
     $coreSession = $this->getCoreSession();
     if ($coreSession->isTaxUpdateRequired()) {
         /** @var Mage_Sales_Model_Quote */
         $quote = $observer->getEvent()->getQuote();
         try {
             $this->taxCollector->collectTaxes($quote);
         } catch (EbayEnterprise_Tax_Exception_Collector_InvalidQuote_Exception $e) {
             // Exception for when a quote is not yet ready for making
             // a tax request. Not an entirely uncommon situation and
             // does not necessarily indicate anything is actually wrong
             // unless the quote is expected to be valid but isn't.
             $this->logger->debug('Quote not valid for tax request.', $this->logContext->getMetaData(__CLASS__));
             return $this;
         } catch (EbayEnterprise_Tax_Exception_Collector_Exception $e) {
             // Want TDF to be non-blocking so exceptions from making the
             // request should be caught. Still need to exit here when there
             // is an exception, however, to allow the TDF to be retried
             // (don't reset update required flag) and prevent totals from being
             // recollected (nothing to update and, more imporantly, would
             // continue to loop until PHP crashes or a TDF request succeeds).
             $this->logger->warning('Tax request failed.', $this->logContext->getMetaData(__CLASS__, [], $e));
             return $this;
         }
         // After retrieving new tax records, update the session with data
         // from the quote used to make the request and reset the tax
         // update required flag as another update should not be required
         // until some other change has been detected.
         $this->logger->debug('Update session flags after tax collection.', $this->logContext->getMetaData(__CLASS__));
         $coreSession->updateWithQuote($quote)->resetTaxUpdateRequired();
         // Need to trigger a re-collection of quote totals now that taxes
         // for the quote have been retrieved. On the second pass, tax totals
         // just collected should be applied to the quote and any totals
         // dependent upon tax totals - like grand total - should update
         // to include the tax totals.
         $this->recollectTotals($quote);
     }
     return $this;
 }
 /**
  * Collect taxes for quote, making an SDK tax request if necessary.
  *
  * @param Mage_Sales_Model_Quote
  * @return self
  * @throws EbayEnterprise_Tax_Exception_Collector_Exception If TDF cannot be collected.
  */
 public function collectTaxes(Mage_Sales_Model_Quote $quote)
 {
     $this->_logger->debug('Collecting new tax data.', $this->_logContext->getMetaData(__CLASS__));
     try {
         $this->_validateQuote($quote);
         $taxResults = $this->_taxHelper->requestTaxesForQuote($quote);
     } catch (EbayEnterprise_Tax_Exception_Collector_Exception $e) {
         // If tax records needed to be updated but could be collected,
         // any previously collected taxes need to be cleared out to
         // prevent tax data that is no longer applicable to the quote
         // from being preserved. E.g. taxes for an item no longer in
         // the quote or calculated for a different shipping/billing
         // address cannot be preserved. Complexity of individually
         // pruning tax data in this case does not seem worth the
         // cost at this time.
         $this->setTaxRecords([])->setTaxDuties([])->setTaxFees([])->setTaxRequestSuccess(false);
         throw $e;
     }
     // When taxes were successfully collected,
     $this->setTaxRecords($taxResults->getTaxRecords())->setTaxDuties($taxResults->getTaxDuties())->setTaxFees($taxResults->getTaxFees())->setTaxRequestSuccess(true);
     return $this;
 }
 /**
  * Determine if an address needs to be validated
  * Some conditions, like an address being saved in the address book,
  * always require validation.
  * Others conditions, like using an address for billing address only
  * or being from the address book, indicate that validation is not required.
  * @param Mage_Customer_Model_Address_Abstract
  * @return bool
  */
 public function shouldValidateAddress(Mage_Customer_Model_Address_Abstract $address)
 {
     if ($this->_hasAddressBeenValidated($address)) {
         $logMessage = 'No validation - already validated';
         $this->_logger->debug($logMessage, $this->_context->getMetaData(__CLASS__));
         return false;
     }
     if ($this->_isCheckoutAddress($address)) {
         if ($this->_isAddressFromAddressBook($address)) {
             $logMessage = 'No validation - from address book';
             $this->_logger->debug($logMessage, $this->_context->getMetaData(__CLASS__));
             return false;
         }
         if ($this->_isAddressBeingSaved()) {
             $logMessage = 'Require validation - saving address in address book';
             $this->_logger->debug($logMessage, $this->_context->getMetaData(__CLASS__));
             return true;
         }
         if ($this->_isVirtualOrder()) {
             $logMessage = 'No validation - virtual order';
             $this->_logger->debug($logMessage, $this->_context->getMetaData(__CLASS__));
             return false;
         }
         if ($this->_isAddressBillingOnly($address)) {
             $logMessage = 'No validation - billing only';
             $this->_logger->debug($logMessage, $this->_context->getMetaData(__CLASS__));
             return false;
         }
         if ($this->_isMissingRequiredFields($address)) {
             $logMessage = 'No validation - missing required fields';
             $this->_logger->debug($logMessage, $this->_context->getMetaData(__CLASS__));
             return false;
         }
     }
     return true;
 }
 /**
  * Log the api call with sensitive information masked.
  *
  * @param ILookupRequest
  * @param string
  * @return self
  */
 protected function logRequest(ILookupRequest $request, $logMessage)
 {
     $metaData = ['rom_request_body' => $this->logMask->maskXmlNodes($request->serialize())];
     $this->logger->debug($logMessage, $this->logContext->getMetaData(__CLASS__, $metaData));
     return $this;
 }
 /**
  * @see Mage_Index_Model_Indexer::processEntityAction()
  * Stub the processEntityAction method from Mage_Index_Model_Indexer
  * to prevent any lockage.
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function processEntityAction(Varien_Object $entity, $entityType, $eventType)
 {
     $this->_logger->debug("Stubbed Indexer Skipping Reindex of {$entityType}, {$eventType}", $this->_context->getMetaData(__CLASS__));
     return $this;
 }
 /**
  * fire an event to allow populating an in store pickup payload
  * from an external source.
  *
  * @param IInStorePickUpItem
  * @param Mage_Sales_Model_Quote_Item_Abstract
  * @param Mage_Customer_Model_Address_Abstract
  */
 protected function delegateInStorePickUpItem(IInStorePickUpItem $ispuItem, Mage_Sales_Model_Quote_Item_Abstract $item, Mage_Customer_Model_Address_Abstract $address)
 {
     $this->logger->debug('preparing in-store-pickup item payload', $this->logContext->getMetaData(__CLASS__));
     Mage::dispatchEvent('ebayenterprise_inventory_instorepickup_item', ['itemPayload' => $ispuItem, 'item' => $item, 'address' => $address]);
 }
 /**
  * handle the case where there is not enough stock to allocate the
  * full amount requested
  *
  * @param EbayEnterprise_Inventory_Model_Allocation
  * @param Mage_Sales_Model_Order_Item
  * @throws EbayEnterprise_Inventory_Exception_Allocation_Availability_Exception
  */
 protected function handleInsufficientStock(Mage_Sales_Model_Order_Item $item)
 {
     $this->logger->debug('Unable to reserve desired quantity for item {sku}', $this->logContext->getMetaData(__CLASS__, ['sku' => $item->getSku()]));
     throw Mage::exception('EbayEnterprise_Inventory_Exception_Allocation_Availability', $this->invHelper->__(static::INSUFFICIENT_STOCK_MESSAGE));
 }