69 lines
2.4 KiB
C#
69 lines
2.4 KiB
C#
using _0_Framework.Application;
|
|
using CompanyManagment.App.Contracts.PaymentTransaction;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
namespace ServiceHost.Pages.CallBack
|
|
{
|
|
[IgnoreAntiforgeryToken]
|
|
public class IndexModel : PageModel
|
|
{
|
|
private readonly IPaymentTransactionApplication _paymentTransactionApplication;
|
|
|
|
public IndexModel(IPaymentTransactionApplication paymentTransactionApplication)
|
|
{
|
|
_paymentTransactionApplication = paymentTransactionApplication;
|
|
}
|
|
|
|
public void OnGet(string? transid, string? cardnumber, string? tracking_number, string status)
|
|
{
|
|
if (string.IsNullOrEmpty(cardnumber) || string.IsNullOrEmpty(tracking_number))
|
|
{
|
|
ViewData["message"] = "پرداخت ناموفق بوده است";
|
|
return;
|
|
}
|
|
else if (status == "1")
|
|
{
|
|
ViewData["message"] = "پرداخت موفق بوده است";
|
|
return;
|
|
|
|
}
|
|
}
|
|
public void OnPost(string? transid, string? cardnumber, string? tracking_number, string? status)
|
|
{
|
|
var command = new CreatePaymentTransaction()
|
|
{
|
|
CardNumber = cardnumber,
|
|
Amount = 10000,
|
|
BankAccountHolderName = "تست",
|
|
ShebaNumber = "",
|
|
TransactionId = transid,
|
|
ContractingPartyId = 0,
|
|
ContractingPartyName = "نام طرف حساب",
|
|
AccountNumber = "",
|
|
BankName = "سامان"
|
|
|
|
};
|
|
if (string.IsNullOrEmpty(cardnumber) || string.IsNullOrEmpty(tracking_number))
|
|
{
|
|
ViewData["message"] = "پرداخت ناموفق بوده است";
|
|
command.Status = PaymentTransactionStatus.Failed;
|
|
}
|
|
else if (status == "1")
|
|
{
|
|
ViewData["message"] = "پرداخت موفق بوده است";
|
|
command.Status = PaymentTransactionStatus.Success;
|
|
|
|
}
|
|
else
|
|
{
|
|
ViewData["message"] = "پرداخت ناموفق بوده است";
|
|
command.Status = PaymentTransactionStatus.Failed;
|
|
}
|
|
|
|
_paymentTransactionApplication.Create(command);
|
|
|
|
}
|
|
}
|
|
}
|