public PaymentDataModel ConvertToDataModel(DataRow paymentRow) { var result = new PaymentDataModel(); result.PaymentID = paymentRow.Field <int>("PaymentID"); result.PaymentTotal = paymentRow.Field <decimal?>("PaymentTotal"); return(result); }
/// <summary> /// Updates the data models /// </summary> private void UpdateDataModels() { _paymentDataModel = _salesManagementService.PaymentDataModel; _productDataModel = _salesManagementService.ProductDataModel; _productDeliveryDataModel = _salesManagementService.ProductDeliveryDataModel; _purchasePriceDataModel = _salesManagementService.PurchasePriceDataModel; _sellingPriceDataModel = _salesManagementService.SellingPriceDataModel; _paymentUnitsTable = _salesManagementService.PaymentUnitsTable; }
/// <summary> /// Convert this PaymentDataModel to a PaymentInfo object. /// </summary> /// <param name="paymentData">The PaymentData to convert.</param> /// <returns>A PaymentInfo containing the same data.</returns> public static PaymentInfo ToPaymentInfo(this PaymentDataModel paymentData) { DateTime expiration = new DateTime(paymentData.ExipryYear, paymentData.ExpiryMonth, 1); var output = new PaymentInfo { CardNumber = paymentData.CardNumber, NameOnCard = paymentData.NameOnCard, ExpirationDate = expiration, CVV = paymentData.CVV }; return(output); }
public ActionResult Payment() { // Get SelectedFlightsModel stored in session data. var selectedFlights = (SelectedFlightsModel)Session["selectedFlightsModel"]; if (selectedFlights is null) { return(View("Index")); } PaymentDataModel model = new PaymentDataModel { SelectedFlights = selectedFlights }; return(View(model)); }
public bool AddPayment(PaymentDataModel payment) { using (OleDbCommand oleDbCommand = new OleDbCommand()) { // Set the command object properties oleDbCommand.Connection = new OleDbConnection(ConnectionString); oleDbCommand.CommandType = CommandType.Text; oleDbCommand.CommandText = PaymentScripts.sqlInsertPayment; // Add the input parameters to the parameter collection oleDbCommand.Parameters.AddWithValue("@PaymentTotal", payment.PaymentTotal ?? (object)DBNull.Value); // Open the connection, execute the query and close the connection oleDbCommand.Connection.Open(); var rowsAffected = oleDbCommand.ExecuteNonQuery(); oleDbCommand.Connection.Close(); return(rowsAffected > 0); } }
public async Task <ActionResult> Payment(PaymentDataModel paymentData) { // Populate paymentData model with SelectedFlightsModel data. var selectedFlightsModel = (SelectedFlightsModel)Session["selectedFlightsModel"]; paymentData.SelectedFlights = selectedFlightsModel; if (!ModelState.IsValid) { return(View(paymentData)); } User user = await _dataAccess.FindByNameAsync(User.Identity.Name); SelectedFlights selectedFlights = paymentData.SelectedFlights.ToSelectedFlights(); PaymentInfo paymentInfo = paymentData.ToPaymentInfo(); // Make booking. MethodResult result = await _bookingManager.MakeBookingAsync(user, selectedFlights, paymentInfo); // If booking did not succeed. if (result.Succeeded == false) { // Add errors to model. foreach (var error in result.Errors) { ModelState.AddModelError("", error); } return(View(paymentData)); } // Booking was successful. // Add details to session data. Session.Add("bookingInformation", paymentData); return(RedirectToAction("Confirmation")); }
/// <summary> /// Method to update payment unit details /// </summary> /// <param name="payment">payment model</param> /// <returns></returns> public bool UpdatePayment(PaymentDataModel payment) { return(paymentAccess.UpdatePayment(payment)); }
/// <summary> /// Method to create new payment /// </summary> /// <param name="payment">payment data model</param> /// <returns>true or false</returns> public bool AddPayment(PaymentDataModel payment) { return(paymentAccess.AddPayment(payment)); }
public PaymentResultModel ApplyPayment(PaymentDataModel requestMdoel) { var result = new PaymentResultModel(); var userContext = _userHandler.GetUserContext(); var invoiceDetailSpecification = new InvoiceSpecification(_clinicId); invoiceDetailSpecification.AddInvoiceId(requestMdoel.InvoiceId); var invoice = _invoiceRepository.GetSingleBySpec(invoiceDetailSpecification); if (invoice != null) { var payementResult = _stripePaymentService.ProcessPayment((StripeBasicRequestModel)requestMdoel); result = payementResult; var cardLast4 = requestMdoel.CreditCard.GetCardF4L4(); result.CardLast4 = cardLast4; if (payementResult.Success && payementResult.Approved) { var payment = new Payment { ClinicId = _clinicId, Description = requestMdoel.Note, PaymentDate = DateTime.UtcNow, PaymentMethodTypeId = (int)PaymentMethodType.Visa, PaymentStatusTypeId = (int)requestMdoel.PaymentStatusType, PaymentTypeId = (int)requestMdoel.PaymentType, UpdatedBy = userContext.SiteUserId, UpdatedDateUtc = DateTime.UtcNow, Amount = requestMdoel.PaymentAmount, TransactionId = payementResult.TransactionId, AuthorizationCode = payementResult.AuthCode, CardToken = payementResult.CardToken, CardF4L4 = cardLast4 }; var invoicePayment = new InvoicePayment { AmountPaid = requestMdoel.PaymentAmount, InvoiceId = requestMdoel.InvoiceId, Payment = payment, Note = requestMdoel.Note }; _invoicePaymentRepository.AddOnly(invoicePayment); var patientCardOnFile = new PatientCardOnFile { Active = true, CardF4L4 = requestMdoel.CreditCard.GetCardF4L4(), CardToken = payementResult.CardToken, UpdatedDateUtc = DateTime.UtcNow, PatientId = invoice.PatientId, UpdatedBy = userContext.SiteUserId }; _patientCardOnFileRepository.AddOnly(patientCardOnFile); invoice.AmountPaid += requestMdoel.PaymentAmount; _invoicePaymentRepository.SaveAll(); result.AmountPaidTotal = invoice.AmountPaid; } else { result.Message = "Process payment failed. "; } } else { result.Message = "Invalid invoice Id, Please choose right one and try again. "; } return(result); }
public PaymentResultModel Void(PaymentDataModel requestMdoel) { throw new NotImplementedException(); }