Ejemplo n.º 1
0
        /// <inheritdoc />
        public override async Task <IPaymentVerifyResult> VerifyAsync(VerifyContext context, CancellationToken cancellationToken = default)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var callbackResult = SamanHelper.CreateCallbackResult(_httpContextAccessor.HttpContext.Request, _messageOptions.Value);

            if (!callbackResult.IsSucceed)
            {
                return(callbackResult.Result);
            }

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

            var data = SamanHelper.CreateVerifyData(callbackResult, account);

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

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

            return(SamanHelper.CreateVerifyResult(response, context, callbackResult, _messageOptions.Value));
        }
Ejemplo n.º 2
0
        public virtual Task <IPaymentRequestResult> RequestAsync(Invoice invoice, CancellationToken cancellationToken = default)
        {
            if (invoice == null)
            {
                throw new ArgumentNullException(nameof(invoice));
            }

            return(SamanHelper.CreateRequestResult(invoice, _httpContextAccessor, _options.Value)
                   .ToInterfaceAsync());
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        public override async Task <IPaymentRequestResult> RequestAsync(Invoice invoice, CancellationToken cancellationToken = default)
        {
            if (invoice == null)
            {
                throw new ArgumentNullException(nameof(invoice));
            }

            var account = await GetAccountAsync(invoice).ConfigureAwaitFalse();

            return(SamanHelper.CreateRequestResult(invoice, _httpContextAccessor, account));
        }
Ejemplo n.º 4
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 = SamanHelper.CreateRefundData(payment, amount, _options.Value);

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

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

            return(SamanHelper.CreateRefundResult(response, _messageOptions.Value));
        }