public static GetRefundDetailsResponse CheckRefundStatus(string amazonRefundId, IOffAmazonPaymentsService service, OffAmazonPaymentsServicePropertyCollection propertiesCollection) { //used to check if the refund is time-out TimeSpan startTime = DateTime.Now.TimeOfDay; GetRefundDetailsRequest refundDetailRequest = new GetRefundDetailsRequest(); refundDetailRequest.SellerId = propertiesCollection.MerchantID; refundDetailRequest.AmazonRefundId = amazonRefundId; GetRefundDetailsResponse getRefundDetailsResponse = GetRefundDetailsSample.InvokeGetRefundDetails(service, refundDetailRequest); while (getRefundDetailsResponse.IsSetGetRefundDetailsResult() && getRefundDetailsResponse.GetRefundDetailsResult.RefundDetails.RefundStatus.State.Equals(PaymentStatus.PENDING)) { if (DateTime.Now.TimeOfDay.Milliseconds - startTime.Milliseconds > 60000) { throw new OffAmazonPaymentsServiceException("The refund has timed-out."); } System.Threading.Thread.Sleep(8000); Console.WriteLine("Waiting until the Refund Status changes from PENDING"); getRefundDetailsResponse = GetRefundDetailsSample.InvokeGetRefundDetails(service, refundDetailRequest); } return(getRefundDetailsResponse); }
public static GetRefundDetailsResponse InvokeGetRefundDetails(IOffAmazonPaymentsService service, GetRefundDetailsRequest request) { GetRefundDetailsResponse response = null; try { response = service.GetRefundDetails(request); Console.WriteLine("Service Response"); Console.WriteLine("============================================================================="); Console.WriteLine(); Console.WriteLine(" GetRefundDetailsResponse"); if (response.IsSetGetRefundDetailsResult()) { Console.WriteLine(" GetRefundDetailsResult"); GetRefundDetailsResult getRefundDetailsResult = response.GetRefundDetailsResult; if (getRefundDetailsResult.IsSetRefundDetails()) { Console.WriteLine(" RefundDetails"); RefundDetails refundDetails = getRefundDetailsResult.RefundDetails; if (refundDetails.IsSetAmazonRefundId()) { Console.WriteLine(" AmazonRefundId"); Console.WriteLine(" {0}", refundDetails.AmazonRefundId); } if (refundDetails.IsSetRefundReferenceId()) { Console.WriteLine(" RefundReferenceId"); Console.WriteLine(" {0}", refundDetails.RefundReferenceId); } if (refundDetails.IsSetSellerRefundNote()) { Console.WriteLine(" SellerRefundNote"); Console.WriteLine(" {0}", refundDetails.SellerRefundNote); } if (refundDetails.IsSetRefundType()) { Console.WriteLine(" RefundType"); Console.WriteLine(" {0}", refundDetails.RefundType); } if (refundDetails.IsSetFeeRefunded()) { Console.WriteLine(" FeeRefunded"); Price feeRefunded = refundDetails.FeeRefunded; if (feeRefunded.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", feeRefunded.Amount); } if (feeRefunded.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", feeRefunded.CurrencyCode); } } if (refundDetails.IsSetCreationTimestamp()) { Console.WriteLine(" CreationTimestamp"); Console.WriteLine(" {0}", refundDetails.CreationTimestamp); } if (refundDetails.IsSetRefundStatus()) { Console.WriteLine(" RefundStatus"); Status refundStatus = refundDetails.RefundStatus; if (refundStatus.IsSetState()) { Console.WriteLine(" State"); Console.WriteLine(" {0}", refundStatus.State); } if (refundStatus.IsSetLastUpdateTimestamp()) { Console.WriteLine(" LastUpdateTimestamp"); Console.WriteLine(" {0}", refundStatus.LastUpdateTimestamp); } if (refundStatus.IsSetReasonCode()) { Console.WriteLine(" ReasonCode"); Console.WriteLine(" {0}", refundStatus.ReasonCode); } if (refundStatus.IsSetReasonDescription()) { Console.WriteLine(" ReasonDescription"); Console.WriteLine(" {0}", refundStatus.ReasonDescription); } } } } if (response.IsSetResponseMetadata()) { Console.WriteLine(" ResponseMetadata"); ResponseMetadata responseMetadata = response.ResponseMetadata; if (responseMetadata.IsSetRequestId()) { Console.WriteLine(" RequestId"); Console.WriteLine(" {0}", responseMetadata.RequestId); } } } catch (OffAmazonPaymentsServiceException ex) { PrintException(ex); } return(response); }