private PaymentSlip MakePaymentEntry(Request request) { try { Payment payment = new Payment(); payment.DateEntered = request.Date; payment.Mode = new PaymentMode() { Id = (int)PaymentMode.List.Online }; payment.ServiceCharge = request.ServiceCharge; payment.Person = request.FromPerson; payment.Paid = false; PaymentSlip paymentSlip = _paymentService.Pay(payment); if (paymentSlip == null || paymentSlip.Payment == null || paymentSlip.Payment.Id <= 0) { throw new Exception("Payment entry creation failed!"); } return(paymentSlip); } catch (Exception) { throw; } }
public PaymentSlip Pay(Payment payment) { try { if (payment == null || payment.Person == null || payment.Person.Id <= 0 || payment.Person.Type == null || payment.Person.Type.Id <= 0) { throw new ArgumentNullException("payment or payment.Person or payment.Person.Type"); } PaymentSlip slip = null; using (TransactionScope transaction = new TransactionScope()) { //payment.ServiceCharge = _serviceCharge.GetChargesBy(payment.Person.Type); Payment newPayment = Create(payment); if (newPayment == null || newPayment.Id <= 0) { throw new Exception("Payment operation failed! Please try again. But contact your system administrator after three unsuccessful trials."); } slip = GenerateSlip(payment); //PayHelper(payment); //invoice = GenerateInvoice(payment); transaction.Complete(); } return(slip); } catch (Exception) { throw; } }
public PaymentSlip GetPaymentSlipBy(Person person) { try { if (person == null || person.Id <= 0 || person.Type == null || person.Type.Id <= 0) { throw new ArgumentNullException("person"); } ServiceCharge serviceCharge = _serviceCharge.GetChargesBy(person.Type); if (serviceCharge == null || serviceCharge.Id <= 0) { throw new Exception("Service Charge retreival failed! Please try again"); } Payment payment = _da.GetModelBy <Payment, PAYMENT>(p => p.Person_Id == person.Id && p.Service_Charge_Id == serviceCharge.Id); PaymentSlip slip = GenerateSlip(payment); return(slip); } catch (Exception) { throw; } }
public JsonResult Send(RequestViewModel viewModel) { JsonResult json = null; try { _viewModel = (RequestViewModel)TempData["RequestViewModel"]; if (_viewModel != null) { Request request = new Request(); request.FromPerson = _viewModel.Employer; request.ToPerson = _viewModel.Teacher.Person; request.RequestMessage = _da.GetModelBy <Message, MESSAGE>(x => x.Message_Id == 1); //new Message() { Id = 1 }; request.ServiceCharge = _viewModel.ServiceCharge; request.Status = new RequestStatus() { Id = (int)RequestStatus.List.Pending }; request.Date = DateTime.Now; List <RequestForEmploymentCostImplication> requestForEmploymentCostImplications = _viewModel.RequestCostImplications.Where(x => x.MonthlyPay > 0 && x.EmployerStudentCategory.Id > 0 && x.EmployerStudentCategory.NoOfStudent > 0).ToList(); if (requestForEmploymentCostImplications != null && requestForEmploymentCostImplications.Count > 0) { foreach (RequestForEmploymentCostImplication requestForEmploymentCostImplication in requestForEmploymentCostImplications) { requestForEmploymentCostImplication.TeacherAvailabilities = requestForEmploymentCostImplication.TeacherAvailabilities.Where(x => x.TeacherAvailability.IsAvailable == true).ToList(); } } request.ForEmploymentCostImplications = requestForEmploymentCostImplications; PaymentSlip paymentSlip = _requestService.Send(request); if (paymentSlip == null || paymentSlip.Payment == null || paymentSlip.Payment.Id <= 0) { json = Json(new { isValid = false, message = "Sending of request failed! Please try again" }, "text/html", JsonRequestBehavior.AllowGet); } else { TempData["PaymentViewModel"] = null; TempData["PaymentSlip"] = paymentSlip; json = Json(new { isValid = true, message = "Request has been successfully sent, and email and SMS has also been sent to the recipient" }, "text/html", JsonRequestBehavior.AllowGet); } } else { json = Json(new { isValid = false, message = "Error occurred! Empty input variables detected! Please contact your system administrator" }, "text/html", JsonRequestBehavior.AllowGet); } } catch (Exception ex) { _logger.LogError(ex); json = Json(new { isValid = false, message = ex.Message }, "text/html", JsonRequestBehavior.AllowGet); } TempData["RequestViewModel"] = _viewModel; return(json); }
public override Employer Save(Employer employer) { try { PaymentSlip slip = null; Employer newEmployer = null; using (TransactionScope transaction = new TransactionScope()) { byte[] passwordHash = _gateService.CreatePasswordHash(employer.LoginDetail.RawPassword); employer.LoginDetail.Password = passwordHash; newEmployer = _da.Create(employer); if (newEmployer == null || newEmployer.Person.Id <= 0) { throw new Exception("Employer registration failed! " + TRY_AGAIN); } employer.Person.Id = newEmployer.Person.Id; foreach (EmployerStudentCategory employerStudentCategory in employer.StudentCategories) { employerStudentCategory.Person = employer.Person; } bool saved = base.SaveStudentCategory(employer.StudentCategories); if (saved == false) { throw new Exception("Student Category save operation failed!"); } employer.Payments[0].ServiceCharge = _serviceCharge.GetChargesBy(employer.Person.Type); employer.Payments[0].Person = employer.Person; slip = _paymentService.Pay(employer.Payments[0]); if (slip == null || slip.Payment == null || slip.Payment.Id <= 0) { throw new Exception("Payment entry creation failed!"); } newEmployer.PaymentSlip = slip; transaction.Complete(); } return(newEmployer); } catch (Exception) { throw; } }
public PaymentSlip Send(Request request) { try { PaymentSlip paymentSlip = null; using (TransactionScope transaction = new TransactionScope()) { Request newRequest = _da.Create(request); if (newRequest == null || newRequest.Id <= 0) { throw new Exception("Sending of request failed! Please try again"); } foreach (RequestForEmploymentCostImplication requestForEmploymentCostImplication in request.ForEmploymentCostImplications) { requestForEmploymentCostImplication.Request = newRequest; RequestForEmploymentCostImplication newRequestForEmploymentCostImplication = _da.Create(requestForEmploymentCostImplication); if (newRequestForEmploymentCostImplication == null || newRequestForEmploymentCostImplication.Id <= 0) { throw new Exception("Cost implication save operation failed! Please try again"); } foreach (RequestForEmploymentTeacherAvailability requestForEmploymentTeacherAvailability in requestForEmploymentCostImplication.TeacherAvailabilities) { requestForEmploymentTeacherAvailability.CostImplication = newRequestForEmploymentCostImplication; } int rowsAdded = _da.Create(requestForEmploymentCostImplication.TeacherAvailabilities); if (rowsAdded <= 0 || rowsAdded != requestForEmploymentCostImplication.TeacherAvailabilities.Count) { throw new Exception("Storing Availability of teacher failed! Please try again"); } } paymentSlip = MakePaymentEntry(request); //SendSMS(request.RequestMessage.Text, "2348035303653"); SendEmail(request); transaction.Complete(); } return(paymentSlip); } catch (Exception) { throw; } }
public bool Add(long salesorderid, string paymentSlip) { var objinfra = _paymentSlipInfra.PaymentSlip(paymentSlip); var obj = new PaymentSlip() { DueDate = objinfra.paymentSlipTransaction.paymentSlip.dueDate, BarCode = objinfra.paymentSlipTransaction.paymentSlip.barCode, Status = objinfra.paymentSlipTransaction.paymentSlip.status, TransactionId = objinfra.paymentSlipTransaction.paymentSlip.id, TransactionKey = objinfra.paymentSlipTransaction.paymentSlip.key, SalesOrderId = salesorderid }; _salesOrderBusiness.UpdateStatus(salesorderid, Domain.Entities.Values.OrderStatus.PaymentApproved); return(_paymentSlipRepository.Insert(obj)); }
public override Teacher Save(Teacher teacher) { try { PaymentSlip slip = null; Teacher newTeacher = null; using (TransactionScope transaction = new TransactionScope()) { byte[] passwordHash = _gateService.CreatePasswordHash(teacher.LoginDetail.RawPassword); teacher.LoginDetail.Password = passwordHash; newTeacher = _da.Create(teacher); if (newTeacher == null || newTeacher.Person.Id <= 0) { throw new Exception("Teacher subscription operation failed! " + TRY_AGAIN); } teacher.Person.Id = newTeacher.Person.Id; string passportFilePath = SaveHelper(teacher); newTeacher.ImageFileUrl = passportFilePath; teacher.Payments[0].Person = teacher.Person; teacher.Payments[0].ServiceCharge = _serviceCharge.GetChargesBy(teacher.Person.Type); slip = _paymentService.Pay(teacher.Payments[0]); if (slip == null || slip.Payment == null || slip.Payment.Id <= 0) { throw new Exception("Payment entry creation failed!"); } newTeacher.PaymentSlip = slip; transaction.Complete(); } return(newTeacher); } catch (Exception) { throw; } }
private PaymentSlip GenerateSlip(Payment payment) { try { PaymentSlip slip = new PaymentSlip(); slip.Payment = payment; //slip.Number = payment.InvoiceNumber; //slip.IssuerName = payment.School.Name; //slip.IssuerLogoUrl = payment.School.LogoUrl; //slip.IssuerEmail = payment.School.Email; //slip.RecipientName = payment.Person.FullName; //slip.RecipientAddress = payment.Person.ContactAddress; //slip.RecipientPhone = payment.Person.MobilePhone; //slip.RecipientEmail = payment.Person.Email; //slip.Channel = payment.Channel.Name; //slip.Date = payment.DatePaid; //slip.Paid = payment.Paid; //InvoiceItem item = new InvoiceItem(); //item.Item = payment.FeeType.Name; //item.UnitCost = GetUnitCost(payment.FeeType); //item.TotalCost = item.UnitCost; //item.Quantity = 1; //slip.Items = new List<InvoiceItem>(); //slip.Items.Add(item); return(slip); } catch (Exception) { throw; } }
public ActionResult Slip() { try { _viewModel = (PaymentViewModel)TempData["PaymentViewModel"]; if (_viewModel == null) { _viewModel = new PaymentViewModel(); PaymentSlip slip = (PaymentSlip)TempData["PaymentSlip"]; if (slip == null || slip.Payment == null) { throw new Exception("Payment or its Slip cannot be null! Please contact your system administrator"); } _viewModel.PaymentSlip = slip; } if (_viewModel.PaymentSlip == null || _viewModel.PaymentSlip.Payment == null || _viewModel.PaymentSlip.Payment.ServiceCharge == null || _viewModel.PaymentSlip.Payment.ServiceCharge.Id <= 0) { throw new Exception("Error occurred! Slip details display operation failed due to empty input variables! Please contact your system administrator"); } //if (_viewModel.PaymentSlip == null || _viewModel.PaymentSlip.Payment == null || _viewModel.PaymentSlip.Payment.Id <= 0 || _viewModel.PaymentSlip.Payment.ServiceCharge == null || _viewModel.PaymentSlip.Payment.ServiceCharge.Id <= 0) //{ // throw new Exception("Error occurred! Slip details display operation failed due to empty input variables! Please contact your system administrator"); //} } catch (Exception ex) { _logger.LogError(ex); SetMessage(ex.Message, ApplicationMessage.Category.Error); } TempData["PaymentViewModel"] = _viewModel; return(View(_viewModel)); }
public async Task <string> Handle(UploadPaymentSlipCommand request, CancellationToken cancellationToken) { if (!_context.TransactionIndexs.Any(x => x.Id == request.TransactionIndexId)) { throw new NotFoundException(nameof(TransactionIndex), request.TransactionIndexId); } var transactionIndexAsset = await _context.TransactionIndexs .FindAsync(request.TransactionIndexId); var entity = new PaymentSlip { TransactionIndexId = request.TransactionIndexId, ImageUrl = await SaveImage(request.ImageUrl) }; _context.PaymentSlips.Add(entity); transactionIndexAsset.Status = Status.WaitingForConfirmation; await _context.SaveChangesAsync(cancellationToken); return("Success Uploads your payment slip"); }
public PaymentViewModel() { //Person = new Person(); //ServiceCharge = new ServiceCharge(); PaymentSlip = new PaymentSlip(); }