public PaymentTransaction AddSuccessTransaction(string customerId, string invoiceNum, string invoiceId, decimal amount, HyperPayResponse hyperPay) { try { PaymentTransaction transaction = new PaymentTransaction() { CustomerId = customerId, ContractId = invoiceId, PaymentStatus = hyperPay.RequiredCode, PaymentStatusName = hyperPay.RequiredValue, Amount = Convert.ToDecimal(amount), Who = 2, EntityName = "Successfull Payment Transaction for Domestic Invoice No [ " + invoiceNum + " ] with Total price of : [ " + amount + " SR ] and customer : [ " + customerId + " ]", IsVoucherSaved = false, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, TransactionType = (int)TransactionType.DomesticInvoice, TransactionTypeName = TransactionType.DomesticInvoice.ToString() }; using (var paymentMgr = new PaymentManager()) { transaction = paymentMgr.CreatePaymentTransaction(transaction); return(transaction); } } catch (Exception ex) { IExceptionLogger logger = new DefaultExceptionLogger(); logger.Log("Error", ex); return(null); } }
public PaymentTransaction AddFailTransaction(string customerId, string invoiceNum, string invoiceId, decimal amount, HyperPayResponse hyperPay) { try { PaymentTransaction transaction = new PaymentTransaction() { CustomerId = customerId, ContractId = invoiceId, Amount = amount, Who = 2, EntityName = "Failed Payment Transaction for Contract Number [ " + invoiceNum + " ] with Total price of : [ " + amount + " SR ] and customer : [ " + customerId + " ]", IsVoucherSaved = false, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, TransactionType = (int)TransactionType.DomesticInvoice, TransactionTypeName = TransactionType.DomesticInvoice.ToString() }; if (String.IsNullOrEmpty(hyperPay.CheckoutId)) { transaction.PaymentStatus = "000000"; transaction.PaymentStatusName = "Checkout payment failed"; } else { transaction.PaymentStatus = hyperPay.RequiredCode; transaction.PaymentStatusName = hyperPay.RequiredValue; } using (var paymentMgr = new PaymentManager()) { transaction = paymentMgr.CreatePaymentTransaction(transaction); return(transaction); } } catch (Exception ex) { IExceptionLogger logger = new DefaultExceptionLogger(); logger.Log("Error", ex); return(null); } }