예제 #1
0
        public virtual async Task <IPaymentVerifyResult> VerifyAsync(Payment payment, CancellationToken cancellationToken = default)
        {
            if (payment == null)
            {
                throw new ArgumentNullException(nameof(payment));
            }

            var callbackResult = IranKishHelper.CreateCallbackResult(
                payment,
                _options.Value,
                _httpContextAccessor.HttpContext.Request,
                _messageOptions.Value);

            var data = IranKishHelper.CreateVerifyData(callbackResult, _options.Value);

            _httpClient.DefaultRequestHeaders.Add(IranKishHelper.HttpVerifyHeader.Key, IranKishHelper.HttpVerifyHeader.Value);

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

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

            return(IranKishHelper.CreateVerifyResult(response, payment, callbackResult, _messageOptions.Value));
        }
예제 #2
0
        /// <inheritdoc />
        public override async Task <IPaymentVerifyResult> VerifyAsync(InvoiceContext context, CancellationToken cancellationToken = default)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

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

            var callbackResult = IranKishHelper.CreateCallbackResult(
                context,
                account,
                _httpContextAccessor.HttpContext.Request,
                _messageOptions.Value);

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

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

            _httpClient.DefaultRequestHeaders.Clear();
            _httpClient.DefaultRequestHeaders.Add(IranKishHelper.HttpVerifyHeader.Key, IranKishHelper.HttpVerifyHeader.Value);

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

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

            return(IranKishHelper.CreateVerifyResult(response, context, callbackResult, _messageOptions.Value));
        }
예제 #3
0
        public virtual async Task <IPaymentRequestResult> RequestAsync(Invoice invoice, CancellationToken cancellationToken = default)
        {
            if (invoice == null)
            {
                throw new ArgumentNullException(nameof(invoice));
            }

            var data = IranKishHelper.CreateRequestData(invoice, _options.Value);

            _httpClient.DefaultRequestHeaders.Add(IranKishHelper.HttpRequestHeader.Key, IranKishHelper.HttpRequestHeader.Value);

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

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

            return(IranKishHelper.CreateRequestResult(response, invoice, _options.Value, _httpContextAccessor, _messageOptions.Value));
        }