/// <inheritdoc /> public override async Task <IPaymentVerifyResult> VerifyAsync(InvoiceContext context, CancellationToken cancellationToken = default) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var callbackResult = await GetCallbackResult(context, cancellationToken); if (!callbackResult.IsSucceed) { return(PaymentVerifyResult.Failed(callbackResult.Message)); } var account = await GetAccountAsync(context.Payment).ConfigureAwaitFalse(); var data = ZarinPalHelper.CreateVerifyData(account, callbackResult, context.Payment.Amount); var responseMessage = await _httpClient .PostXmlAsync(ZarinPalHelper.GetApiUrl(account.IsSandbox, _gatewayOptions), data, cancellationToken) .ConfigureAwaitFalse(); var response = await responseMessage.Content.ReadAsStringAsync().ConfigureAwaitFalse(); return(ZarinPalHelper.CreateVerifyResult(response, _messagesOptions.Value)); }
/// <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 = ZarinPalHelper.CreateRequestData(account, invoice); var responseMessage = await _httpClient .PostXmlAsync(ZarinPalHelper.GetApiUrl(account.IsSandbox, _gatewayOptions), data, cancellationToken) .ConfigureAwaitFalse(); var response = await responseMessage.Content.ReadAsStringAsync().ConfigureAwaitFalse(); return(ZarinPalHelper.CreateRequestResult(response, _httpContextAccessor.HttpContext, account, _gatewayOptions, _messagesOptions.Value)); }