feat(payment): integrate TwentyCard payment option and enhance checkout flow
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 5m6s

- Added a new payment method for TwentyCard in the checkout process, allowing users to select it alongside direct payment options.
- Implemented the logic for processing TwentyCard payments, including user feedback and dialog interactions for payment confirmation.
- Updated the appsettings files to include configuration for the new payment method.
- Enhanced the user interface in the PackagePurchaseDialog to reflect the new payment option and its requirements.

These changes improve the payment flexibility in the checkout process, providing users with additional options for completing their transactions.
This commit is contained in:
masoodafar-web
2026-09-20 22:17:39 +03:30
parent 8252e408b6
commit aedf312812
12 changed files with 178 additions and 14 deletions
@@ -421,7 +421,10 @@ public partial class Index
switch (purchase.Method)
{
case Shared.PackagePurchaseDialog.PaymentMethodType.DirectPayment:
await ProcessDirectPayment(purchase.Package.Id);
await ProcessDirectPayment(purchase.Package.Id, gatewayProvider: null);
break;
case Shared.PackagePurchaseDialog.PaymentMethodType.TwentyCard:
await ProcessTwentyCardPayment(purchase.Package.Id);
break;
case Shared.PackagePurchaseDialog.PaymentMethodType.DayaLoan:
await ProcessDayaLoanPayment();
@@ -430,7 +433,25 @@ public partial class Index
}
}
private async Task ProcessDirectPayment(long packageId)
private async Task ProcessTwentyCardPayment(long packageId)
{
var options = new DialogOptions
{
MaxWidth = MaxWidth.Small,
FullWidth = true,
CloseOnEscapeKey = true,
BackdropClick = true
};
var dialog = await DialogService.ShowAsync<Shared.TwentyCardCreditDialog>(
string.Empty, options);
var result = await dialog.Result;
if (result.Canceled) return;
await ProcessDirectPayment(packageId, gatewayProvider: "20card");
}
private async Task ProcessDirectPayment(long packageId, string? gatewayProvider = null)
{
if (_isProcessingPayment) return;
@@ -439,11 +460,15 @@ public partial class Index
try
{
var response = await PackageContract.CustomerPurchasePackageAsync(new CustomerPurchasePackageRequest
var request = new CustomerPurchasePackageRequest
{
PackageId = packageId,
PurchaseMethod = PurchaseMethodEnum.PurchaseMethodGateway
});
};
if (!string.IsNullOrWhiteSpace(gatewayProvider))
request.GatewayProvider = gatewayProvider;
var response = await PackageContract.CustomerPurchasePackageAsync(request);
if (!response.Success)
{
@@ -85,6 +85,10 @@
[SupplyParameterFromQuery(Name = "Status")]
private string? Status { get; set; }
/// <summary>۲۰کارت callback — هم‌معنی Status زرین‌پال</summary>
[SupplyParameterFromQuery(Name = "PaymentStatus")]
private string? PaymentStatus { get; set; }
private bool _isLoading = true;
private bool _isSuccess;
@@ -132,6 +136,10 @@
{
try
{
// ۲۰کارت: PaymentStatus؛ زرین‌پال: Status
if (string.IsNullOrWhiteSpace(Status) && !string.IsNullOrWhiteSpace(PaymentStatus))
Status = PaymentStatus;
// تعیین نوع پرداخت — اگر type نباشد، پیش‌فرض خرید پکیج
var type = PaymentType?.ToLowerInvariant() ?? "package";