/** * Sending the payload request and returning the response. * * @return IPayload | null */ protected function _sendRequest() { $logger = $this->_logger; $logContext = $this->_logContext; $response = null; try { $response = $this->_api->setRequestBody($this->_request)->send()->getResponseBody(); } catch (InvalidPayload $e) { $logMessage = "Invalid payload for {$this->_getPayloadName()}. See exception log for more details."; $logger->warning($logMessage, $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e)); } catch (NetworkError $e) { $logMessage = "Caught a network error sending {$this->_getPayloadName()}. See exception log for more details."; $logger->warning($logMessage, $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e)); } catch (UnsupportedOperation $e) { $logMessage = "{$this->_getPayloadName()} operation is unsupported in the current configuration. See exception log for more details."; $logger->critical($logMessage, $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e)); } catch (UnsupportedHttpAction $e) { $logMessage = "{$this->_getPayloadName()} request is configured with an unsupported HTTP action. See exception log for more details."; $logger->critical($logMessage, $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e)); } catch (Exception $e) { $logMessage = "Encountered unexpected exception sending {$this->_getPayloadName()}. See exception log for more details."; $logger->warning($logMessage, $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e)); } return $response; }
/** * Send the order create request to the api. * * @return self */ protected function _send() { Mage::dispatchEvent($this->_beforeOrderSendEvent, ['order' => $this->_order, 'payload' => $this->_payload]); try { $reply = $this->_api->setRequestBody($this->_payload)->send()->getResponseBody(); } catch (NetworkException $e) { $this->_logger->warning('Caught a network error sending order create. Will retry later.', $this->_logContext->getMetaData(__CLASS__, [], $e)); return $this; } catch (UnsupportedOperation $e) { $this->_logger->critical('[%s] Order create request saved, but not sent. See exception log.', $this->_logContext->getMetaData(__CLASS__, [], $e)); return $this; } catch (UnsupportedHttpAction $e) { $this->_logger->critical('[%s] Order create request saved, but not sent. See exception log.', $this->_logContext->getMetaData(__CLASS__, [], $e)); return $this; } catch (Exception $e) { throw $this->_logUnhandledException($e); } if ($reply->isSuccessful()) { $this->_order->setStatus(self::STATUS_SENT); Mage::dispatchEvent($this->_successfulOrderCreateEvent, ['order' => $this->_order]); } else { throw $this->_logUnhandledException(); } return $this; }
/** * Send the order create request to the api. * * @return self */ protected function _send() { Mage::dispatchEvent($this->_beforeOrderSendEvent, ['order' => $this->_order, 'payload' => $this->_payload]); $logger = $this->_logger; $logContext = $this->_logContext; try { $reply = $this->_api->setRequestBody($this->_payload)->send()->getResponseBody(); } catch (NetworkError $e) { $logger->warning('Caught a network error sending order create. See exception log for more details.', $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e)); return $this; } catch (UnsupportedOperation $e) { $logger->critical('The order create operation is unsupported in the current configuration. Order saved, but not sent. See exception log for more details.', $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e)); return $this; } catch (UnsupportedHttpAction $e) { $logger->critical('The order create operation is configured with an unsupported HTTP action. Order saved, but not sent. See exception log for more details.', $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e)); return $this; } catch (Exception $e) { throw $this->_logUnhandledException($e); } if ($reply->isSuccessful()) { $this->_order->setStatus(self::STATUS_SENT); Mage::dispatchEvent($this->_successfulOrderCreateEvent, ['order' => $this->_order]); } else { throw $this->_logUnhandledException(); } return $this; }
/** * prepare to send the request * * @param ILookupRequest * @param string * @param string * @return ILookupRequest */ protected function prepareApiForSend() { $request = $this->api->getRequestBody(); $this->buildOutRequest($request); $this->logRequest($request, 'Gift card tender type request'); $this->api->setRequestBody($request); return $request; }
/** * Sending the payload request and returning the response. * * @return IPayload | null */ protected function _sendRequest() { $response = null; try { $response = $this->_api->setRequestBody($this->_request)->send()->getResponseBody(); } catch (Exception $e) { $this->_processException($e); } return $response; }
/** * 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(); }
/** * 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(); }
/** * Prepare a request payload for the API to validate the address. * * @param Mage_Customer_Model_Address_Abstract * @param IBidirectionalApi * @return \eBayEnterprise\RetailOrderManagement\Payload\Address\IValidationRequest */ protected function _prepareApiForAddressRequest(Mage_Customer_Model_Address_Abstract $address, IBidirectionalApi $api) { return $api->setRequestBody($this->_getValidationRequest($address, $api)->prepareRequest()->getRequest()); }
/** * Prepare the API request with data from the quote - fill out and set * the request payload. * * @param IBidirectionalApi * @param Mage_Sales_Model_Quote_Item_Abstract[] * @return self */ protected function _prepareRequest(IBidirectionalApi $api, array $items) { try { $requestBody = $api->getRequestBody(); } catch (UnsupportedOperation $e) { // If the SDK cannot handle sending requests to the inventory/quantity // service operation but is expected to, the SDK is likely broken. // As this would fall into the "human intervention required" // category of errors, log crit the exception. $this->_logger->critical('Inventory quantity service request unsupported by SDK.', $this->_logContext->getMetaData(__CLASS__, [], $e)); // Throw a more generic, expected exception to prevent // this from being a blocking failure. throw $this->_failQuantityCollection(); } $quantityRequest = $this->_inventoryQuantityFactory->createRequestBuilder($requestBody, $items)->getRequest(); $api->setRequestBody($quantityRequest); return $this; }
/** * Prepare an API instance for a balance request - fill out and set the * request payload with gift card data. * @param Api\IBidirectionalApi $api * @return self */ protected function _prepareApiForVoid(Api\IBidirectionalApi $api) { $this->setRedeemVoidRequestId($this->_coreHelper->generateRequestId(self::VOID_REQUST_ID_PREFIX)); $payload = $api->getRequestBody(); $payload->setRequestId($this->getRedeemVoidRequestId())->setPin($this->getPin())->setAmount($this->getAmountRedeemed())->setCurrencyCode($this->getRedeemCurrencyCode()); $this->_setPayloadPaymentContext($payload); $api->setRequestBody($payload); return $this; }
/** * prepare the request to be sent * * return IBidirectionalApi */ protected function prepareRequest(IBidirectionalApi $api, EbayEnterprise_Inventory_Model_Allocation_Reservation $reservation) { $request = $api->getRequestBody(); $request->setReservationId($reservation->getId())->setRequestId(uniqid()); $api->setRequestBody($request); return $this; }
/** * Prepare the API request with data from the quote - fill out and set * the request payload. * * @param IBidirectionalApi * @param Mage_Sales_Model_Order_Quote * @return self */ protected function _prepareRequest(IBidirectionalApi $api, Mage_Sales_Model_Quote $quote) { try { $requestBody = $api->getRequestBody(); } catch (UnsupportedOperation $e) { // If the SDK cannot handle sending requests to the tax/quote // service operation but is expected to, the SDK is likely broken. // As this would fall into the "human intervention required" // category of errors, log crit the exception. $this->logger->critical('Tax quote service request unsupported by SDK.', $this->logContext->getMetaData(__CLASS__, [], $e)); // Throw a more generic, expected exception to prevent // this from being a blocking failure. throw $this->_failTaxCollection(); } $taxRequest = $this->taxFactory->createRequestBuilderQuote($requestBody, $quote)->getTaxRequest(); $api->setRequestBody($taxRequest); return $this; }