diff --git a/CompanyManagment.App.Contracts/FinancialStatment/IFinancialStatmentApplication.cs b/CompanyManagment.App.Contracts/FinancialStatment/IFinancialStatmentApplication.cs index da47e6c8..0418df8f 100644 --- a/CompanyManagment.App.Contracts/FinancialStatment/IFinancialStatmentApplication.cs +++ b/CompanyManagment.App.Contracts/FinancialStatment/IFinancialStatmentApplication.cs @@ -36,6 +36,9 @@ public interface IFinancialStatmentApplication public class GetFinancialStatementBalanceAmount { + /// + /// مبلغ + /// public double Amount { get; set; } public long ContractingPartyId { get; set; } } \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Controllers/FinancialController.cs b/ServiceHost/Areas/Client/Controllers/FinancialController.cs index c6354d75..446a7500 100644 --- a/ServiceHost/Areas/Client/Controllers/FinancialController.cs +++ b/ServiceHost/Areas/Client/Controllers/FinancialController.cs @@ -56,13 +56,13 @@ public class FinancialController : ClientBaseController return op.Failed("موجودی حساب شما صفر است"); } - var callBack = baseUrl+ "/CallBack"; + var callBack = baseUrl+ "/api/CallBack"; var transactionCommand = new CreatePaymentTransaction() { Amount = balanceAmount.Amount, ContractingPartyId = balanceAmount.ContractingPartyId, - CallBackUrl = callBack + CallBackUrl = baseUrl }; var transaction = await _paymentTransactionApplication.Create(transactionCommand); diff --git a/ServiceHost/Controllers/GeneralController.cs b/ServiceHost/Controllers/GeneralController.cs index 9c824016..00d779bd 100644 --- a/ServiceHost/Controllers/GeneralController.cs +++ b/ServiceHost/Controllers/GeneralController.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using ServiceHost.BaseControllers; using System.Globalization; +using _0_Framework.Application.PaymentGateway; namespace ServiceHost.Controllers; @@ -12,10 +13,12 @@ public class GeneralController : GeneralBaseController { private readonly IPaymentTransactionApplication _paymentTransactionApplication; + private readonly IPaymentGateway _paymentGateway; - public GeneralController(IPaymentTransactionApplication paymentTransactionApplication) + public GeneralController(IPaymentTransactionApplication paymentTransactionApplication,IHttpClientFactory clientFactory) { _paymentTransactionApplication = paymentTransactionApplication; + _paymentGateway = new AqayePardakhtPaymentGateway(clientFactory); } /// @@ -39,9 +42,9 @@ public class GeneralController : GeneralBaseController }); } - [HttpPost("callback")] + [HttpPost("/api/callback")] public async Task OnGetCallBack(string? transid, string? cardnumber, string? tracking_number, - string bank, string invoice_id, string? status) + string bank, string invoice_id, string? status,CancellationToken cancellationToken) { if (!long.TryParse(invoice_id, out var paymentTransactionId)) { @@ -60,10 +63,18 @@ public class GeneralController : GeneralBaseController return await HandleFailedTransaction(transaction, paymentTransactionId); } + var verifyCommand = new VerifyPaymentGateWayRequest() + { + Amount = transaction.Amount, + TransactionId = transid + }; + var verifyRes =await _paymentGateway.Verify(verifyCommand, cancellationToken); + // اگر استاتوس 1 باشد، تراکنش موفق است - if (status == "1") + if (verifyRes.IsSuccess) { var setSuccessResult = _paymentTransactionApplication.SetSuccess(paymentTransactionId, cardnumber, bank); + //TODO : افزودن دریافت درآمد به وضعیت مالی if (!setSuccessResult.IsSuccedded) { return new JsonResult(setSuccessResult); @@ -90,7 +101,7 @@ public class GeneralController : GeneralBaseController private string BuildCallbackUrl(string baseUrl, bool isSuccess, long transactionId) { var statusCode = isSuccess ? "1" : "0"; - return $"{baseUrl}?Status={statusCode}&transactionId={transactionId}"; + return $"{baseUrl}/callback?Status={statusCode}&transactionId={transactionId}"; }