Beispiel #1
0
        public virtual async Task <IPaymentRefundResult> RefundAsync(Payment payment, Money amount, CancellationToken cancellationToken = default)
        {
            if (payment == null)
            {
                throw new ArgumentNullException(nameof(payment));
            }
            if (amount == null)
            {
                throw new ArgumentNullException(nameof(amount));
            }

            var data = MellatHelper.CreateRefundData(payment, _options.Value);

            var responseMessage = await _httpClient
                                  .PostXmlAsync(GetWebServiceUrl(), data, cancellationToken)
                                  .ConfigureAwaitFalse();

            var response = await responseMessage.Content.ReadAsStringAsync().ConfigureAwaitFalse();

            return(MellatHelper.CreateRefundResult(response, _messagesOptions.Value));
        }
Beispiel #2
0
        /// <inheritdoc />
        public override async Task <IPaymentRefundResult> RefundAsync(InvoiceContext context, Money amount, CancellationToken cancellationToken = default)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (amount == null)
            {
                throw new ArgumentNullException(nameof(amount));
            }

            var account = await GetAccountAsync(context.Payment).ConfigureAwaitFalse();

            var data = MellatHelper.CreateRefundData(context, account);

            var responseMessage = await _httpClient
                                  .PostXmlAsync(MellatHelper.GetWebServiceUrl(account.IsTestTerminal), data, cancellationToken)
                                  .ConfigureAwaitFalse();

            var response = await responseMessage.Content.ReadAsStringAsync().ConfigureAwaitFalse();

            return(MellatHelper.CreateRefundResult(response, _messagesOptions.Value));
        }