/** * Poll the API for the status of the Refund Request, and continue * once the status has been updated * Throw an error if the status is not equal to OPEN * * @param string $amazonRefundReferenceId * refund transaction to query * * @return No value */ private function _waitForProviderCreditReversalSummaryList($amazonRefundReferenceId) { $response = null; $providerCreditReversalSummaryList = null; $maxSleepTime = 60; while (is_null($providerCreditReversalSummaryList) && $maxSleepTime > 0) { sleep(5); $maxSleepTime -= 5; $response = $this->callStepAndCheckForException('getRefundDetails', array($amazonRefundReferenceId)); $providerCreditReversalSummaryList = $response->getGetRefundDetailsResult()->getRefundDetails()->getProviderCreditReversalSummaryList(); } printGetRefundDetailsResponse($response); validateThatRefundIsCompleted($response->getGetRefundDetailsResult()->getRefundDetails()); if (is_null($providerCreditReversalSummaryList)) { throw new ErrorException("No providerCreditReversalSummaryList found in getRefundDetails response"); } return $providerCreditReversalSummaryList; }
/** * Poll the API for the status of the Refund Request, and continue * once the status has been updated * Throw an error if the status is not equal to OPEN * * @param string $amazonRefundReferenceId * refund transaction to query * * @return No value */ private function _waitUntilRefundProcessingIsCompleted($amazonRefundReferenceId) { // Check for the presence of the ipn notification $this->waitForNotificationToBeProcessedBeforeContinuing($amazonRefundReferenceId, "RefundNotification"); $response = null; $providerCreditReversalSummaryList = null; $maxSleepTime = 60; while (is_null($providerCreditReversalSummaryList) && $maxSleepTime > 0) { sleep(5); $maxSleepTime -= 5; $response = $this->callStepAndCheckForException('getRefundDetails', array($amazonRefundReferenceId)); $providerCreditReversalSummaryList = $response->getGetRefundDetailsResult()->getRefundDetails()->getProviderCreditReversalSummaryList(); } validateThatRefundIsCompleted($response->getGetRefundDetailsResult()->getRefundDetails()); $this->printResponseToWebpage("printGetRefundDetailsResponse", array($response)); if (is_null($providerCreditReversalSummaryList)) { throw new ErrorException("No providerCreditReversalSummaryList found in getRefundDetails response"); } return $providerCreditReversalSummaryList; }
/** * Poll the API for the status of the Refund Request, and continue * once the status has been updated * Throw an error if the status is not equal to OPEN * * @param string $amazonRefundReferenceId refund transaction to query * * @return No value */ private function _waitUntilRefundProcessingIsCompleted($amazonRefundReferenceId) { $response = $this->callStepAndCheckForException('waitUntilRefundProcessingIsCompleted', array($amazonRefundReferenceId)); printGetRefundDetailsResponse($response); validateThatRefundIsCompleted($response->getGetRefundDetailsResult()->getRefundDetails()); }
/** * Check that we have received an IPN notification for the refund * * For PHP, there is an IPN handler that will write the contents of the IPN to * a file in the format of * <amazonReferenceId>_RefundNotification.txt * This method will check for the presence of this file * and will loop/timeout until the notification has been handled. * * Merchants can use alternative approaches such as memory caches, * shared memory or database storage so that scripts serving user * pages are able to check on the status of a notification * * @param string $amazonRefundId refund transaction to query * * @return void */ private function _waitUntilRefundProcessingIsCompleted($amazonRefundId) { // Check for the presence of the ipn notification $this->waitForNotificationToBeProcessedBeforeContinuing($amazonRefundId, "RefundNotification"); // Notification is present, go and get the full // information for this notification $response = $this->callStepAndCheckForException('getRefundDetails', array($amazonRefundId)); validateThatRefundIsCompleted($response->getGetRefundDetailsResult()->getRefundDetails()); echo $this->printResponseToWebpage("printGetRefundDetailsResponse", array($response)); }