예제 #1
0
        /// <summary>
        /// Verifies the membership credit.
        /// </summary>
        /// <returns></returns>
        public static string CheckOutForSubscriptionPlan(long customerProfileId, long paymentProfileId)
        {
            try
            {
                if (BaseController.LoggedOnUser != null)
                {
                    if (BaseController.CurrentTransaction == null)
                    {
                        BaseController.CurrentTransaction = new Entities.TransactionQueueData();
                    }

                    BaseController.CurrentTransaction.Email       = BaseController.LoggedOnUser.Email;
                    BaseController.CurrentTransaction.OrderNumber = Guid.NewGuid().ToString();
                    BaseController.CurrentTransaction.ZipCode     = BaseController.LoggedOnUser.ZipCode;

                    BaseController.CurrentTransaction.CustomerProfileId = customerProfileId.ToString();
                    BaseController.CurrentTransaction.PaymentProfileID  = paymentProfileId.ToString();

                    if (BaseController.LoggedOnUser.BatteriesInPlan == 0)
                    {
                        int     subscriptionPlanId = BaseController.GetSubscriptionPlanId(BaseController.LoggedOnUser.NewBatteriesInPlan);
                        decimal price           = BaseController.GetPriceBySubscriptionPlanId(subscriptionPlanId);
                        decimal amount          = price - BaseController.LoggedOnUser.OutstandingCredit;
                        decimal newCreditAmount = 0;

                        if (amount > 0)
                        {
                            CreateTransaction(customerProfileId, paymentProfileId, price);
                            newCreditAmount = 0;
                        }
                        else
                        {
                            newCreditAmount = Math.Abs(amount);
                        }

                        MembershipRegistrationController.UpdateMembershipProfile(BaseController.LoggedOnUser.MemberId, BaseController.LoggedOnUser.CustomerProfileId, BaseController.LoggedOnUser.PaymentProfileId, BaseController.LoggedOnUser.NewBatteriesInPlan, newCreditAmount, true, false);
                    }
                    else
                    {
                        MembershipRegistrationController.UpdateMembershipProfile(BaseController.LoggedOnUser.MemberId, BaseController.LoggedOnUser.CustomerProfileId, BaseController.LoggedOnUser.PaymentProfileId, BaseController.LoggedOnUser.NewBatteriesInPlan, BaseController.LoggedOnUser.OutstandingCredit, true, true);
                    }
                }

                return(string.Empty);
            }
            catch (KioskException kioskException)
            {
                AlertController.TransactionFailureAlert(kioskException.CustomMessage);
                Logger.Log(EventLogEntryType.Error, kioskException, BaseController.StationId);
                BaseController.RaiseOnThrowExceptionEvent();
                return(kioskException.CustomMessage);
            }
            catch (Exception ex)
            {
                AlertController.TransactionFailureAlert(ex.Message);
                Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                BaseController.RaiseOnThrowExceptionEvent();
                return(Constants.Messages.YourCreditCardWasNotAuthorized);
            }
        }
예제 #2
0
        /// <summary>
        /// Memberships the checkout.
        /// </summary>
        /// <param name="cardInfo">The card info.</param>
        /// <returns></returns>
        public static string MembershipCheckout(string cardInfo)
        {
            try
            {
                if (BaseController.LoggedOnUser != null)
                {
                    if (BaseController.CurrentTransaction == null)
                    {
                        BaseController.CurrentTransaction = new Entities.TransactionQueueData();
                    }

                    BaseController.CurrentTransaction.Email       = BaseController.LoggedOnUser.Email;
                    BaseController.CurrentTransaction.OrderNumber = Guid.NewGuid().ToString();
                    BaseController.CurrentTransaction.ZipCode     = BaseController.LoggedOnUser.ZipCode;
                    decimal amount = 0;
                    if (BaseController.SelectedBettery != null)
                    {
                        BaseController.SelectedBettery.AaVendRemaining   = BaseController.SelectedBettery.AaVend;
                        BaseController.SelectedBettery.AaaVendRemaining  = BaseController.SelectedBettery.AaaVend;
                        BaseController.CurrentTransaction.AaVend         = BaseController.SelectedBettery.AaVend;
                        BaseController.CurrentTransaction.AaaVend        = BaseController.SelectedBettery.AaaVend;
                        BaseController.CurrentTransaction.AaReturn       = BaseController.SelectedBettery.AaReturn;
                        BaseController.CurrentTransaction.AaaReturn      = BaseController.SelectedBettery.AaaReturn;
                        BaseController.CurrentTransaction.SubTotalAmount = BaseController.SelectedBettery.SubTotalAmount;
                        if (BaseController.SelectedBettery.CalculatedReturnedAmount > 0)
                        {
                            BaseController.CurrentTransaction.ChargeAmount = -BaseController.SelectedBettery.CalculatedReturnedAmount;
                        }
                        else
                        {
                            BaseController.CurrentTransaction.ChargeAmount = BaseController.SelectedBettery.TotalAmount;
                        }
                        BaseController.CurrentTransaction.AaForgotVend  = BaseController.SelectedBettery.AaForgotDrainedVend;
                        BaseController.CurrentTransaction.AaaForgotVend = BaseController.SelectedBettery.AaaForgotDrainedVend;

                        BaseController.CurrentTransaction.PromoCode       = BaseController.SelectedBettery.PromotionCode;
                        BaseController.CurrentTransaction.PromoCodeAmount = BaseController.SelectedBettery.PromotionalAmount;
                        amount = BaseController.SelectedBettery.TotalAmount;
                        BaseController.CurrentTransaction.TaxAmount = BaseController.SelectedBettery.TotalTaxAmount;


                        BaseController.CurrentTransaction.BatteryPacksCheckedOut = BaseController.LoggedOnUser.BatteriesCheckedOut + BaseController.SelectedBettery.NewCartridges;
                    }
                    else
                    {
                        BaseController.CurrentTransaction.BatteryPacksCheckedOut = BaseController.LoggedOnUser.BatteriesCheckedOut;
                    }

                    // Use the Credit Card Helper to parse cc fields
                    CreditCard cc = new CreditCard(cardInfo, CreditCard.ExpireDateFormat.YYYY_MM);
                    BaseController.CurrentTransaction.CardInfo = cc.Number.Substring(cc.Number.Length - 4);

                    long customerProfileId        = CreateCustomerProfile(BaseController.CurrentTransaction.Email);
                    long customerPaymentProfileId = CreateCustomerPaymentProfile(customerProfileId, cc.Number, cc.ExpDate, BaseController.LoggedOnUser.MemberFirstName, BaseController.LoggedOnUser.MemberLastName, BaseController.LoggedOnUser.ZipCode);

                    BaseController.CurrentTransaction.CustomerProfileId = customerProfileId.ToString();
                    BaseController.CurrentTransaction.PaymentProfileID  = customerPaymentProfileId.ToString();

                    BaseController.LoggedOnUser.CustomerProfileId = customerProfileId.ToString();
                    BaseController.LoggedOnUser.PaymentProfileId  = customerPaymentProfileId.ToString();

                    if (amount > 0)
                    {
                        CreateTransaction(customerProfileId, customerPaymentProfileId, amount);
                    }

                    MembershipRegistrationController.UpdateMembershipProfile(BaseController.LoggedOnUser.MemberId,
                                                                             BaseController.LoggedOnUser.CustomerProfileId,
                                                                             BaseController.LoggedOnUser.PaymentProfileId);
                }

                return(string.Empty);
            }
            catch (KioskException kioskException)
            {
                AlertController.TransactionFailureAlert(kioskException.CustomMessage);
                Logger.Log(EventLogEntryType.Error, kioskException, BaseController.StationId);
                BaseController.RaiseOnThrowExceptionEvent();
                return(kioskException.CustomMessage);
            }
            catch (Exception ex)
            {
                AlertController.TransactionFailureAlert(ex.Message);
                Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                BaseController.RaiseOnThrowExceptionEvent();
                return(Constants.Messages.YourCreditCardWasNotAuthorized);
            }
        }