73 lines
2.7 KiB
C#
73 lines
2.7 KiB
C#
using _0_Framework.Application;
|
|
using _0_Framework.Application.PaymentGateway;
|
|
using CompanyManagment.App.Contracts.PaymentTransaction;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using Microsoft.Extensions.Options;
|
|
using System.Net.Http;
|
|
|
|
namespace ServiceHost.Pages.CallBack
|
|
{
|
|
[IgnoreAntiforgeryToken]
|
|
public class IndexModel : PageModel
|
|
{
|
|
private readonly IPaymentTransactionApplication _paymentTransactionApplication;
|
|
private readonly IPaymentGateway _paymentGateway;
|
|
|
|
|
|
public IndexModel(IPaymentTransactionApplication paymentTransactionApplication, IHttpClientFactory httpClientFactory, IOptions<AppSettingConfiguration> appSetting)
|
|
{
|
|
_paymentTransactionApplication = paymentTransactionApplication;
|
|
_paymentGateway = new AqayePardakhtPaymentGateway(httpClientFactory, appSetting);
|
|
}
|
|
|
|
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 async Task OnPost(string? transid, string? cardnumber, string? tracking_number, string bank, string invoice_id, string? status)
|
|
{
|
|
//var verify =await _paymentGateway.Verify(new VerifyPaymentGateWayRequest { Amount = 1000, TransactionId = transid });
|
|
var command = new CreatePaymentTransaction()
|
|
{
|
|
CardNumber = cardnumber,
|
|
Amount = 10000,
|
|
TransactionId = transid,
|
|
ContractingPartyId = 0,
|
|
ContractingPartyName = "تست تستی",
|
|
BankName = bank
|
|
|
|
};
|
|
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;
|
|
}
|
|
|
|
await _paymentTransactionApplication.Create(command);
|
|
|
|
}
|
|
}
|
|
}
|