Introduced the SepehrPaymentGateway to replace the previous payment gateway, AqayePardakht. Added `Rrn` and `DigitalReceipt` columns to the `PaymentTransactions` table for improved payment tracking and verification. Updated the Entity Framework model and mappings to reflect these changes. Refactored payment transaction logic to support the new gateway, including creating, verifying, and handling payments. Added new request/response models for Sepehr gateway integration. Enhanced error handling and financial statement creation upon successful payment verification. Removed legacy code and updated dependency injection for the Parbad library.
99 lines
2.9 KiB
C#
99 lines
2.9 KiB
C#
using System;
|
|
using _0_Framework.Domain;
|
|
using CompanyManagment.App.Contracts.PaymentTransaction;
|
|
|
|
namespace Company.Domain.PaymentTransactionAgg;
|
|
|
|
/// <summary>
|
|
/// نمایانگر یک تراکنش پرداخت شامل جزئیات طرف قرارداد، اطلاعات بانکی، وضعیت تراکنش و مبلغ.
|
|
/// </summary>
|
|
public class PaymentTransaction:EntityBase
|
|
{
|
|
/// <summary>
|
|
/// سازنده کلاس PaymentTransaction با دریافت اطلاعات تراکنش.
|
|
/// </summary>
|
|
/// <param name="contractingPartyId">شناسه طرف قرارداد</param>
|
|
/// <param name="amount">مبلغ تراکنش</param>
|
|
/// <param name="contractingPartyName"></param>
|
|
/// <param name="callBackUrl"></param>
|
|
public PaymentTransaction(long contractingPartyId,
|
|
double amount,
|
|
string contractingPartyName,string callBackUrl,
|
|
PaymentTransactionGateWay gateway)
|
|
{
|
|
ContractingPartyId = contractingPartyId;
|
|
Status = PaymentTransactionStatus.Pending;
|
|
Amount = amount;
|
|
ContractingPartyName = contractingPartyName;
|
|
CallBackUrl = callBackUrl;
|
|
Gateway = gateway;
|
|
}
|
|
|
|
/// <summary>
|
|
/// تاریخ و زمان انجام پرداخت
|
|
/// </summary>
|
|
public DateTime TransactionDate { get; private set; }
|
|
|
|
/// <summary>
|
|
/// شناسه طرف حساب
|
|
/// </summary>
|
|
public long ContractingPartyId { get; private set; }
|
|
|
|
/// <summary>
|
|
/// نام طرف حساب
|
|
/// </summary>
|
|
public string ContractingPartyName { get; private set; }
|
|
|
|
/// <summary>
|
|
/// نام بانک
|
|
/// </summary>
|
|
public string BankName { get; private set; }
|
|
|
|
/// <summary>
|
|
/// شماره کارت
|
|
/// </summary>
|
|
public string CardNumber { get; private set; }
|
|
|
|
/// <summary>
|
|
/// وضعیت تراکنش پرداخت
|
|
/// </summary>
|
|
public PaymentTransactionStatus Status { get; private set; }
|
|
|
|
/// <summary>
|
|
/// مبلغ تراکنش
|
|
/// </summary>
|
|
public double Amount { get; private set; }
|
|
|
|
/// <summary>
|
|
/// شناسه یکتای تراکنش
|
|
/// </summary>
|
|
public string TransactionId { get; private set; }
|
|
|
|
public string CallBackUrl { get; private set; }
|
|
public PaymentTransactionGateWay Gateway { get; private set; }
|
|
public string Rrn { get; private set; }
|
|
public string DigitalReceipt { get; private set; }
|
|
|
|
|
|
public void SetPaid(string cardNumber,string bankName,string rrn,string digitalReceipt)
|
|
{
|
|
Status = PaymentTransactionStatus.Success;
|
|
TransactionDate = DateTime.Now;
|
|
CardNumber = cardNumber;
|
|
BankName = bankName;
|
|
Rrn = rrn;
|
|
DigitalReceipt = digitalReceipt;
|
|
|
|
}
|
|
public void SetFailed()
|
|
{
|
|
Status = PaymentTransactionStatus.Failed;
|
|
TransactionDate = DateTime.Now;
|
|
}
|
|
public void SetTransactionId(string transactionId)
|
|
{
|
|
TransactionId = transactionId;
|
|
}
|
|
}
|
|
|