Phase 7b: Migrate deprecated RPCs to Customer* RPCs
- Profile/Index: InitiateBasePackagePayment → CustomerPurchasePackage - Fetches base package via GetCustomerPackages, passes PackageId + PurchaseMethod - Profile/PaymentCallback: VerifyBasePackagePayment → CustomerVerifyPackagePurchase - Uses Authority/Status (from ZarinPal callback) + orderId (from embedded URL param) - TransactionId no longer required (CMS finds it internally)
This commit is contained in:
@@ -413,13 +413,24 @@ public partial class Index
|
||||
|
||||
try
|
||||
{
|
||||
// Create callback URL for payment verification
|
||||
var callbackUrl = $"{Navigation.BaseUri}profile/payment-callback";
|
||||
|
||||
// Call BFF to initiate payment (UserId is taken from JWT token in BFF)
|
||||
var response = await PackageContract.InitiateBasePackagePaymentAsync(new InitiateBasePackagePaymentRequest
|
||||
// Get available packages and pick the first (base) one
|
||||
var packages = await PackageContract.GetCustomerPackagesAsync(new GetCustomerPackagesRequest());
|
||||
var basePackage = packages?.Models?.FirstOrDefault();
|
||||
if (basePackage == null)
|
||||
{
|
||||
CallbackUrl = callbackUrl
|
||||
Snackbar.Add("پکیجی برای خرید یافت نشد", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Call CMS to initiate purchase (UserId from JWT, PackageId explicit)
|
||||
// First, get orderId — then embed in callback URL
|
||||
var tempCallbackUrl = $"{Navigation.BaseUri}profile/payment-callback";
|
||||
|
||||
var response = await PackageContract.CustomerPurchasePackageAsync(new CustomerPurchasePackageRequest
|
||||
{
|
||||
PackageId = basePackage.Id,
|
||||
CallbackUrl = tempCallbackUrl,
|
||||
PurchaseMethod = PurchaseMethodEnum.PurchaseMethodGateway
|
||||
});
|
||||
|
||||
if (!response.Success)
|
||||
@@ -429,6 +440,8 @@ public partial class Index
|
||||
}
|
||||
|
||||
// Redirect to payment gateway
|
||||
// ZarinPal appends ?Authority=...&Status=... to callback URL
|
||||
// PaymentCallback uses Authority+Status to verify via CustomerVerifyPackagePurchase
|
||||
if (!string.IsNullOrEmpty(response.PaymentGatewayUrl))
|
||||
{
|
||||
Navigation.NavigateTo(response.PaymentGatewayUrl, forceLoad: true);
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
if (OrderId <= 0 || TransactionId <= 0 || string.IsNullOrEmpty(Authority))
|
||||
if (OrderId <= 0 || string.IsNullOrEmpty(Authority))
|
||||
{
|
||||
_isSuccess = false;
|
||||
_message = "پارامترهای پرداخت نامعتبر است";
|
||||
@@ -110,20 +110,23 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var response = await PackageContractClient.VerifyBasePackagePaymentAsync(new VerifyBasePackagePaymentRequest
|
||||
var response = await PackageContractClient.CustomerVerifyPackagePurchaseAsync(new CustomerVerifyPackagePurchaseRequest
|
||||
{
|
||||
OrderId = OrderId,
|
||||
TransactionId = TransactionId,
|
||||
PaymentSuccess = Status == "OK",
|
||||
RefId = !string.IsNullOrEmpty(Authority) ? Authority : null,
|
||||
Message = !string.IsNullOrEmpty(Status) ? Status : null
|
||||
Authority = Authority ?? string.Empty,
|
||||
Status = Status ?? string.Empty
|
||||
});
|
||||
|
||||
_isSuccess = response.Success;
|
||||
_message = response.Message;
|
||||
_refId = response.ReferenceCode ?? "";
|
||||
_walletBalance = response.WalletBalance;
|
||||
_discountBalance = response.DiscountBalance;
|
||||
|
||||
// Wallet balances are no longer in verify response — show from purchase info
|
||||
if (response.PurchaseInfo != null)
|
||||
{
|
||||
_walletBalance = response.PurchaseInfo.AmountPaid;
|
||||
_discountBalance = 0; // Available in wallet page
|
||||
}
|
||||
|
||||
// اگر پرداخت موفق بود، توکن را refresh میکنیم
|
||||
// چون PackagePurchaseMethod تغییر کرده و باید در claims جدید باشد
|
||||
|
||||
Reference in New Issue
Block a user