public static RefundResponse RefundAction(IOffAmazonPaymentsService service, OffAmazonPaymentsServicePropertyCollection propertiesCollection, Random rng, string amazonCaptureID, string refundAmount, string providerId, string creditReversalAmountString)
        {
            //Initiate the Refund request, including SellerId, CaptureId, RefundReferenceId and RefundAmount
            RefundRequest request = new RefundRequest();

            request.SellerId          = propertiesCollection.MerchantID;
            request.AmazonCaptureId   = amazonCaptureID;
            request.RefundReferenceId = amazonCaptureID.Replace("-", "") + "r" + rng.Next(1, 1000).ToString();

            //assign the refundAmount to the refund request
            Price price = new Price();

            price.Amount         = refundAmount;
            price.CurrencyCode   = propertiesCollection.CurrencyCode;
            request.RefundAmount = price;
            if (!String.IsNullOrEmpty(providerId) && !String.IsNullOrEmpty(creditReversalAmountString))
            {
                ProviderCreditReversal providerCreditReversal = new ProviderCreditReversal();
                providerCreditReversal.ProviderId = providerId;
                Price creditReversalAmount = new Price();
                creditReversalAmount.Amount                 = creditReversalAmountString;
                creditReversalAmount.CurrencyCode           = propertiesCollection.CurrencyCode;
                providerCreditReversal.CreditReversalAmount = creditReversalAmount;
                ProviderCreditReversalList providerCreditReversalList = new ProviderCreditReversalList();
                providerCreditReversalList.member = new List <ProviderCreditReversal>();
                providerCreditReversalList.member.Add(providerCreditReversal);
                request.ProviderCreditReversalList = providerCreditReversalList;
            }
            return(RefundSample.InvokeRefund(service, request));
        }
 //Invoke the Refund method
 public RefundResponse RefundAction(string amazonCaptureID, string refundAmount)
 {
     return(RefundSample.RefundAction(_service, this._propertiesCollection, this._rng, amazonCaptureID, refundAmount, null, null));
 }
 //Use a loop to check the status of the refund. Once the status is not "PENDING", it returns the response.
 public GetRefundDetailsResponse CheckRefundStatus(RefundResponse refundResponse)
 {
     return(RefundSample.CheckRefundStatus(refundResponse.RefundResult.RefundDetails.AmazonRefundId, this._service, this._propertiesCollection));
 }
 //Invoke the Refund method with Provider Credit Reversal
 public RefundResponse RefundActionWithProviderCreditReversal(string amazonCaptureID, string refundAmount, string providerId, string creditReversalAmountString)
 {
     return(RefundSample.RefundAction(this._service, this._propertiesCollection, this._rng, amazonCaptureID, refundAmount, providerId, creditReversalAmountString));
 }