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
|
try
|
||||||
{
|
{
|
||||||
// Create callback URL for payment verification
|
// Get available packages and pick the first (base) one
|
||||||
var callbackUrl = $"{Navigation.BaseUri}profile/payment-callback";
|
var packages = await PackageContract.GetCustomerPackagesAsync(new GetCustomerPackagesRequest());
|
||||||
|
var basePackage = packages?.Models?.FirstOrDefault();
|
||||||
// Call BFF to initiate payment (UserId is taken from JWT token in BFF)
|
if (basePackage == null)
|
||||||
var response = await PackageContract.InitiateBasePackagePaymentAsync(new InitiateBasePackagePaymentRequest
|
|
||||||
{
|
{
|
||||||
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)
|
if (!response.Success)
|
||||||
@@ -429,6 +440,8 @@ public partial class Index
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to payment gateway
|
// Redirect to payment gateway
|
||||||
|
// ZarinPal appends ?Authority=...&Status=... to callback URL
|
||||||
|
// PaymentCallback uses Authority+Status to verify via CustomerVerifyPackagePurchase
|
||||||
if (!string.IsNullOrEmpty(response.PaymentGatewayUrl))
|
if (!string.IsNullOrEmpty(response.PaymentGatewayUrl))
|
||||||
{
|
{
|
||||||
Navigation.NavigateTo(response.PaymentGatewayUrl, forceLoad: true);
|
Navigation.NavigateTo(response.PaymentGatewayUrl, forceLoad: true);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (OrderId <= 0 || TransactionId <= 0 || string.IsNullOrEmpty(Authority))
|
if (OrderId <= 0 || string.IsNullOrEmpty(Authority))
|
||||||
{
|
{
|
||||||
_isSuccess = false;
|
_isSuccess = false;
|
||||||
_message = "پارامترهای پرداخت نامعتبر است";
|
_message = "پارامترهای پرداخت نامعتبر است";
|
||||||
@@ -110,20 +110,23 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var response = await PackageContractClient.VerifyBasePackagePaymentAsync(new VerifyBasePackagePaymentRequest
|
var response = await PackageContractClient.CustomerVerifyPackagePurchaseAsync(new CustomerVerifyPackagePurchaseRequest
|
||||||
{
|
{
|
||||||
OrderId = OrderId,
|
OrderId = OrderId,
|
||||||
TransactionId = TransactionId,
|
Authority = Authority ?? string.Empty,
|
||||||
PaymentSuccess = Status == "OK",
|
Status = Status ?? string.Empty
|
||||||
RefId = !string.IsNullOrEmpty(Authority) ? Authority : null,
|
|
||||||
Message = !string.IsNullOrEmpty(Status) ? Status : null
|
|
||||||
});
|
});
|
||||||
|
|
||||||
_isSuccess = response.Success;
|
_isSuccess = response.Success;
|
||||||
_message = response.Message;
|
_message = response.Message;
|
||||||
_refId = response.ReferenceCode ?? "";
|
_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 میکنیم
|
// اگر پرداخت موفق بود، توکن را refresh میکنیم
|
||||||
// چون PackagePurchaseMethod تغییر کرده و باید در claims جدید باشد
|
// چون PackagePurchaseMethod تغییر کرده و باید در claims جدید باشد
|
||||||
|
|||||||
Reference in New Issue
Block a user