/** * Function to get the status of the feed submitted through MWS identified by * ReferenceID returned when feed was submitted. * @param referenceId string * @returns true: if the feed's processing was successful * false: if the feed's processing was pending/unsuccessful with errors * Added for checking the status of the submitted requests (used by polling) */ public function getRequestStatus($referenceId) { $country = Mage::getStoreConfig('payment/amazonpayments_cba/country'); if ($country == "US") { $serviceUrl = Mage::getStoreConfig('payment/amazonpayments_cba/mws_service_url_US'); $marketplace_id = Mage::getStoreConfig('payment/amazonpayments_cba/marketplace_id_US'); } elseif ($country == "UK") { $serviceUrl = Mage::getStoreConfig('payment/amazonpayments_cba/mws_service_url_UK'); $marketplace_id = Mage::getStoreConfig('payment/amazonpayments_cba/marketplace_id_UK'); } elseif ($country == "DE") { $serviceUrl = Mage::getStoreConfig('payment/amazonpayments_cba/mws_service_url_DE'); $marketplace_id = Mage::getStoreConfig('payment/amazonpayments_cba/marketplace_id_DE'); } Mage::log("In getStatusRequest:"); $application_name = 'Magento CBA Plugin'; $application_version = Mage::getVersion(); $merchant_id = Mage::getStoreConfig('payment/amazonpayments_cba/merchant_id'); $config = array('ServiceURL' => $serviceUrl, 'ProxyHost' => null, 'ProxyPort' => -1, 'MaxErrorRetry' => 3); /************************************************************************ * Instantiate Implementation of MarketplaceWebService * * AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY constants * are defined in the .config.inc.php located in the same * directory as this sample ***********************************************************************/ $service = new MarketplaceWebService_Client($this->getMwsAccessKey(), $this->getMwsSecretKey(), $config, $application_name, $application_version); $feedHandle = @fopen('php://memory', 'rw+'); $parameters = array('Marketplace' => $marketplace_id, 'Merchant' => $merchant_id, 'FeedSubmissionId' => $referenceId, 'FeedSubmissionResult' => $feedHandle); $request = new MarketplaceWebService_Model_GetFeedSubmissionResultRequest($parameters); $processingStatus = false; try { $response = $service->getFeedSubmissionResult($request); } catch (MarketplaceWebService_Exception $ex) { Mage::log("Caught Exception: " . $ex->getMessage() . "\n"); Mage::log("Response Status Code: " . $ex->getStatusCode() . "\n"); Mage::log("Error Code: " . $ex->getErrorCode() . "\n"); Mage::log("Error Type: " . $ex->getErrorType() . "\n"); Mage::log("Request ID: " . $ex->getRequestId() . "\n"); Mage::log("XML: " . $ex->getXML() . "\n"); @fclose($feedHandle); return $processingStatus; //returns false in case of request still in pending status } rewind($feedHandle); $xml = simplexml_load_string(stream_get_contents($feedHandle), 'Varien_Simplexml_Element'); if ($xml->descend('Message/ProcessingReport/ProcessingSummary/MessagesSuccessful') == "1") { Mage::log("Success"); $processingStatus = true; //Sets status to true if and only if the feed was successfully processed } if ($processingStatus) { Mage::log("Returning the state of " . $referenceId . " !"); } @fclose($feedHandle); return $processingStatus; }