From 05abc67cdd25ddbfb282b4c86a1dfeff340f668d Mon Sep 17 00:00:00 2001 From: SamSys Date: Tue, 11 Nov 2025 16:11:04 +0330 Subject: [PATCH] add gatewaypayment test --- .../Pages/Company/AndroidApk/Index.cshtml.cs | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/AndroidApk/Index.cshtml.cs b/ServiceHost/Areas/AdminNew/Pages/Company/AndroidApk/Index.cshtml.cs index b8e8146c..f61e005c 100644 --- a/ServiceHost/Areas/AdminNew/Pages/Company/AndroidApk/Index.cshtml.cs +++ b/ServiceHost/Areas/AdminNew/Pages/Company/AndroidApk/Index.cshtml.cs @@ -34,6 +34,8 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk private readonly AccountContext _accountContext; private readonly IPaymentGateway _paymentGateway; private readonly ITemporaryClientRegistrationApplication _clientRegistrationApplication; + private readonly IHttpClientFactory _httpClientFactory; + [BindProperty] public IFormFile File { get; set; } @@ -47,6 +49,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk _rollCallDomainService = rollCallDomainService; _context = context; _accountContext = accountContext; + _httpClientFactory = httpClientFactory; _clientRegistrationApplication = clientRegistrationApplication; _paymentGateway = new AqayePardakhtPaymentGateway(httpClientFactory, appSetting); } @@ -63,7 +66,7 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk } - public IActionResult OnPostShiftDate() + public async Task OnPostShiftDate() { //var startRollCall = new DateTime(2025, 2, 19); //var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall); @@ -73,8 +76,29 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk //var notEndedRollCalls = rollCalls.Where(x => x.EndDate == null).ToList(); //RefactorAllTheRollCallsOnEsfand(endedRollCalls, notEndedRollCalls); //CreateRewardForKebabMahdi().GetAwaiter().GetResult(); - SetEntityIdForCheckoutValues(); - SetEntityIdForCheckoutValuesTemp(); + var httpClient = _httpClientFactory.CreateClient(); + httpClient.BaseAddress = new Uri("https://sepehr.shaparak.ir/"); + var terminal = 98000000; + var res= await httpClient.PostAsJsonAsync("Rest/V1/PeymentApi/GetToken", new + { + TerminalID=terminal, + Amount="2000", + InvoiceID="444", + callbackURL="https://test.ir/Payment/PageCallBackSaderat", + payload="" + }); + // خواندن محتوای پاسخ + var content = await res.Content.ReadAsStringAsync(); + + // تبدیل پاسخ JSON به آبجکت دات‌نت + var json = System.Text.Json.JsonDocument.Parse(content); + + // گرفتن مقدار AccessToken + var accessToken = json.RootElement.GetProperty("Accesstoken").GetString(); + + return Redirect($"https://sepehr.shaparak.ir/Payment/Pay?token={accessToken}&terminalId={terminal}"); + + ViewData["message"] = "ایجاد شد"; return Page(); }