From bfd66329407d3eda24dcd2dab561d9cb068e8356 Mon Sep 17 00:00:00 2001 From: MahanCh Date: Sun, 20 Jul 2025 14:53:50 +0330 Subject: [PATCH] change the step from paymentCallBack - set transactionId on create PaymentGateway --- .../IPaymentTransactionApplication.cs | 2 ++ .../PaymentTransactionApplication.cs | 8 ++++++++ .../Client/Controllers/FinancialController.cs | 1 + ServiceHost/Controllers/GeneralController.cs | 14 +++++++------- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CompanyManagment.App.Contracts/PaymentTransaction/IPaymentTransactionApplication.cs b/CompanyManagment.App.Contracts/PaymentTransaction/IPaymentTransactionApplication.cs index 8564d7f5..3e86b7cf 100644 --- a/CompanyManagment.App.Contracts/PaymentTransaction/IPaymentTransactionApplication.cs +++ b/CompanyManagment.App.Contracts/PaymentTransaction/IPaymentTransactionApplication.cs @@ -50,6 +50,8 @@ public interface IPaymentTransactionApplication /// /// OperationResult SetSuccess(long paymentTransactionId, string cardNumber, string bankName); + + Task SetTransactionId(long id, string transactionId); } public class PaymentTransactionDetailsViewModel diff --git a/CompanyManagment.Application/PaymentTransactionApplication.cs b/CompanyManagment.Application/PaymentTransactionApplication.cs index cbe01756..cf4e1e0a 100644 --- a/CompanyManagment.Application/PaymentTransactionApplication.cs +++ b/CompanyManagment.Application/PaymentTransactionApplication.cs @@ -97,4 +97,12 @@ public class PaymentTransactionApplication : IPaymentTransactionApplication return op.Succcedded(); } + + public async Task SetTransactionId(long id, string transactionId) + { + var paymentTransaction = _paymentTransactionRepository.Get(id); + paymentTransaction.SetTransactionId(transactionId); + await _paymentTransactionRepository.SaveChangesAsync(); + return new OperationResult().Succcedded(); + } } \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Controllers/FinancialController.cs b/ServiceHost/Areas/Client/Controllers/FinancialController.cs index 56b8d83d..8cb66001 100644 --- a/ServiceHost/Areas/Client/Controllers/FinancialController.cs +++ b/ServiceHost/Areas/Client/Controllers/FinancialController.cs @@ -88,6 +88,7 @@ public class FinancialController : ClientBaseController if (gatewayResponse.IsSuccess) { + _ = await _paymentTransactionApplication.SetTransactionId(transaction.SendId, gatewayResponse.TransactionId); return op.Succcedded(_paymentGateway.GetStartPayUrl(gatewayResponse.TransactionId)); } diff --git a/ServiceHost/Controllers/GeneralController.cs b/ServiceHost/Controllers/GeneralController.cs index 88aa0100..d11350a1 100644 --- a/ServiceHost/Controllers/GeneralController.cs +++ b/ServiceHost/Controllers/GeneralController.cs @@ -83,12 +83,7 @@ public class GeneralController : GeneralBaseController if (verifyRes.IsSuccess) { var setSuccessResult = _paymentTransactionApplication.SetSuccess(paymentTransactionId, cardnumber, bank); - - if (!setSuccessResult.IsSuccedded) - { - return new JsonResult(setSuccessResult); - } - //TODO : افزودن دریافت درآمد به وضعیت مالی + var command = new CreateFinancialStatment() { @@ -101,7 +96,12 @@ public class GeneralController : GeneralBaseController DescriptionOption = "بابت قرارداد مابین (روابط کار)", }; - var result = _financialStatmentApplication.Create(command); + _financialStatmentApplication.Create(command); + + if (!setSuccessResult.IsSuccedded) + { + return new JsonResult(setSuccessResult); + } return Redirect(BuildCallbackUrl(transaction.CallBackUrl, true, transaction.Id)); }