private void CompleteModel(ProductOrderItemEditModel model) { if (model.Payments != null) { model.Payments = new PaymentEditModel { PaymentFlow = PaymentFlow.Out, AllowedPaymentTypes = new[] { new OrderedPair <long, string>( PaymentType.Check.PersistenceLayerId, PaymentType.Check.Name) } } } ; else { model.Payments.PaymentFlow = PaymentFlow.Out; model.Payments.AllowedPaymentTypes = new[] { new OrderedPair <long, string>( PaymentType.Check.PersistenceLayerId, PaymentType.Check.Name) }; } var order = model.Order; if (order.PaymentsApplied != null && order.PaymentsApplied.Count > 0 && order.PaymentsApplied.Where(pa => pa.PaymentType == PaymentType.CreditCard && pa.Amount > 0).Count() > 0) { var cardPayment = (ChargeCardPayment)order.PaymentsApplied.Where(pa => pa.PaymentType == PaymentType.CreditCard).OrderByDescending( pa => pa.DataRecorderMetaData.DateCreated).FirstOrDefault(); string reasonForFailure; if (IoC.Resolve <IChargeCardService>().IsCardValidforRefund(cardPayment, 0, out reasonForFailure)) { model.Payments.ChargeCardonFile = new ChargeCardPaymentEditModel() { ChargeCardPayment = cardPayment, ChargeCard = _chargeCardRepository.GetById(cardPayment.ChargeCardId) }; model.Payments.AllowedPaymentTypes = model.Payments.AllowedPaymentTypes.Concat(new[] { new OrderedPair <long, string>( PaymentType.CreditCardOnFile_Value, PaymentType.CreditCardOnFile_Text) }); } } model.Payments.ExistingBillingAddress = Mapper.Map <Address, AddressEditModel>(_customerRepository.GetCustomer(model.CustomerId).BillingAddress) ?? new AddressEditModel(); }
public void ProcessPayment(PaymentEditModel paymentEditModel, long eventCustomerId, long customerId, bool isAmexFullPayment) { if (paymentEditModel != null && paymentEditModel.Payments != null && paymentEditModel.Payments.Any(p => p.ChargeCard != null || p.ECheck != null || p.GiftCertificate != null || p.Check != null)) { var aexPayment = paymentEditModel.Payments.SingleOrDefault(p => p.ChargeCard != null && p.ChargeCard.ChargeCard != null && p.ChargeCard.ChargeCard.TypeId == ChargeCardType.AmericanExpress); if (aexPayment != null && !isAmexFullPayment) { aexPayment.Amount = Math.Round(aexPayment.Amount / 2, 2); aexPayment.ChargeCard.ChargeCardPayment.Amount = aexPayment.Amount; } _paymentController.ManagePayment(paymentEditModel, customerId, (System.Web.HttpContext.Current != null ? System.Web.HttpContext.Current.Request.UserHostAddress : ""), string.Concat(customerId, "_", eventCustomerId)); } if (paymentEditModel != null && paymentEditModel.Payments != null && paymentEditModel.Payments.Any(p => p.Insurance != null)) { var insurancePayment = paymentEditModel.Payments.Where(p => p.Insurance != null).Select(p => p.Insurance).SingleOrDefault(); if (insurancePayment != null && insurancePayment.EligibilityId > 0 && insurancePayment.InsurancePayment.AmountToBePaid > 0) { var chargeCard = _chargeCardRepository.GetById(insurancePayment.ChargeCardId); chargeCard.DataRecorderMetaData.DataRecorderCreator.Id = customerId; _chargeCardRepository.Save(chargeCard); _eligibilityRepository.SaveEventCustomerEligibility(eventCustomerId, insurancePayment.EligibilityId, insurancePayment.ChargeCardId); } } }
private void CompleteEditModel(RefundRequestResultEditModel model, long customerId) { string value = _configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.CancellationFee); if (!string.IsNullOrEmpty(value)) { decimal fee; Decimal.TryParse(value.Trim(), out fee); model.CancellationFee = fee; } if (model.PaymentEditModel == null) { model.PaymentEditModel = new PaymentEditModel { PaymentFlow = PaymentFlow.Out }; } if (_isEccEnabled) { model.PaymentEditModel.AllowedPaymentTypes = new[] { new OrderedPair <long, string>(PaymentType.Check.PersistenceLayerId, PaymentType.Check.Name), new OrderedPair <long, string>(PaymentType.Cash.PersistenceLayerId, PaymentType.Cash.Name), new OrderedPair <long, string>(PaymentType.CreditCard.PersistenceLayerId, PaymentType.CreditCard.Name) } } ; else { model.PaymentEditModel.AllowedPaymentTypes = new[] { new OrderedPair <long, string>(PaymentType.Check.PersistenceLayerId, PaymentType.Check.Name), new OrderedPair <long, string>(PaymentType.Cash.PersistenceLayerId, PaymentType.Cash.Name) } }; var order = _orderRepository.GetOrder(model.OrderId); var validCardPayment = order.PaymentsApplied.Where(pi => pi.PaymentType == PaymentType.CreditCard).OrderBy( pi => pi.DataRecorderMetaData.DateCreated).Select(pi => (ChargeCardPayment)pi).LastOrDefault(); if (validCardPayment != null && (_isEccEnabled || (validCardPayment.Amount > 0 && validCardPayment.DataRecorderMetaData.DateCreated > DateTime.Now.Date.AddDays(-120) && ProcessorResponse.IsValidResponseString(validCardPayment.ProcessorResponse)))) { model.PaymentEditModel.ChargeCardonFile = new ChargeCardPaymentEditModel() { ChargeCardPayment = validCardPayment, ChargeCard = _chargeCardRepository.GetById(validCardPayment.ChargeCardId) }; model.PaymentEditModel.AllowedPaymentTypes = model.PaymentEditModel.AllowedPaymentTypes.Concat(new[] { new OrderedPair <long, string>(PaymentType.CreditCardOnFile_Value, PaymentType.CreditCardOnFile_Text) }); } model.PaymentEditModel.ExistingBillingAddress = Mapper.Map <Address, AddressEditModel>(_customerRepository.GetCustomer(customerId).BillingAddress) ?? new AddressEditModel(); }
private PaymentViewData GetPaymentInstrumentInformation(PaymentInstrument paymentInstrument, PaymentViewData paymentViewData) { if (paymentInstrument is CheckPayment) { var checkPayment = paymentInstrument as CheckPayment; paymentViewData.InstrumentNumber = checkPayment.Check.CheckNumber; } else if (paymentInstrument is ECheckPayment) { var eCheckPayment = paymentInstrument as ECheckPayment; var processorResponse = eCheckPayment.ProcessorResponse.Split('|'); paymentViewData.ProcessorResponse = processorResponse.Length >= 6 ? processorResponse.GetValue(6).ToString() : "-N/A-"; paymentViewData.InstrumentNumber = eCheckPayment.ECheck.CheckNumber; } else if (paymentInstrument is ChargeCardPayment) { var chargeCardPayment = paymentInstrument as ChargeCardPayment; paymentViewData.ProcessorResponse = "-N/A-"; if (ProcessorResponse.IsValidResponseString(chargeCardPayment.ProcessorResponse)) { paymentViewData.ProcessorResponse = new ProcessorResponse(chargeCardPayment.ProcessorResponse).TransactionCode; } var chargeCard = _chargeCardRepository.GetById(chargeCardPayment.ChargeCardId); if (chargeCard != null) { paymentViewData.InstrumentDate = chargeCard.ExpirationDate.ToString("MM/yyyy"); paymentViewData.InstrumentNumber = chargeCard.Number.Length > 3 ? chargeCard.TypeId + " - ends with " + chargeCard.Number.Substring( chargeCard.Number.Length - 4, 4) : chargeCard.Number; } } else if (paymentInstrument is InsurancePayment) { var insurancePayment = paymentInstrument as InsurancePayment; if (insurancePayment.AmountToBePaid > insurancePayment.Amount) { paymentViewData.ProcessorResponse = "Amount: $" + insurancePayment.AmountToBePaid.ToString("0.00") + ", Status: Pending for settlement"; } else { paymentViewData.ProcessorResponse = "Amount: $" + insurancePayment.AmountToBePaid.ToString("0.00") + ", Status: Payment settled"; } } return(paymentViewData); }
// // GET: /Scheduling/Insurance/ public ActionResult Edit(long chargeCardId = 0) { if (chargeCardId > 0) { var chargeCard = _chargeCardRepository.GetById(chargeCardId); var model = new EligibilityEditModel { CardDetail = chargeCard, HideCardDetails = true }; return(View(model)); } return(View(new EligibilityEditModel())); }
public OnlineSchedulingCustomerInfoEditModel GetPaymentInfo(string guid) { var onlineRequestValidationModel = _tempcartService.ValidateOnlineRequest(guid); if (onlineRequestValidationModel.RequestStatus != OnlineRequestStatus.Valid) { return new OnlineSchedulingCustomerInfoEditModel { RequestValidationModel = onlineRequestValidationModel } } ; var tempCart = onlineRequestValidationModel.TempCart; var model = new OnlineSchedulingCustomerInfoEditModel { ProcessAndCartViewModel = _eventSchedulerService.GetOnlineCart(tempCart), EventCustomerOrderSummaryModel = _eventSchedulerService.GetEventCustomerOrderSummaryModel(guid), CustomerEditModel = new SchedulingCustomerEditModel { EnableTexting = _enableTexting }, SourceCodeApplyEditModel = _eventSchedulerService.GetSourceCodeApplied(tempCart), RequestValidationModel = onlineRequestValidationModel }; var newsletterprompt = Convert.ToBoolean(_configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.EnableNewsletterPrompt)); if (newsletterprompt && model.EventCustomerOrderSummaryModel != null && model.EventCustomerOrderSummaryModel.EventType == EventType.Retail) { model.RequestForNewsLetterDescription = _toolTipRepository.GetToolTipContentByTag(ToolTipType.OnlineNewsletterDescription); model.ShowNewsLetterPrompt = true; } model.EventCustomerOrderSummaryModel = _eventSchedulerService.GetEventCustomerOrderSummaryModel(guid); model.StateList = _stateRepository.GetAllStates().ToList().Select(x => new OrderedPair <long, string>(x.Id, x.Name)); var customer = tempCart.CustomerId.HasValue ? _customerRepository.GetCustomer(tempCart.CustomerId.Value) : null; if (customer == null && tempCart.ProspectCustomerId.HasValue && tempCart.ProspectCustomerId.Value > 0) { model.CustomerEditModel = _prospectCustomerService.GetforProspectCustomerId(tempCart.ProspectCustomerId.Value); } else if (customer != null) { model.CustomerEditModel = Mapper.Map <Customer, SchedulingCustomerEditModel>(customer); model.CustomerEditModel.ShippingAddress = Mapper.Map <Address, AddressEditModel>(customer.Address); model.CustomerEditModel.ConfirmationToEnablTexting = customer.EnableTexting; //model.CustomerEditModel.ShippingAddress.Id = tempCart.ShippingAddressId.HasValue ? tempCart.ShippingAddressId.Value : 0; } //payment if (model.PaymentEditModel == null) { model.PaymentEditModel = new PaymentEditModel { PaymentFlow = PaymentFlow.In, Amount = model.EventCustomerOrderSummaryModel.AmountDue.HasValue ? model.EventCustomerOrderSummaryModel.AmountDue.Value : 0, ShippingAddressSameAsBillingAddress = true }; } if (customer != null && ((customer.BillingAddress != null && customer.BillingAddress.StreetAddressLine1 != OnlineAddress1) || (customer.Address != null && customer.Address.StreetAddressLine1 != OnlineAddress1))) { model.PaymentEditModel.ExistingBillingAddress = Mapper.Map <Address, AddressEditModel>(customer.BillingAddress ?? customer.Address); model.PaymentEditModel.ExistingBillingAddress.Id = customer.BillingAddress != null ? customer.BillingAddress.Id : 0; model.PaymentEditModel.ExistingShippingAddress = Mapper.Map <Address, AddressEditModel>(customer.BillingAddress ?? customer.Address); model.PaymentEditModel.ExistingShippingAddress.Id = customer.Address != null ? customer.Address.Id : 0; } model.RequestForNewsLetter = model.EventCustomerOrderSummaryModel != null && model.EventCustomerOrderSummaryModel.EventType == EventType.Retail; model.PaymentEditModel.AllowedPaymentTypes = new[] { new OrderedPair <long, string>(PaymentType.CreditCard.PersistenceLayerId, PaymentType.CreditCard.Name), new OrderedPair <long, string>(PaymentType.ElectronicCheck.PersistenceLayerId, PaymentType.ElectronicCheck.Name), new OrderedPair <long, string>(PaymentType.GiftCertificate.PersistenceLayerId, PaymentType.GiftCertificate.Name) }; var payLaterOnlineRegistration = Convert.ToBoolean(_configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.PayLaterOnlineRegistration)); if (payLaterOnlineRegistration) { var payLaterOption = new[] { new OrderedPair <long, string>(PaymentType.Onsite_Value, PaymentType.PayLater_Text) }; model.PaymentEditModel.AllowedPaymentTypes = model.PaymentEditModel.AllowedPaymentTypes.Concat(payLaterOption); } var eventId = model.EventCustomerOrderSummaryModel.EventId.HasValue ? model.EventCustomerOrderSummaryModel.EventId.Value : 0; var packageId = model.SourceCodeApplyEditModel.Package != null ? model.SourceCodeApplyEditModel.Package.FirstValue : 0; var addOnTestIds = model.SourceCodeApplyEditModel.SelectedTests != null?model.SourceCodeApplyEditModel.SelectedTests.Select(st => st.FirstValue).ToArray() : null; var testCoveredByInsurance = _eligibilityService.CheckTestCoveredByinsurance(eventId, packageId, addOnTestIds); if (testCoveredByInsurance) { var insurancePaymentOption = new[] { new OrderedPair <long, string>(PaymentType.Insurance.PersistenceLayerId, PaymentType.Insurance.Name) }; model.PaymentEditModel.AllowedPaymentTypes = model.PaymentEditModel.AllowedPaymentTypes.Concat(insurancePaymentOption); } if (model.EventCustomerOrderSummaryModel.AmountDue != null && model.EventCustomerOrderSummaryModel.AmountDue > 0) { if (payLaterOnlineRegistration) { model.PaymentEditModel.Payments = new[] { new PaymentInstrumentEditModel { Amount = model.EventCustomerOrderSummaryModel.AmountDue.Value, PaymentType = Convert.ToInt32(PaymentType.Onsite_Value) } }; } else { model.PaymentEditModel.Payments = new[] { new PaymentInstrumentEditModel { Amount = model.EventCustomerOrderSummaryModel.AmountDue.Value, ChargeCard = new ChargeCardPaymentEditModel() { ChargeCard = (tempCart.ChargeCardId.HasValue && tempCart.ChargeCardId.Value > 0) ?_chargeCardRepository.GetById(tempCart.ChargeCardId.Value) :new ChargeCard() } } }; if (testCoveredByInsurance && tempCart.EligibilityId.HasValue && tempCart.EligibilityId.Value > 0 && tempCart.ChargeCardId.HasValue && tempCart.ChargeCardId.Value > 0) { var insurancePayment = new[] { new PaymentInstrumentEditModel { Insurance = new InsurancePaymentEditModel { EligibilityId = tempCart.EligibilityId.Value, ChargeCardId = tempCart.ChargeCardId.Value } } }; model.PaymentEditModel.Payments = model.PaymentEditModel.Payments.Concat(insurancePayment); } } } else { model.PaymentEditModel.ShippingAddressSameAsBillingAddress = false; } return(model); }