add: update payment gateway integration and enhance transaction handling in callback
This commit is contained in:
@@ -112,7 +112,33 @@ public class PaymentCallbackHandler : IPaymentCallbackHandler
|
||||
return operation.Failed("خطا در بهروزرسانی فاکتور مالی");
|
||||
}
|
||||
|
||||
// گام 8: ایجاد سند مالی (Financial Statement)
|
||||
|
||||
|
||||
// گام 8: بهروزرسانی وضعیت تراکنش
|
||||
var setSuccessResult = _paymentTransactionApplication.SetSuccess(
|
||||
command.InvoiceId,
|
||||
command.CardNumber,
|
||||
command.IssuerBank,
|
||||
command.Rrn.ToString(),
|
||||
command.DigitalReceipt);
|
||||
|
||||
if (!setSuccessResult.IsSuccedded)
|
||||
{
|
||||
return operation.Failed("خطا در بهروزرسانی وضعیت تراکنش");
|
||||
}
|
||||
|
||||
// گام 9: بهروزرسانی وضعیت قراردادهای نهادی (اگر وجود داشته باشند)
|
||||
var institutionContractItems = financialInvoice.Items.Where(x =>
|
||||
x.Type is FinancialInvoiceItemType.BuyInstitutionContract
|
||||
or FinancialInvoiceItemType.BuyInstitutionContractInstallment).ToList();
|
||||
|
||||
if (institutionContractItems.Any())
|
||||
{
|
||||
await HandleInstitutionContractItems(financialInvoice);
|
||||
}
|
||||
|
||||
|
||||
// گام 10: ایجاد سند مالی (Financial Statement)
|
||||
var createCreditStatementCommand = new CreateFinancialStatment()
|
||||
{
|
||||
ContractingPartyId = transaction.ContractingPartyId,
|
||||
@@ -128,31 +154,9 @@ public class PaymentCallbackHandler : IPaymentCallbackHandler
|
||||
var statementResult = _financialStatmentApplication.CreateFromBankGateway(createCreditStatementCommand);
|
||||
if (!statementResult.IsSuccedded)
|
||||
{
|
||||
var failResult = _paymentTransactionApplication.SetFailed(command.InvoiceId);
|
||||
_paymentTransactionApplication.SetFailed(command.InvoiceId);
|
||||
return operation.Failed("خطا در ایجاد سند مالی");
|
||||
}
|
||||
|
||||
// گام 9: بهروزرسانی وضعیت تراکنش
|
||||
var setSuccessResult = _paymentTransactionApplication.SetSuccess(
|
||||
command.InvoiceId,
|
||||
command.CardNumber,
|
||||
command.IssuerBank,
|
||||
command.Rrn.ToString(),
|
||||
command.DigitalReceipt);
|
||||
|
||||
if (!setSuccessResult.IsSuccedded)
|
||||
{
|
||||
return operation.Failed("خطا در بهروزرسانی وضعیت تراکنش");
|
||||
}
|
||||
|
||||
// گام 10: بهروزرسانی وضعیت قراردادهای نهادی (اگر وجود داشته باشند)
|
||||
if (financialInvoice.Items?.Any(x =>
|
||||
x.Type is FinancialInvoiceItemType.BuyInstitutionContract
|
||||
or FinancialInvoiceItemType.BuyInstitutionContractInstallment) ?? false)
|
||||
{
|
||||
await HandleInstitutionContractItems(financialInvoice);
|
||||
}
|
||||
|
||||
// گام 11: تأیید نهایی با درگاه پرداخت
|
||||
var verifyCommand = new VerifyPaymentGateWayRequest()
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ public class FinancialController : ClientBaseController
|
||||
_financialStatementApplication = financialStatementApplication;
|
||||
_authHelper = authHelper;
|
||||
_paymentTransactionApplication = paymentTransactionApplication;
|
||||
_paymentGateway = new AqayePardakhtPaymentGateway(httpClientFactory, appSetting);
|
||||
_paymentGateway = new SepehrPaymentGateway(httpClientFactory);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@@ -63,7 +63,7 @@ public class FinancialController : ClientBaseController
|
||||
}
|
||||
|
||||
var callbackUrl = Url.Action(
|
||||
action: "OnGetCallBack",
|
||||
action: "Verify",
|
||||
controller: "General", // نام کنترلر بدون کلمهی "Controller"
|
||||
values: null,
|
||||
protocol: Request.Scheme); // http یا https
|
||||
@@ -72,7 +72,8 @@ public class FinancialController : ClientBaseController
|
||||
{
|
||||
Amount = balanceAmount.Amount,
|
||||
ContractingPartyId = balanceAmount.ContractingPartyId,
|
||||
CallBackUrl = request.BaseUrl
|
||||
CallBackUrl = request.BaseUrl,
|
||||
Gateway = PaymentTransactionGateWay.SepehrPay
|
||||
};
|
||||
|
||||
var transaction = await _paymentTransactionApplication.Create(transactionCommand);
|
||||
@@ -85,7 +86,7 @@ public class FinancialController : ClientBaseController
|
||||
var command = new CreatePaymentGatewayRequest()
|
||||
{
|
||||
CallBackUrl = callbackUrl,
|
||||
Amount = balanceAmount.Amount/10,
|
||||
Amount = balanceAmount.Amount,
|
||||
TransactionId = transaction.SendId.ToString(),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user