public string GetRefundUrl(RefundRequest request)
        {
            ValidateBaseOrderRequestAndThrow(request);

            var builder = BuildBaseUrl("refund", request)
                .AddQuery("orderId", request.OrderId);

            return builder.ComputeAndAppendSha256ToUri(_token).ToString();
        }
Пример #2
0
        /// <summary>
        /// Creates the refund asynchronous.
        /// </summary>
        /// <param name="paymentId">The payment identifier.</param>
        /// <param name="refundRequest">The refund request.</param>
        /// <returns>Task&lt;RefundResponse&gt;.</returns>
        public Task <RefundResponse> CreateRefundAsync(string paymentId, RefundRequest refundRequest)
        {
            if (refundRequest.Testmode.HasValue)
            {
                ValidateApiKeyIsOauthAccesstoken();
            }

            return(_clientService.PostAsync <RefundResponse>($"payments/{paymentId}/refunds", refundRequest));
        }
        public System.Threading.Tasks.Task <RefundResponse> RefundAsync(SecurityHeaderType Security, RequestHeaderType RequestHeader, dacRefund_Input dacRefund_Input)
        {
            RefundRequest inValue = new RefundRequest();

            inValue.Security        = Security;
            inValue.RequestHeader   = RequestHeader;
            inValue.dacRefund_Input = dacRefund_Input;
            return(((RefundV02)(this)).RefundAsync(inValue));
        }
Пример #4
0
        /// <summary>
        /// 按订单申请退款
        /// </summary>
        /// <param name="out_refund_no">商户退款单号</param>
        /// <param name="out_trade_no">商户订单号</param>
        /// <param name="total_amount">订单金额(分)</param>
        /// <param name="refund_amount">退款金额(分)</param>
        /// <returns></returns>
        public ApiResult <RefundResponse> Refund(String out_refund_no, String out_trade_no, Int32 total_amount, Int32 refund_amount)
        {
            var request = new RefundRequest();

            request.out_refund_no = out_refund_no;
            request.out_trade_no  = out_trade_no;
            request.total_fee     = total_amount;
            request.refund_fee    = refund_amount;
            return(GetResponseFromAsyncTask(RefundAsync(request)));
        }
Пример #5
0
        public RefundResponse Refund(string token, decimal amount)
        {
            ValidationUtil.hasTextWithMaxLength(token, ApiConstants.TOKEN_LENGTH, "token");

            return(ExceptionHandler.Perform <RefundResponse, TransactionRefundException>(() =>
            {
                var request = new RefundRequest(token, amount);
                return _requestService.Perform <RefundResponse, TransactionRefundException>(request, Options);
            }));
        }
Пример #6
0
        public Charge RefundWithRequest(string customer_id, string charge_id, RefundRequest refund_request)
        {
            if (charge_id == null)
            {
                throw new ArgumentNullException("charge_id cannot be null");
            }
            string ep = GetEndPoint(customer_id, charge_id) + "/refund";

            return(this.httpClient.Post <Charge>(ep, refund_request));
        }
Пример #7
0
        public async void Example()
        {
#pragma warning disable 0168
            using (Client client = GetClient())
            {
                AmountOfMoney amountOfMoney = new AmountOfMoney();
                amountOfMoney.Amount       = 1L;
                amountOfMoney.CurrencyCode = "EUR";

                BankAccountIban bankAccountIban = new BankAccountIban();
                bankAccountIban.Iban = "NL53INGB0000000036";

                BankRefundMethodSpecificInput bankRefundMethodSpecificInput = new BankRefundMethodSpecificInput();
                bankRefundMethodSpecificInput.BankAccountIban = bankAccountIban;

                PersonalName name = new PersonalName();
                name.Surname = "Coyote";

                AddressPersonal address = new AddressPersonal();
                address.CountryCode = "US";
                address.Name        = name;

                ContactDetailsBase contactDetails = new ContactDetailsBase();
                contactDetails.EmailAddress     = "*****@*****.**";
                contactDetails.EmailMessageType = "html";

                RefundCustomer customer = new RefundCustomer();
                customer.Address        = address;
                customer.ContactDetails = contactDetails;

                RefundReferences refundReferences = new RefundReferences();
                refundReferences.MerchantReference = "AcmeOrder0001";

                RefundRequest body = new RefundRequest();
                body.AmountOfMoney = amountOfMoney;
                body.BankRefundMethodSpecificInput = bankRefundMethodSpecificInput;
                body.Customer         = customer;
                body.RefundDate       = "20140306";
                body.RefundReferences = refundReferences;

                try
                {
                    RefundResponse response = await client.Merchant("merchantId").Payments().Refund("paymentId", body);
                }
                catch (DeclinedRefundException e)
                {
                    HandleDeclinedRefund(e.RefundResult);
                }
                catch (ApiException e)
                {
                    HandleApiErrors(e.Errors);
                }
            }
#pragma warning restore 0168
        }
Пример #8
0
 /// <summary>
 /// 订单退款
 /// </summary>
 /// <param name="refundRequest"></param>
 /// <returns></returns>
 public bool OrderRefund(RefundRequest refundRequest)
 {
     try
     {
         return(Refund.Run(refundRequest));
     }
     catch
     {
         return(false);
     }
 }
Пример #9
0
        /// <summary>
        ///     Refund a payment (AfterPay and iDeal only).
        /// </summary>
        /// <param name="refund">A refund object.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>A refund response object.</returns>
        public async Task <RefundResponse> RefundAsync([NotNull] RefundRequest refund, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (refund == null)
            {
                throw new ArgumentNullException(nameof(refund));
            }

            const string query = "refunds/v1";

            return(await this.PostAsync <RefundResponse>(query, refund, cancellationToken).ConfigureAwait(false));
        }
Пример #10
0
        public async Task Refund(string paymentId)
        {
            PaymentResponse paymentToRefund = await GetPaymentDetails(paymentId);

            RefundRequest refundRequest = new RefundRequest()
            {
                Amount = new Amount(paymentToRefund.Amount.Currency, paymentToRefund.Amount.Value)
            };

            await _refundClient.CreateRefundAsync(paymentId, refundRequest);
        }
        /// <summary>
        ///
        /// </summary>
        ///<param name="refundRequest"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param>
        public RefundResponse Refund(RefundRequest refundRequest, ICredential credential)
        {
            IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, refundRequest.ToNVPString(string.Empty), ServiceName, "Refund", credential);

            ((PlatformAPICallPreHandler)apiCallPreHandler).SDKName    = SDKName;
            ((PlatformAPICallPreHandler)apiCallPreHandler).SDKVersion = SDKVersion;
            ((PlatformAPICallPreHandler)apiCallPreHandler).PortName   = "AdaptivePayments";

            NVPUtil util = new NVPUtil();

            return(RefundResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1));
        }
Пример #12
0
 private static RefundResponse doRefundResponse(int approved, RefundRequest request, string privateKey, string randomKey, string refundid, string errorMsg, string errorCode)
 {
     return(new RefundResponse()
     {
         approved = approved,
         errorcode = errorCode,
         errormessage = errorMsg,
         randomkey = randomKey,
         transactionid = refundid,
         signature = Md5Helper.GetMd5Hash(randomKey + privateKey + request.orderid + request.invoice + refundid)
     });
 }
Пример #13
0
        public RefundResponse Refund(RefundRequest refundRequest, string apiUrl, string secretKey)
        {
            refundRequest.SetSignature(secretKey);

            var refundResponse = RestCall <RefundResponse>(apiUrl, refundRequest, secretKey);

            if (refundResponse.Success && !refundResponse.WaitingApproval)
            {
                refundResponse.ControlSignature(secretKey, refundRequest.HashVersion);
            }
            return(refundResponse);
        }
Пример #14
0
        /// <summary>
        /// 申请退款(https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4)
        /// </summary>
        public RefundReponse Refund(RefundRequest request)
        {
            var response = new RefundReponse()
            {
                return_code = "FAI"
            };

            string requestUrl = "https://api.mch.weixin.qq.com/secapi/pay/refund";

            RefundImpl refund = new RefundImpl()
            {
                apiKey = request.apiKey
            };

            refund.Add("appid", request.appid);
            refund.Add("mch_id", request.mch_id);
            refund.Add("nonce_str", request.nonce_str);
            refund.Add("out_refund_no", request.out_refund_no);
            //refund.Add("out_trade_no", request.out_trade_no);
            refund.Add("refund_fee", Convert.ToInt32(request.refund_fee * 100).ToString());
            refund.Add("total_fee", Convert.ToInt32(request.total_fee * 100).ToString());
            refund.Add("transaction_id", request.transaction_id);
            var sign = refund.CreateMd5Sign();

            refund.Add("sign", sign);

            var data = new HttpUtils().DoPost(requestUrl, refund.ParseXML(), request.isUseCert, request.cert, request.password);
            var doc  = new XmlDocument();

            doc.LoadXml(data);

            XmlNode xmlNode = doc.DocumentElement;

            if (xmlNode != null)
            {
                response.return_code = xmlNode["return_code"].InnerText;
                if (response.return_code.ToUpper() != "SUCCESS")
                {
                    response.return_msg = xmlNode["return_msg"].InnerText;
                    return(response);
                }

                response.result_code = xmlNode["result_code"].InnerText;
                if (response.result_code.ToUpper() == "FAIL")
                {
                    response.err_code     = "错误码:" + xmlNode["err_code"].InnerText;
                    response.err_code_des = "错误描述:" + xmlNode["err_code_des"].InnerText;
                    return(response);
                }
            }

            return(response);
        }
        protected RefundRequest CreateRefundTestRequest(string pspReference)
        {
            var refundRequest = new RefundRequest()
            {
                MerchantAccount    = "MerchantAccount",
                ModificationAmount = new Amount("EUR", 150),
                Reference          = "refund - " + DateTime.Now.ToString("yyyyMMdd"),
                OriginalReference  = pspReference
            };

            return(refundRequest);
        }
        /// <summary>
        /// Create a Refund Creates a refund.
        /// </summary>
        /// <param name="orderId">order id</param>
        /// <param name="body"></param>
        /// <param name="accept"></param>
        /// <param name="contentType"></param>
        /// <returns>InlineResponse2011</returns>
        public InlineResponse2011 PostRefund(int?orderId, RefundRequest body, string accept = null, string contentType = null)
        {
            // verify the required parameter 'orderId' is set
            if (orderId == null)
            {
                throw new ApiException(400, "Missing required parameter 'orderId' when calling Postrefund");
            }

            // verify the required parameter 'body' is set
            if (body == null)
            {
                throw new ApiException(400, "Missing required parameter 'body' when calling Postrefund");
            }


            var path = "/orders/{order_id}/payment_actions/refunds";

            path = path.Replace("{format}", "json");
            path = path.Replace("{" + "order_id" + "}", ApiClient.ParameterToString(orderId));

            var    queryParams  = new Dictionary <string, string>();
            var    headerParams = new Dictionary <string, string>();
            var    formParams   = new Dictionary <string, string>();
            var    fileParams   = new Dictionary <string, FileParameter>();
            string postBody     = null;

            if (accept != null)
            {
                headerParams.Add("Accept", ApiClient.ParameterToString(accept));                 // header parameter
            }
            if (contentType != null)
            {
                headerParams.Add("Content-Type", ApiClient.ParameterToString(contentType)); // header parameter
            }
            postBody = ApiClient.Serialize(body);                                           // http body (model) parameter

            // authentication setting, if any
            string[] authSettings = new string[] { "X-Auth-Client", "X-Auth-Token" };

            // make the HTTP request
            IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

            if (((int)response.StatusCode) >= 400)
            {
                throw new ApiException((int)response.StatusCode, "Error calling Postrefund: " + response.Content, response.Content);
            }
            else if (((int)response.StatusCode) == 0)
            {
                throw new ApiException((int)response.StatusCode, "Error calling Postrefund: " + response.ErrorMessage, response.ErrorMessage);
            }

            return((InlineResponse2011)ApiClient.Deserialize(response.Content, typeof(InlineResponse2011), response.Headers));
        }
Пример #17
0
 public bool UpdateRefund(RefundRequest request)
 {
     try
     {
         _dataContext.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #18
0
        public Charge Refund(string customer_id, string charge_id, string description)
        {
            if (charge_id == null)
            {
                throw new ArgumentNullException("charge_id cannot be null");
            }
            string        ep      = GetEndPoint(customer_id, charge_id) + "/refund";
            RefundRequest request = new RefundRequest();

            request.Description = description;
            return(this.httpClient.Post <Charge>(ep, request));
        }
        public dacRefund_Output Refund(ref SecurityHeaderType Security, RequestHeaderType RequestHeader, dacRefund_Input dacRefund_Input)
        {
            RefundRequest inValue = new RefundRequest();

            inValue.Security        = Security;
            inValue.RequestHeader   = RequestHeader;
            inValue.dacRefund_Input = dacRefund_Input;
            RefundResponse retVal = ((RefundV02)(this)).Refund(inValue);

            Security = retVal.Security;
            return(retVal.dacRefund_Output);
        }
Пример #20
0
        public async Task <RefundResponse> RefundAsync(RefundRequest request)
        {
            var inputObj = new SettleObject();
            var head     = new SettleObject();

            head.SetValue("BranchNo", _options.CmbPay.BranchId);
            head.SetValue("MerchantNo", _options.CmbPay.CoNo);
            head.SetValue("Operator", _options.CmbPay.Operator);
            head.SetValue("Password", _options.CmbPay.OperatorPassword);
            head.SetValue("TimeStamp", GenerateTimeStamp());
            head.SetValue("Command", "Refund_No_Dup");
            inputObj.SetValue("Head", head.GetValues());
            var body = new SettleObject();

            body.SetValue("Date", request.ChargeTime.ToString("yyyyMMdd"));
            body.SetValue("BillNo", request.ChargeId);
            body.SetValue("RefundNo", request.RefundId);
            body.SetValue("Amount", request.RefundAmount / 100m);
            body.SetValue("Desc", "refund");
            inputObj.SetValue("Body", body.GetValues());
            var xml =
                await GetAsStringAsync($"{_options.CmbPay.RefundUrl}?Request={WebUtility.UrlEncode(ToXml(inputObj))}");

            try
            {
                var responseObj = FromXml(xml);
                var oHead       = responseObj.GetValue("Head");
                var rBody       = responseObj.GetValue <Dictionary <string, object> >("Body");
                if (oHead is Dictionary <string, object> rHead)
                {
                    return new RefundResponse
                           {
                               RefundId   = request.RefundId,
                               Result     = string.IsNullOrEmpty(rHead.ContainsKey("Code") ? rHead["Code"]?.ToString() : null),
                               Message    = rHead.ContainsKey("ErrMsg") ? rHead["ErrMsg"]?.ToString() : null,
                               ProviderId = rBody.ContainsKey("RefundNo") ? rBody["RefundNo"]?.ToString() : "0"
                           }
                }
                ;

                return(new RefundResponse
                {
                    RefundId = request.RefundId,
                    Result = true,
                    ProviderId = rBody.ContainsKey("RefundNo") ? rBody["RefundNo"]?.ToString() : "0"
                });
            }
            catch (Exception e)
            {
                throw new SettleException($"{xml}", e);
            }
        }
Пример #21
0
        public RefundResponse RefundOrder(string accessToken, string orderIdentifier, string managerConfirmation = null)
        {
            RefundRequest request           = new RefundRequest(accessToken, orderIdentifier, managerConfirmation);
            var           accessTokenHeader = (request.ApiVersion == Http.LevelUpApiVersion.v14) ?
                                              FormatAccessTokenString(unspecifiedUserAccessToken: request.AccessToken) :
                                              FormatAccessTokenString(merchantUserAccessToken: request.AccessToken);

            return(_restWrapper.Post <RefundRequestBody, RefundResponse>(
                       request.Body,
                       uri: BuildUri(request.ApiVersion, $"orders/{request.OrderIdentifier}/refund"),
                       accessTokenHeader: accessTokenHeader,
                       actions: null));
        }
        /// <summary>
        /// По этому запросу средства по указанному заказу будут возвращены плательщику. Запрос закончится ошибкой в случае, если средства
        /// по этому заказу не были списаны. Система позволяет возвращать средства более одного раза, но в общей сложности не более
        /// первоначальной суммы списания.
        /// Для выполнения операции возврата необходимо наличие соответствующих права в системе
        /// </summary>
        public RefundResponse Refund(RefundParams refundParams)
        {
            var url     = _settings.BaseUrl + "/refund.do";
            var request = new RefundRequest(refundParams)
            {
                userName = _settings.Username,
                password = _settings.Password
            };

            var result = _networkClient.PostObjectViaUrlParams <RefundResponse>(url, request);

            return(result);
        }
Пример #23
0
        public void RefundPaymentReturnsSuccess_WithoutSendingAMount()
        {
            var reserveResult = ReserveAmount(1.23, AuthType.paymentAndCapture);

            this.WaitForDataToFlowIntoReporting();

            var request = new RefundRequest()
            {
                PaymentId = reserveResult.Payment.TransactionId,
            };

            Assert.AreEqual(Result.Success, _api.Refund(request).Result);
        }
Пример #24
0
        public ModificationResult Refund(string pspReference, string currency, int amount)
        {
            var modification = new Modification(_client);

            var captureRequest = new RefundRequest
            {
                MerchantAccount    = _adyenConfiguration.MerchantAccount,
                ModificationAmount = new Amount(currency, amount),
                OriginalReference  = pspReference
            };

            return(modification.Refund(captureRequest));
        }
        public void GetRefundUrl_GeneratesUrl()
        {
            var request = new RefundRequest
            {
                CallbackUri = _callBackUri,
                DisplayName = DisplayName,
                OrderId = OrderId
            };

            var actual = _sut.GetRefundUrl(request);

            Assert.IsNotNull(actual);
        }
Пример #26
0
 public Task <RefundResponse> RefundPayment(
     string paymentId,
     RefundRequest refundRequest         = null,
     string idempotencyKey               = null,
     CancellationToken cancellationToken = default)
 {
     CheckoutUtils.ValidateParams("paymentId", paymentId);
     return(ApiClient.Post <RefundResponse>(BuildPath(PaymentsPath, paymentId, "refunds"),
                                            SdkAuthorization(),
                                            refundRequest,
                                            cancellationToken,
                                            idempotencyKey));
 }
        private TransactionResponse Refund(string reference, decimal amount)
        {
            var refundRequest = new RefundRequest(_userName, _password, reference, amount);
            var response      = refundRequest.Execute();

            return(new TransactionResponse
            {
                Approved = response.ResponseStatus == ResponseStatus.Approved,
                AuthCode = response.AuthCode,
                Message = response.ResponseText,
                TransactionId = response.TransactionId
            });
        }
Пример #28
0
        public GatewayRefundRequest GetGatewayRefundRequest(RefundRequest request)
        {
            var gatewayRefundRequest = new GatewayRefundRequest()
            {
                amount = new GatewayAmount()
                {
                    amount_in_cents = request.amounttotal, currency = request.currency
                },
                refund_id      = request.transactionid,
                is_full_refund = request.is_full_refund
            };

            return(gatewayRefundRequest);
        }
Пример #29
0
        /// <summary>
        /// Creates a refund.
        /// </summary>
        /// <param name="paymentId">The ID of the payment to refund.</param>
        /// <param name="description">A description/reason for the refund.</param>
        /// <returns>A RefundResponse</returns>
        public async Task <RefundResponse> CreateRefundAsync(string paymentId, string description)
        {
            var paymentClient   = GetPaymentClient();
            var refundClient    = GetRefundClient();
            var paymentToRefund = await paymentClient.GetPaymentAsync(paymentId);

            var refundRequest = new RefundRequest
            {
                Amount      = new Amount(paymentToRefund.Amount.Currency, paymentToRefund.Amount.Value),
                Description = description
            };

            return(await refundClient.CreateRefundAsync(paymentId, refundRequest));
        }
Пример #30
0
        public void RefundPaymentReturnsRefundedAmount()
        {
            var reserveResult = ReserveAmount(1.23, AuthType.paymentAndCapture);

            this.WaitForDataToFlowIntoReporting();

            var request = new RefundRequest()
            {
                PaymentId = reserveResult.Payment.TransactionId,
                Amount    = Amount.Get(1.11, Currency.DKK),
            };

            Assert.AreEqual(1.11, _api.Refund(request).Payment.RefundedAmount);
        }
Пример #31
0
        public RefundResponse Refund(RefundRequest request)
        {
            //Log.Information("LCManagerPartner Refund {Phone}", request.Phone);
            Log.Information("LCManagerPartner GetRegistrationUser Operator = {Operator}, Phone = {phone}, Amount = {Amount}, Card = {Card}, ChequeTime = {ChequeTime}, " +
                            "Number = {Number}, PaidByBonus = {PaidByBonus}, Partner = {Partner}, Pos = {Pos}, PurchaseDate = {PurchaseDate}, PurchaseId = {PurchaseId}, " +
                            "PurchaseNumber = {PurchaseNumber}, PurchasePos = {PurchasePos}, PurchaseTerminal = {PurchaseTerminal}",
                            request.Operator, request.Phone, request.Amount, request.Card, request.ChequeTime,
                            request.Number, request.PaidByBonus, request.Partner, request.Pos, request.PurchaseDate, request.PurchaseId, request.PurchaseNumber,
                            request.PurchasePos, request.PurchaseTerminal);
            var result      = new ServerRefundResponse();
            var returnValue = result.ProcessRequest(cnn, request);

            return(returnValue);
        }
Пример #32
0
        public string RefundPaymentFully(string paymentid, string notes = null)
        {
            var payment            = Payment.Get(apiContext, paymentid);
            var sale               = payment.transactions[0].related_resources[0].sale;
            var fullAmountToRefund = payment.transactions[0].amount;
            var refund             = new RefundRequest()
            {
                amount = fullAmountToRefund,
                reason = notes
            };
            var response = Sale.Refund(apiContext, sale.id, refund);

            return(response.id);
        }
Пример #33
0
        public string Refund(AmazonPayClient client, RefundPaymentRequest refund, RefundPaymentResult result)
        {
            result.NewPaymentStatus = refund.Order.PaymentStatus;

            string amazonRefundId = null;
            var request = new RefundRequest();
            request.SellerId = client.Settings.SellerId;
            request.AmazonCaptureId = refund.Order.CaptureTransactionId;
            request.RefundReferenceId = GetRandomId("Refund");
            //request.SellerRefundNote = client.Settings.SellerNoteRefund.Truncate(255);

            request.RefundAmount = new Price()
            {
                Amount = refund.AmountToRefund.ToString("0.00", CultureInfo.InvariantCulture),
                CurrencyCode = refund.Order.CustomerCurrencyCode ?? "EUR"
            };

            var response = client.Service.Refund(request);

            if (response != null && response.IsSetRefundResult() && response.RefundResult.IsSetRefundDetails())
            {
                var details = response.RefundResult.RefundDetails;

                amazonRefundId = details.AmazonRefundId;

                if (details.IsSetRefundStatus() && details.RefundStatus.IsSetState())
                {
                    if (refund.IsPartialRefund)
                        result.NewPaymentStatus = Core.Domain.Payments.PaymentStatus.PartiallyRefunded;
                    else
                        result.NewPaymentStatus = Core.Domain.Payments.PaymentStatus.Refunded;
                }
            }
            return amazonRefundId;
        }
        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);
        }
        public void GetRefundUrl_ThrowsWhenMissingArguments()
        {
            var request = new RefundRequest();

            Assert.Throws<ArgumentNullException>(() => _sut.GetRefundUrl(request));
        }
 public static RefundResponse InvokeRefund(IOffAmazonPaymentsService service, RefundRequest request)
 {
     RefundResponse response = null;
     try
     {
         response = service.Refund(request);
         Console.WriteLine("Service Response");
         Console.WriteLine("=============================================================================");
         Console.WriteLine();
         Console.WriteLine("        RefundResponse");
         if (response.IsSetRefundResult())
         {
             Console.WriteLine("            RefundResult");
             RefundResult refundResult = response.RefundResult;
             if (refundResult.IsSetRefundDetails())
             {
                 Console.WriteLine("                RefundDetails");
                 RefundDetails refundDetails = refundResult.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.IsSetProviderCreditReversalSummaryList())
                 {
                     foreach (ProviderCreditReversalSummary providerCreditReversalSummary in refundDetails.ProviderCreditReversalSummaryList.member)
                     {
                         if (providerCreditReversalSummary.IsSetProviderCreditReversalId())
                         {
                             Console.WriteLine("                    ProviderCreditReversalId");
                             Console.WriteLine("                        {0}", providerCreditReversalSummary.ProviderCreditReversalId);
                         }
                         if (providerCreditReversalSummary.IsSetProviderId())
                         {
                             Console.WriteLine("                    ProviderId");
                             Console.WriteLine("                        {0}", providerCreditReversalSummary.ProviderId);
                         }
                     }
                 }
                 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;
 }