public async Task <IActionResult> Edit(PaymentEditModel model)
 {
     try
     {
         return(Ok(await _paymentApi.EditPaymentAsync(model)));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemple #2
0
        public void VoidCreditCardGatewayRequests(PaymentEditModel paymentEditModel)
        {
            if (paymentEditModel.Payments == null || paymentEditModel.Payments.Count() < 1)
            {
                return;
            }

            var payments = paymentEditModel.Payments.Where(p => p.IsProcessed && (p.PaymentType == PaymentType.CreditCard.PersistenceLayerId || p.PaymentType == PaymentType.CreditCardOnFile_Value) && p.ChargeCard != null && p.ChargeCard.ChargeCardPayment != null);

            foreach (var payment in payments)
            {
                _chargeCardService.VoidRequest(payment.ChargeCard.ChargeCardPayment.ProcessorResponse);
            }
        }
        public IActionResult Payment(PaymentEditModel model)
        {
            var paymentResponse = this._safecharge.Payment(
                model.Currency,
                model.Amount,
                new PaymentOption
            {
                Card = new Card
                {
                    CardNumber      = "4000023104662535",
                    CardHolderName  = "John Smith",
                    ExpirationMonth = "12",
                    ExpirationYear  = "22",
                    CVV             = "217"
                }
            }).GetAwaiter().GetResult();

            return(View(new PaymentViewModel {
                PaymentResponse = paymentResponse
            }));
        }
Exemple #4
0
        public void CancelAppointment(long eventId, long customerId, PaymentEditModel paymentEditModel, long dataRecorderOrgRoleUserId, bool chargeCancellation = true)
        {
            using (var scope = new TransactionScope())
            {
                //var eventCustomer = UpdateEventCustomerforCancelAppointment(eventId, customerId);
                //if (eventCustomer == null) return;

                var orderController = new OrderController();
                var order           = orderController.CancelOrder(eventId, customerId, dataRecorderOrgRoleUserId,
                                                                  chargeCancellation);
                if (order == null)
                {
                    return;
                }

                long paymentId = _paymentController.SavePayment(paymentEditModel, dataRecorderOrgRoleUserId);
                if (paymentId > 0)
                {
                    var orderRepository = new OrderRepository();
                    orderRepository.ApplyPaymentToOrder(order.Id, paymentId);
                }
                scope.Complete();
            }
        }
        public void CreateOrder(TempCart tempCart, PaymentEditModel paymentEditModel = null)
        {
            if (tempCart.EventId == null || tempCart.CustomerId == null || tempCart.AppointmentId == null || (tempCart.EventPackageId == null && string.IsNullOrEmpty(tempCart.TestId)))
            {
                return;
            }

            var customer = _customerRepository.GetCustomer(tempCart.CustomerId.Value);
            var inDb     = _eventCustomerRepository.Get(tempCart.EventId.Value, tempCart.CustomerId.Value);

            var eventCustomer = new EventCustomer
            {
                Id                   = inDb != null ? inDb.Id : 0,
                EventId              = tempCart.EventId.Value,
                CustomerId           = tempCart.CustomerId.Value,
                DataRecorderMetaData = new DataRecorderMetaData
                {
                    DataRecorderCreator = new OrganizationRoleUser(tempCart.CustomerId.Value),
                    DateCreated         = DateTime.Now
                },
                OnlinePayment   = true,
                MarketingSource = tempCart.MarketingSource,
                NoShow          = false,
                TestConducted   = false,
                HIPAAStatus     = RegulatoryState.Unknown,
                EnableTexting   = customer.EnableTexting
            };

            using (var scope = new TransactionScope())
            {
                var appointment = _eventAppointmentService.CreateAppointment(tempCart.InChainAppointmentSlotIds, tempCart.CustomerId.Value);
                eventCustomer.AppointmentId = appointment.Id;
                eventCustomer = _eventCustomerRepository.Save(eventCustomer);

                //Moved code into ProcessPayment to Extract Common Code for API and Service
                ProcessPayment(paymentEditModel, eventCustomer.Id, customer.CustomerId, false);

                var orderables = new List <IOrderable>();

                if (tempCart.EventPackageId.HasValue)
                {
                    orderables.Add(_eventPackageRepository.GetById(tempCart.EventPackageId.Value));
                }


                var testIds = new List <long>();
                if (!string.IsNullOrEmpty(tempCart.TestId))
                {
                    string[] testIdStrings = tempCart.TestId.Split(new[] { ',' });
                    foreach (var testIdString in testIdStrings)
                    {
                        int i = 0;
                        if (int.TryParse(testIdString, out i))
                        {
                            testIds.Add(i);
                        }
                    }
                }

                if (testIds.Count > 0)
                {
                    var eventTests = _eventTestRepository.GetbyIds(testIds);
                    if (tempCart.EventPackageId.HasValue)
                    {
                        foreach (var eventTest in eventTests)
                        {
                            eventTest.Price = eventTest.WithPackagePrice;
                        }
                    }
                    orderables.AddRange(eventTests);
                }

                IEnumerable <ElectronicProduct> products = null;
                var productIds = new List <long>();
                if (!string.IsNullOrEmpty(tempCart.ProductId))
                {
                    string[] productIdStrings = tempCart.ProductId.Split(new[] { ',' });
                    foreach (var productIdIdString in productIdStrings)
                    {
                        int i = 0;
                        if (int.TryParse(productIdIdString, out i))
                        {
                            productIds.Add(i);
                        }
                    }
                }

                if (productIds.Count > 0)
                {
                    products = _productRepository.GetByIds(productIds);
                    orderables.AddRange(products);
                }

                if (orderables.IsNullOrEmpty())
                {
                    return;
                }

                SourceCode sourceCode = null;
                if (tempCart.SourceCodeId.HasValue && tempCart.SourceCodeId.Value > 0)
                {
                    var sourceCodeModel = GetSourceCodeApplied(tempCart);
                    sourceCode = new SourceCode
                    {
                        Id          = sourceCodeModel.SourceCodeId,
                        CouponCode  = sourceCodeModel.SourceCode,
                        CouponValue = sourceCodeModel.DiscountApplied
                    };
                }

                var shippingAddress = tempCart.ShippingAddressId.HasValue
                                          ? _addressRepository.GetAddress(tempCart.ShippingAddressId.Value)
                                          : null;

                ShippingDetail shippingDetail = null;
                if (tempCart.ShippingId != null && tempCart.ShippingId.Value > 0)
                {
                    var shippingOption = _shippingOptionRepository.GetById(tempCart.ShippingId.Value);
                    shippingDetail = new ShippingDetail
                    {
                        ShippingOption       = shippingOption,
                        ShippingAddress      = shippingAddress,
                        Status               = ShipmentStatus.Processing,
                        ActualPrice          = shippingOption.Price,
                        DataRecorderMetaData = new DataRecorderMetaData(tempCart.CustomerId.Value, DateTime.Now, null)
                    };
                    shippingDetail = _shippingController.OrderShipping(shippingDetail);
                }

                bool indentedLineItemsAdded = false;
                // TODO: applying hook to the system all the indented line items will be attached to the first order item.
                foreach (var orderable in orderables)
                {
                    if (!indentedLineItemsAdded && (orderable.OrderItemType == OrderItemType.EventPackageItem || orderable.OrderItemType == OrderItemType.EventTestItem))
                    {
                        _orderController.AddItem(orderable, 1, tempCart.CustomerId.Value, tempCart.CustomerId.Value, sourceCode, eventCustomer, shippingDetail, OrderStatusState.FinalSuccess);
                        indentedLineItemsAdded = true;
                    }
                    else
                    {
                        _orderController.AddItem(orderable, 1, tempCart.CustomerId.Value, tempCart.CustomerId.Value, OrderStatusState.FinalSuccess);
                    }
                }
                var order = _orderRepository.GetOrder(tempCart.CustomerId.Value, tempCart.EventId.Value);
                order = order == null?_orderController.PlaceOrder(OrderType.Retail, tempCart.CustomerId.Value) : _orderController.ActivateOrder(order);

                if (products != null && products.Count() > 0 && shippingDetail != null)
                {
                    foreach (var electronicProduct in products)
                    {
                        SaveProductShippingDetail(electronicProduct.Id, order, shippingAddress, customer.CustomerId);
                    }
                }

                if (paymentEditModel != null && paymentEditModel.Payments != null && paymentEditModel.Payments.Any(p => p.ChargeCard != null || p.ECheck != null || p.GiftCertificate != null))
                {
                    var paymentId = _paymentController.SavePayment(paymentEditModel, tempCart.CustomerId.Value);
                    _orderRepository.ApplyPaymentToOrder(order.Id, paymentId);
                }

                scope.Complete();
            }
        }
Exemple #6
0
        public void ManagePayment(PaymentEditModel paymentEditModel, long customerId, string ipAddress, string uniquePaymentReference)
        {
            if (paymentEditModel.Payments == null || paymentEditModel.Payments.Count() < 1)
            {
                return;
            }
            var customer = _customerRepository.GetCustomer(customerId);
            var payments = paymentEditModel.Payments.Where(p => p.Amount != 0);

            int index = 1;

            try
            {
                foreach (var payment in payments)
                {
                    if (payment.PaymentType == PaymentType.ElectronicCheck.PersistenceLayerId && paymentEditModel.PaymentFlow == PaymentFlow.In)
                    {
                        var response = _checkService.ChargefromECheck(payment.ECheck.ECheck,
                                                                      Mapper.Map <AddressEditModel, Address>(
                                                                          paymentEditModel.ExistingBillingAddress), customer, ipAddress,
                                                                      uniquePaymentReference);


                        if (response.ProcessorResult != ProcessorResponseResult.Accepted)
                        {
                            new NLogLogManager().GetLogger <PaymentController>().Info("ECheck Transaction - Details [RawResponse: " + response.RawResponse + "]");
                            throw new Exception("Transaction Failed!");
                        }

                        payment.IsProcessed = true;
                        payment.ECheck.ECheckPayment.ProcessorResponse = response.RawResponse;
                    }
                    else if ((payment.PaymentType == PaymentType.CreditCard.PersistenceLayerId || payment.PaymentType == PaymentType.CreditCardOnFile_Value) && payment.ChargeCard != null)
                    {
                        var transactionAmount = payment.ChargeCard.ChargeCardPayment.Amount;
                        if (paymentEditModel.PaymentFlow == PaymentFlow.Out)
                        {
                            transactionAmount = -1 * transactionAmount;
                        }

                        ProcessorResponse response = null;
                        if (paymentEditModel.PaymentFlow == PaymentFlow.Out)
                        {
                            if (_isEccEnabled)
                            {
                                response = _chargeCardService.ApplyRefundtoNewCard(transactionAmount, customer.Name,
                                                                                   payment.ChargeCard.ChargeCard,
                                                                                   payment.BillingAddress, ipAddress,
                                                                                   uniquePaymentReference + "(" + index +
                                                                                   ")", customer.Email != null ? customer.Email.ToString() : string.Empty);
                            }
                            else if (payment.PaymentType == PaymentType.CreditCardOnFile_Value)
                            {
                                var    cardPayment      = _chargeCardPaymentRepository.GetById(payment.ChargeCard.ChargeCardPayment.Id);
                                string reasonForFailure = "";
                                bool   isValidcard      = _chargeCardService.IsCardValidforRefund(cardPayment, payment.Amount, out reasonForFailure);
                                if (!isValidcard)
                                {
                                    throw new Exception(reasonForFailure);
                                }

                                string previousResponse = cardPayment.ProcessorResponse;
                                if (cardPayment.Amount == payment.Amount)
                                {
                                    response = _chargeCardService.VoidRequest(previousResponse);
                                    if (response.ProcessorResult != ProcessorResponseResult.Accepted)
                                    {
                                        response = _chargeCardService.ApplyRefundtoCardonFile(transactionAmount, payment.ChargeCard.ChargeCard.Number, payment.ChargeCard.ChargeCard.ExpirationDate, previousResponse);
                                    }
                                    else
                                    {
                                        new NLogLogManager().GetLogger <PaymentController>().Info("CC Void Request - Details [RawResponse: " + response.RawResponse + "]");
                                    }
                                }
                                else
                                {
                                    response = _chargeCardService.ApplyRefundtoCardonFile(transactionAmount, payment.ChargeCard.ChargeCard.Number, payment.ChargeCard.ChargeCard.ExpirationDate, previousResponse);
                                }
                            }
                            else
                            {
                                throw new Exception("Refund on the provided card is not allowed. Please choose any other option.");
                            }
                        }
                        else
                        {
                            response = _chargeCardService.ChargefromCard(transactionAmount, new Name(payment.ChargeCard.ChargeCard.NameOnCard), payment.ChargeCard.ChargeCard, payment.BillingAddress, ipAddress,
                                                                         uniquePaymentReference + "(" + index + ")", customer.Email != null ? customer.Email.ToString() : string.Empty);
                        }

                        if (response.ProcessorResult != ProcessorResponseResult.Accepted)
                        {
                            new NLogLogManager().GetLogger <PaymentController>().Info("CC Transaction - Details [RawResponse: " + response.RawResponse + "]");
                            throw new Exception("Transaction Failed!");
                        }

                        payment.IsProcessed = true;
                        payment.ChargeCard.ChargeCardPayment.ProcessorResponse = response.RawResponse;
                    }
                    index++;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(
                          "An exception caused while " + (paymentEditModel.PaymentFlow == PaymentFlow.Out ? "refunding" : "charging") + " amount. Message: " + ex.Message, ex);
            }
        }
Exemple #7
0
        public long SavePayment(PaymentEditModel paymentEditModel, long dataRecorderOrgRoleUserId)
        {
            if (paymentEditModel.Payments == null || paymentEditModel.Payments.Count() < 1)
            {
                return(0);
            }

            var payments           = paymentEditModel.Payments.Where(p => p.Amount != 0);
            var paymentInstruments = new List <PaymentInstrument>();

            var dataRecordermetaData = new DataRecorderMetaData()
            {
                DateCreated         = DateTime.Now,
                DataRecorderCreator = new OrganizationRoleUser(dataRecorderOrgRoleUserId)
            };

            foreach (var payment in payments)
            {
                if ((payment.PaymentType == PaymentType.CreditCard.PersistenceLayerId || payment.PaymentType == PaymentType.CreditCardOnFile_Value) && payment.ChargeCard != null)
                {
                    payment.ChargeCard.ChargeCardPayment.DataRecorderMetaData = dataRecordermetaData;
                    payment.ChargeCard.ChargeCardPayment.Id = 0;

                    if (payment.ChargeCard.ChargeCard.Id < 1)
                    {
                        payment.ChargeCard.ChargeCard.DataRecorderMetaData = dataRecordermetaData;
                    }

                    if (payment.PaymentType != PaymentType.CreditCardOnFile_Value)
                    {
                        payment.ChargeCard.ChargeCard = _chargeCardRepository.Save(payment.ChargeCard.ChargeCard);
                    }

                    payment.ChargeCard.ChargeCardPayment.ChargeCardId            = payment.ChargeCard.ChargeCard.Id;
                    payment.ChargeCard.ChargeCardPayment.ChargeCardPaymentStatus = ChargeCardPaymentStatus.Approve;
                    if (paymentEditModel.PaymentFlow == PaymentFlow.Out)
                    {
                        payment.ChargeCard.ChargeCardPayment.Amount = -1 * payment.ChargeCard.ChargeCardPayment.Amount;
                    }

                    paymentInstruments.Add(payment.ChargeCard.ChargeCardPayment);
                }
                else if (payment.PaymentType == PaymentType.Cash.PersistenceLayerId)
                {
                    var cashPayment = new CashPayment
                    {
                        Amount = paymentEditModel.PaymentFlow == PaymentFlow.Out ? -1 * payment.Amount : payment.Amount,
                        DataRecorderMetaData = dataRecordermetaData
                    };
                    paymentInstruments.Add(cashPayment);
                }
                else if (payment.PaymentType == PaymentType.Check.PersistenceLayerId && payment.Check != null)
                {
                    var check        = payment.Check.Check;
                    var checkPayment = payment.Check.CheckPayment;

                    if (check.Id < 1)
                    {
                        check.DataRecorderMetaData = dataRecordermetaData;
                    }

                    if (checkPayment.Id < 1)
                    {
                        checkPayment.DataRecorderMetaData = dataRecordermetaData;
                    }

                    checkPayment.Check = check;
                    if (paymentEditModel.PaymentFlow == PaymentFlow.Out)
                    {
                        checkPayment.Amount = -1 * checkPayment.Amount;
                        check.Amount        = -1 * check.Amount;
                    }

                    paymentInstruments.Add(checkPayment);
                }
                else if (payment.PaymentType == PaymentType.ElectronicCheck.PersistenceLayerId && payment.ECheck != null)
                {
                    var check        = payment.ECheck.ECheck;
                    var checkPayment = payment.ECheck.ECheckPayment;

                    if (check.Id < 1)
                    {
                        check.DataRecorderMetaData = dataRecordermetaData;
                    }

                    if (checkPayment.Id < 1)
                    {
                        checkPayment.DataRecorderMetaData = dataRecordermetaData;
                    }

                    checkPayment.ECheck = check;

                    paymentInstruments.Add(checkPayment);
                }
                else if (payment.PaymentType == PaymentType.GiftCertificate.PersistenceLayerId && payment.GiftCertificate != null)
                {
                    var giftCertificate        = payment.GiftCertificate.GiftCertificate;
                    var giftCertificatePayment = payment.GiftCertificate.GiftCertificatePayment;

                    if (giftCertificate.Id < 1)
                    {
                        giftCertificate.DataRecorderMetaData = dataRecordermetaData;
                    }

                    if (giftCertificatePayment.Id < 1)
                    {
                        giftCertificatePayment.DataRecorderMetaData = dataRecordermetaData;
                    }

                    paymentInstruments.Add(giftCertificatePayment);
                }
                else if (payment.PaymentType == PaymentType.Insurance.PersistenceLayerId && payment.Insurance != null && payment.Insurance.EligibilityId > 0 && payment.Insurance.InsurancePayment.AmountToBePaid > 0)
                {
                    var insurancePayment = payment.Insurance.InsurancePayment;
                    insurancePayment.Amount = 0;
                    insurancePayment.DataRecorderMetaData = dataRecordermetaData;

                    paymentInstruments.Add(insurancePayment);
                }
            }

            long paymentId = SavePayment(paymentInstruments, "Payment", dataRecorderOrgRoleUserId);

            return(paymentId);
        }
Exemple #8
0
        public OnlineSchedulingCustomerInfoEditModel SavePaymentInfo(OnlineSchedulingCustomerInfoEditModel model)
        {
            OnlineSchedulingProcessAndCartViewModel cartModel = model.ProcessAndCartViewModel;
            SourceCodeApplyEditModel sourceCodeModel          = model.SourceCodeApplyEditModel;
            PaymentEditModel         paymentModel             = model.PaymentEditModel;

            var onlineRequestValidationModel = _tempcartService.ValidateOnlineRequest(cartModel.CartGuid);

            model.RequestValidationModel = onlineRequestValidationModel;

            if (onlineRequestValidationModel.RequestStatus != OnlineRequestStatus.Valid)
            {
                return(model);
            }
            var tempCart = onlineRequestValidationModel.TempCart;


            if (tempCart.EventId.HasValue)
            {
                var summarymodel = _eventSchedulerService.GetEventCustomerOrderSummaryModel(tempCart);

                var couponAmount = sourceCodeModel != null ? sourceCodeModel.DiscountApplied : 0;
                if ((summarymodel.TotalPrice != null && summarymodel.TotalPrice.Value != (paymentModel.Amount + couponAmount)) || (summarymodel.TotalPrice == null && paymentModel.Amount > 0))
                {
                    throw new Exception("Seems like you changed your order. Please go back to the Package screen, and confirm!");
                }

                var result = ValidatePaymentModel(paymentModel);
                if (!result)
                {
                    throw new Exception("Payment error - Please re-enter your payment information or contact our customer care line at " +
                                        _settings.PhoneTollFree);
                }

                var isAppointmentTemporarilyBooked = _slotService.IsSlotTemporarilyBooked(tempCart.InChainAppointmentSlotIds);
                if (!isAppointmentTemporarilyBooked)
                {
                    //throw new Exception("The appointment time selected by you is no longer temporarliy booked for you. Please go back to appointment page to choose the time slot");
                    model.PaymentEditModel.IsTemporaryBookedSlotExpired = true;
                    return(model);
                }


                var isAppointmentBooked = _slotService.IsSlotBooked(tempCart.InChainAppointmentSlotIds);
                if (isAppointmentBooked)
                {
                    throw new Exception("The appointment slot selected by you seems to have exhausted. Please re-select another slot!");
                }
            }
            bool?    paymentSucceded = null;
            Customer customer;

            try
            {
                using (var scope = new TransactionScope())
                {
                    customer = tempCart.CustomerId.HasValue ? _customerRepository.GetCustomer(tempCart.CustomerId.Value) : null;

                    var address = Mapper.Map <AddressEditModel, Address>(paymentModel.ExistingShippingAddress);

                    address = _addressService.SaveAfterSanitizing(address, true);

                    if (customer == null)
                    {
                        throw new Exception("System Failure! Data not saved. Please try again.");
                    }

                    var customerAddress = Mapper.Map <AddressEditModel, Address>(paymentModel.ExistingShippingAddress);
                    customerAddress  = _addressService.SaveAfterSanitizing(customerAddress, true);
                    customer.Address = customerAddress;

                    customer.RequestForNewsLetter = model.RequestForNewsLetter;

                    if (paymentModel.Payments != null && paymentModel.Payments.Where(p => p.PaymentType != PaymentType.Onsite_Value && p.PaymentType != PaymentType.GiftCertificate.PersistenceLayerId).Count() > 0)
                    {
                        if (paymentModel.ExistingBillingAddress != null)
                        {
                            if (customer.BillingAddress != null && customer.BillingAddress.Id > 0)
                            {
                                paymentModel.ExistingBillingAddress.Id = customer.BillingAddress.Id;
                            }

                            var billingAddress = Mapper.Map <AddressEditModel, Address>(paymentModel.ExistingBillingAddress);
                            billingAddress = _addressService.SaveAfterSanitizing(billingAddress, true);

                            customer.BillingAddress = billingAddress;
                        }
                    }
                    else
                    {
                        var billingAddress = Mapper.Map <AddressEditModel, Address>(paymentModel.ExistingShippingAddress);
                        billingAddress = _addressService.SaveAfterSanitizing(billingAddress, true);

                        customer.BillingAddress = billingAddress;
                    }

                    _customerService.SaveCustomer(customer, customer.CustomerId);

                    tempCart.SourceCodeId = sourceCodeModel == null || sourceCodeModel.SourceCodeId < 1
                                                ? null
                                                : (long?)sourceCodeModel.SourceCodeId;

                    tempCart.ShippingAddressId = address.Id;
                    tempCart.ScreenResolution  = cartModel.ScreenResolution;

                    if (paymentModel.Payments != null)
                    {
                        tempCart.PaymentMode = "";

                        if (paymentModel.Payments.Any(p => p.ChargeCard != null))
                        {
                            tempCart.PaymentMode += PaymentType.CreditCard.Name + ",";
                        }

                        if (paymentModel.Payments.Any(p => p.ECheck != null))
                        {
                            tempCart.PaymentMode += PaymentType.ElectronicCheck.Name + ",";
                        }

                        if (paymentModel.Payments.Any(p => p.GiftCertificate != null))
                        {
                            tempCart.PaymentMode += PaymentType.GiftCertificate.Name + ",";
                        }

                        if (paymentModel.Payments.Any(p => p.PaymentType == (int)PaymentType.Onsite_Value))
                        {
                            tempCart.PaymentMode += PaymentType.PayLater_Text + ",";
                        }

                        tempCart.PaymentMode = tempCart.PaymentMode.Substring(0, tempCart.PaymentMode.LastIndexOf(","));
                    }

                    tempCart.PaymentAmount = paymentModel.Amount;
                    try
                    {
                        _eventSchedulerService.CreateOrder(tempCart, paymentModel);
                        paymentSucceded = true;
                    }
                    catch (Exception ex)
                    {
                        _paymentController.VoidCreditCardGatewayRequests(paymentModel);
                        paymentSucceded = false;
                        throw new Exception("\nOnline Payment. Message: " + ex.Message + ". \n\t Stack Trace: " + ex.StackTrace);
                    }

                    tempCart.IsPaymentSuccessful = true;
                    tempCart.IsCompleted         = true;
                    _tempcartService.SaveTempCart(tempCart);

                    UpdateProspectCustomer(tempCart, customer);
                    scope.Complete();
                }

                try
                {
                    var account = _corporateAccountRepository.GetbyEventId(tempCart.EventId.Value);

                    if (account == null || account.SendWelcomeEmail)
                    {
                        var welcomeEmailViewModel = _emailNotificationModelsFactory.GetWelcomeWithUserNameNotificationModel(customer.UserLogin.UserName, customer.Name.FullName, customer.DateCreated);
                        _notifier.NotifySubscribersViaEmail(NotificationTypeAlias.CustomerWelcomeEmailWithUsername, EmailTemplateAlias.CustomerWelcomeEmailWithUsername, welcomeEmailViewModel, customer.Id, customer.CustomerId, Request.RequestUri.OriginalString);
                    }

                    var eventData = _eventRepository.GetById(tempCart.EventId.Value);

                    _customerRegistrationService.SendAppointmentConfirmationMail(customer, eventData, customer.CustomerId, Request.RequestUri.OriginalString, account);

                    //If somebody registered within 24 hours of the event Date then send notification.
                    if (eventData.EventDate.AddDays(-1).Date <= DateTime.Now.Date)
                    {
                        var appointmentBookedInTwentyFourHoursNotificationModel = _emailNotificationModelsFactory.GetAppointmentBookedInTwentyFourHoursModel(tempCart.EventId.Value, tempCart.CustomerId.Value);
                        _notifier.NotifySubscribersViaEmail(NotificationTypeAlias.AppointmentBookedInTwentyFourHours, EmailTemplateAlias.AppointmentBookedInTwentyFourHours, appointmentBookedInTwentyFourHoursNotificationModel, 0, customer.CustomerId, Request.RequestUri.OriginalString);
                    }

                    _callQueueCustomerRepository.UpdateOtherCustomerStatus(customer.CustomerId, tempCart.ProspectCustomerId.HasValue ? tempCart.ProspectCustomerId.Value : 0, CallQueueStatus.Completed, customer.CustomerId);

                    _eventSchedulingSlotService.SendEventFillingNotification(tempCart.EventId.Value, customer.CustomerId);
                }
                catch (Exception)
                {
                    //throw  new Exception("\nOnline Payment. Exception caused while sending notification. Message: " + ex.Message);
                }
            }
            catch (InvalidAddressException ex)
            {
                throw new Exception("Address provided by you is not a valid address. " + ex.Message);
            }
            catch (Exception)
            {
                if (paymentSucceded != null && paymentSucceded == false)
                {
                    tempCart.IsPaymentSuccessful = false;
                    tempCart.IsCompleted         = false;
                    tempCart.PaymentMode         = "";
                    tempCart.SourceCodeId        = 0;
                    tempCart.ShippingAddressId   = null;
                    _tempcartService.SaveTempCart(tempCart);
                    throw new Exception("OOPS! Payment could not be settled. Please try again or Call our Care Agent at " + _settings.PhoneTollFree);
                }

                throw new Exception("OOPS! Some error while generating the Order. Please try again or Call our Care Agent at " + _settings.PhoneTollFree);
            }

            return(model);
        }
Exemple #9
0
 public async Task <IActionResult> Edit(PaymentEditModel model) => Ok(await _mediator.Send(new EditPayment.Command(model.TransactionId, model.Amount)));
        private static bool ValidateModelforPayments(RefundRequestResultEditModel model, PaymentEditModel childModel)
        {
            if (model.RequestResultType == RequestResultType.RescheduleAppointment || model.RequestResultType == RequestResultType.IssueGiftCertificate ||
                (model.RequestResultType == RequestResultType.OfferFreeAddonsAndDiscounts && model.PaymentEditModel.Amount == 0))
            {
                return(true);
            }

            if (model.PaymentEditModel.Amount == 0 && model.PaymentEditModel.Payments == null && model.RefundAmount > 0)
            {
                return(false);
            }

            return(true);
        }
Exemple #11
0
        public ActionResult RemoveProduct(ProductOrderItemEditModel model, PaymentEditModel paymentModel)
        {
            try
            {
                model.Order    = _orderRepository.GetOrder(model.CustomerId, model.EventId);
                model.Payments = paymentModel;
                var result = IsModelValid(model);
                if (!result)
                {
                    CompleteModel(model);
                    return(View(model));
                }

                if (_settings.IsRefundQueueEnabled)
                {
                    using (var scope = new TransactionScope())
                    {
                        SaveOrderforProductRemove(model);
                        CheckEventCustomerResultStateAndDeleteCdGenTrackRecord(model.EventId, model.CustomerId);
                        if (model.RefundRequest != null && model.RefundRequest.RequestedRefundAmount > 0)
                        {
                            _refundRequestService.SaveRequest(model.RefundRequest);
                        }

                        scope.Complete();
                    }
                }
                else
                {
                    if (paymentModel != null && paymentModel.Payments != null && paymentModel.Payments.Count() > 0)
                    {
                        try
                        {
                            _paymentController.ManagePayment(paymentModel, model.CustomerId, Request.UserHostAddress, "Product_Removal_" + model.CustomerId + "_" + model.ProductOrderDetailIds.FirstOrDefault());
                        }
                        catch (Exception)
                        {
                            model.FeedbackMessage =
                                FeedbackMessageModel.CreateFailureMessage(
                                    "System Failure! Payments were not processed for Customer: " + model.CustomerName + " [Id = " + model.CustomerId + "]. Please contact system administrator at " + _settings.SupportEmail);
                            return(View(model));
                        }
                    }
                    using (var scope = new TransactionScope())
                    {
                        SaveOrderforProductRemove(model);
                        if (paymentModel != null && paymentModel.Payments != null && paymentModel.Payments.Count() > 0)
                        {
                            var paymentId = _paymentController.SavePayment(paymentModel, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId);

                            _orderRepository.ApplyPaymentToOrder(model.Order.Id, paymentId);
                        }
                        CheckEventCustomerResultStateAndDeleteCdGenTrackRecord(model.EventId, model.CustomerId);
                        scope.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                model.Order = _orderRepository.GetOrder(model.CustomerId, model.EventId);
                CompleteModel(model);
                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("System Failure! " + ex.Message);
                return(View(model));
            }

            model.FeedbackMessage = FeedbackMessageModel.CreateSuccessMessage("Product removed from order successfully!");
            return(View(model));
        }
Exemple #12
0
        public ActionResult ManualRefund(ManualRefundEditModel model, PaymentEditModel paymentModel)
        {
            var currentOrgRole = IoC.Resolve <ISessionContext>().UserSession.CurrentOrganizationRole;

            try
            {
                model.Order    = _orderRepository.GetOrder(model.CustomerId, model.EventId);
                model.Payments = paymentModel;
                var result = IsModelValid(model);
                if (!result)
                {
                    CompleteModel(model);
                    return(View(model));
                }
                if ((_settings.IsRefundQueueEnabled) && (currentOrgRole.CheckRole((long)Roles.CallCenterRep) || currentOrgRole.CheckRole((long)Roles.CallCenterManager) || currentOrgRole.CheckRole((long)Roles.Technician)))
                {
                    using (var scope = new TransactionScope())
                    {
                        SaveRefundOrder(model);
                        if (model.RefundRequest != null && model.RefundRequest.RequestedRefundAmount > 0)
                        {
                            var refundRequests = _refundRequestRepository.GetbyOrderId(model.Order.Id);
                            if (!refundRequests.IsNullOrEmpty())
                            {
                                var requestSum = refundRequests.Where(rr => rr.RefundRequestType == RefundRequestType.ManualRefund && rr.RequestStatus == (long)RequestStatus.Pending).Sum(rr => rr.RequestedRefundAmount);
                                model.RefundRequest.RequestedRefundAmount += requestSum;
                            }
                            _refundRequestService.SaveRequest(model.RefundRequest);
                        }

                        scope.Complete();
                    }
                }
                else
                {
                    if (paymentModel != null && paymentModel.Payments != null && paymentModel.Payments.Count() > 0)
                    {
                        try
                        {
                            _paymentController.ManagePayment(paymentModel, model.CustomerId, Request.UserHostAddress, "Manual_Refund_" + model.CustomerId + "_" + model.EventId);
                        }
                        catch (Exception)
                        {
                            model.FeedbackMessage =
                                FeedbackMessageModel.CreateFailureMessage(
                                    "System Failure! Your order was saved succesfully. Payments were not processed for Customer: " + model.CustomerName + " [Id = " + model.CustomerId + "]. Please contact system administrator at " + _settings.SupportEmail);
                            return(View(model));
                        }
                    }
                    using (var scope = new TransactionScope())
                    {
                        SaveRefundOrder(model);
                        if (paymentModel != null && paymentModel.Payments != null && paymentModel.Payments.Count() > 0)
                        {
                            var paymentId = _paymentController.SavePayment(paymentModel, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId);

                            _orderRepository.ApplyPaymentToOrder(model.Order.Id, paymentId);
                        }
                        scope.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                model.Order = _orderRepository.GetOrder(model.CustomerId, model.EventId);
                CompleteModel(model);
                model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("System Failure! " + ex.Message);
                return(View(model));
            }
            model.FeedbackMessage = FeedbackMessageModel.CreateSuccessMessage("Amount refunded successfully.");
            return(View(model));
        }