コード例 #1
0
ファイル: FanAvaGateway.cs プロジェクト: parsintalk/Parbad
        /// <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();

            var data = FanAvaHelper.CreateRequestModel(invoice, account);

            var responseMessage = await _httpClient.PostAsJsonAsync(_gatewayOptions.ApiGenerateToken, data, cancellationToken);

            return(await FanAvaHelper.CreateRequestResult(responseMessage, _httpContextAccessor.HttpContext, account, _gatewayOptions));
        }
コード例 #2
0
ファイル: FanAvaGateway.cs プロジェクト: mehregan9000/Parbad
        /// <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 = await FanAvaHelper.CreateCallbackResult(
                _httpContextAccessor.HttpContext.Request,
                _messageOptions,
                account,
                cancellationToken)
                                 .ConfigureAwaitFalse();

            if (!callbackResult.IsSucceed)
            {
                return(PaymentVerifyResult.Failed(callbackResult.Message));
            }

            var responseMessage = await _httpClient.PostJsonAsync(
                _gatewayOptions.ApiCheckPaymentUrl,
                callbackResult.CallbackCheckData,
                cancellationToken)
                                  .ConfigureAwaitFalse();

            var checkResult = await FanAvaHelper.CreateCheckResult(
                responseMessage,
                account,
                callbackResult,
                _messageOptions);

            if (!checkResult.IsSucceed)
            {
                return(checkResult.VerifyResult);
            }

            var data = FanAvaHelper.CreateVerifyRequest(context, callbackResult, checkResult);

            responseMessage = await _httpClient.PostJsonAsync(
                _gatewayOptions.ApiVerificationUrl,
                data,
                cancellationToken)
                              .ConfigureAwaitFalse();

            return(await FanAvaHelper.CreateVerifyResult(responseMessage, callbackResult, _messageOptions));
        }
コード例 #3
0
ファイル: FanAvaGateway.cs プロジェクト: mehregan9000/Parbad
        /// <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();

            var data = FanAvaHelper.CreateRequestModel(invoice, account);

            var jsonSettings = new JsonSerializerSettings
            {
                Converters = { new StringEnumConverter() }
            };

            var responseMessage = await _httpClient.PostJsonAsync(_gatewayOptions.ApiTokenGenerationUrl, data, jsonSettings, cancellationToken);

            return(await FanAvaHelper.CreateRequestResult(responseMessage, _httpContextAccessor.HttpContext, account, _gatewayOptions));
        }
コード例 #4
0
ファイル: FanAvaGateway.cs プロジェクト: parsintalk/Parbad
        /// <inheritdoc />
        public override async Task <IPaymentFetchResult> FetchAsync(InvoiceContext context, CancellationToken cancellationToken = default)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            var account = await GetAccountAsync(context.Payment).ConfigureAwaitFalse();

            var callbackResult = await FanAvaHelper.CreateCallbackResult(
                _httpContextAccessor.HttpContext.Request,
                _messageOptions,
                account,
                cancellationToken)
                                 .ConfigureAwaitFalse();

            if (callbackResult.IsSucceed)
            {
                return(PaymentFetchResult.ReadyForVerifying());
            }

            return(PaymentFetchResult.Failed(callbackResult.Message));
        }