Exemple #1
0
        private void ManagePaymentsbeforeDataSave(RefundRequestResultEditModel model)
        {
            switch (model.RequestResultType)
            {
            case RequestResultType.IssueRefund:
                _paymentController.ManagePayment(model.PaymentEditModel, model.CustomerId, Request.UserHostAddress, "Pr_Rq_IR_" + model.RequestId);
                break;

            case RequestResultType.OfferFreeAddonsAndDiscounts:
                _paymentController.ManagePayment(model.PaymentEditModel, model.CustomerId, Request.UserHostAddress, "Pr_Rq_DiscAdOn_" + model.RequestId);
                break;
            }
        }
        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);
                }
            }
        }
Exemple #3
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));
        }