コード例 #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>
        /// Verifies the membership credit.  When creating new Membership.
        /// </summary>
        /// <param name="cardInfo">The card info.</param>
        /// <returns></returns>
        ///
        public static string VerifyMembershipCredit(string cardInfo)
        {
            try
            {
                if (BaseController.RegistrationUser != null)
                {
                    if (BaseController.CurrentTransaction == null)
                    {
                        BaseController.CurrentTransaction = new Entities.TransactionQueueData();
                    }

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

                    // Use the Credit Card Helper to parse cc fields
                    CreditCard cc = new CreditCard(cardInfo, CreditCard.ExpireDateFormat.YYYY_MM);

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

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

                    int subscriptionPlanId = BaseController.GetSubscriptionPlanId(BaseController.RegistrationUser.BatteriesInPlan);
                    if (subscriptionPlanId != 0)
                    {
                        decimal amount = BaseController.GetPriceBySubscriptionPlanId(subscriptionPlanId);
                        if (amount > 0)
                        {
                            CreateTransaction(customerProfileId, customerPaymentProfileId, amount);
                        }
                    }
                }

                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);
            }
        }
コード例 #3
0
        /// <summary>
        /// Gets the max aaa product.
        /// </summary>
        /// <returns>Max Aaa Product</returns>
        public static int?GetMaxAaaProduct()
        {
            try
            {
                int maxAaaProduct = BaseDAL.GetTotalQuantitybyProduct(ProductTypes.AAA);

                if (maxAaaProduct > Constants.BetteryProduct.AaaMax)
                {
                    return(Constants.BetteryProduct.AaaMax);
                }

                return(maxAaaProduct);
            }
            catch (Exception ex)
            {
                Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                AlertController.TransactionFailureAlert(ex.Message);
                BaseController.RaiseOnThrowExceptionEvent();
            }

            return(null);
        }
コード例 #4
0
        /// <summary>
        /// Checks the bettery store.
        /// </summary>
        public static bool BetteryStoreExists()
        {
            try
            {
                int aa  = BaseDAL.GetTotalQuantitybyProduct(ProductTypes.AA);
                int aaa = BaseDAL.GetTotalQuantitybyProduct(ProductTypes.AAA);

                if (aa > 0 || aaa > 0)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                AlertController.TransactionFailureAlert(ex.Message);
                BaseController.RaiseOnThrowExceptionEvent();

                return(false);
            }
        }
コード例 #5
0
        /// <summary>
        /// Gets the out of battery message.
        /// </summary>
        /// <returns></returns>
        public static bool GetOutOfBatteryMessage(out string message)
        {
            message = string.Empty;

            try
            {
                int aaCount  = BaseDAL.GetTotalQuantitybyProduct(ProductTypes.AA);
                int aaaCount = BaseDAL.GetTotalQuantitybyProduct(ProductTypes.AAA);

                if (aaCount <= 0 && aaaCount <= 0)
                {
                    message = Constants.Messages.OutOfBatteries;
                    Logger.Log(EventLogEntryType.Error, "Station out of Batteries", BaseController.StationId);
                }
                else if (aaCount <= 0)
                {
                    message = Constants.Messages.OutOfAABatteries;
                    Logger.Log(EventLogEntryType.Error, "Station out of AA Batteries", BaseController.StationId);
                }
                else if (aaaCount <= 0)
                {
                    message = Constants.Messages.OutOfAAABatteries;
                    Logger.Log(EventLogEntryType.Error, "Station out of AAA Batteries", BaseController.StationId);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                AlertController.TransactionFailureAlert(ex.Message);
                BaseController.RaiseOnThrowExceptionEvent();

                return(false);
            }
        }
コード例 #6
0
        /// <summary>
        /// Vends the batteries to user.
        /// </summary>
        public static bool Vending()
        {
            try
            {
                // Product: AA
                if (BaseController.SelectedBettery != null)
                {
                    int totalBins;

                    int  vendPauseCount   = BaseController.VendPauseCount;
                    bool isVendBinSuccess = false;

                    VendEventArgs vendEventArgs;

                    vendEventArgs = new VendEventArgs(BaseController.SelectedBettery.AaVend, BaseController.SelectedBettery.AaaVend);

                    if (BaseController.SelectedBettery.AaVendRemaining > 0 && vendPauseCount > 0)
                    {
                        totalBins = BaseDAL.GetTotalQuantitybyProduct(ProductTypes.AA);
                        if (totalBins > 0)
                        {
                            List <BinProduct> aaBins = BaseDAL.GetBinsbyProduct(ProductTypes.AA);
                            foreach (BinProduct bin in aaBins)
                            {
                                isVendBinSuccess = false;

                                if (bin.Quantity > 0)
                                {
                                    for (int i = 0; i < bin.Quantity; i++)
                                    {
                                        if (BaseController.SelectedBettery.AaVendRemaining > 0)
                                        {
                                            // Update the Vending message
                                            if (OnVending != null)
                                            {
                                                vendEventArgs.CurrentProductAA  = BaseController.SelectedBettery.AaVend - BaseController.SelectedBettery.AaVendRemaining;
                                                vendEventArgs.CurrentProductAAA = BaseController.SelectedBettery.AaaVend - BaseController.SelectedBettery.AaaVendRemaining;
                                                OnVending.Invoke(vendEventArgs);
                                            }

                                            // Send the Vend command to the serial port
                                            isVendBinSuccess = BaseController.SendCommandToSerialPort(bin.BinId);

                                            if (isVendBinSuccess)
                                            {
                                                vendPauseCount--;

                                                // Decrement Remaining to vend
                                                BaseController.SelectedBettery.AaVendRemaining--;

                                                // Decrement Bin Inventory
                                                BaseDAL.DecrementBinInventory(bin.BinId);

                                                //// Update the Vending message
                                                //if (OnVending != null)
                                                //{
                                                //    vendEventArgs.CurrentProductAA = BaseController.SelectedBettery.AaVend - BaseController.SelectedBettery.AaVendRemaining;
                                                //    vendEventArgs.CurrentProductAAA = BaseController.SelectedBettery.AaaVend - BaseController.SelectedBettery.AaaVendRemaining;
                                                //    OnVending.Invoke(vendEventArgs);
                                                //}

                                                if (vendPauseCount == 0)
                                                {
                                                    return(true);
                                                }
                                            }
                                            else
                                            {
                                                // Disable the bin
                                                BaseDAL.DisableBin(bin.BinId);

                                                AlertController.TransactionFailureAlert("Bin " + bin.BinId.ToString() + " Disabled");

                                                // Don't continue iterating through bin
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }


                    // Product: AAA
                    if (BaseController.SelectedBettery.AaaVendRemaining > 0 && vendPauseCount > 0)
                    {
                        totalBins = BaseDAL.GetTotalQuantitybyProduct(ProductTypes.AAA);

                        if (totalBins > 0)
                        {
                            List <BinProduct> aaaBins = BaseDAL.GetBinsbyProduct(ProductTypes.AAA);
                            foreach (BinProduct bin in aaaBins)
                            {
                                isVendBinSuccess = false;

                                if (bin.Quantity > 0)
                                {
                                    for (int i = 0; i < bin.Quantity; i++)
                                    {
                                        if (BaseController.SelectedBettery.AaaVendRemaining > 0)
                                        {
                                            // Update the vending message
                                            if (OnVending != null)
                                            {
                                                vendEventArgs.CurrentProductAA  = BaseController.SelectedBettery.AaVend - BaseController.SelectedBettery.AaVendRemaining;
                                                vendEventArgs.CurrentProductAAA = BaseController.SelectedBettery.AaaVend - BaseController.SelectedBettery.AaaVendRemaining;
                                                OnVending.Invoke(vendEventArgs);
                                            }

                                            // Send the Vend command to the serial port
                                            isVendBinSuccess = BaseController.SendCommandToSerialPort(bin.BinId);

                                            if (isVendBinSuccess)
                                            {
                                                vendPauseCount--;

                                                // Decrement Remaining to vend
                                                BaseController.SelectedBettery.AaaVendRemaining--;

                                                // Decrement Bin Inventory
                                                BaseDAL.DecrementBinInventory(bin.BinId);

                                                //// Update the vending message
                                                //if (OnVending != null)
                                                //{
                                                //    vendEventArgs.CurrentProductAA = BaseController.SelectedBettery.AaVend - BaseController.SelectedBettery.AaVendRemaining;
                                                //    vendEventArgs.CurrentProductAAA = BaseController.SelectedBettery.AaaVend - BaseController.SelectedBettery.AaaVendRemaining;
                                                //    OnVending.Invoke(vendEventArgs);
                                                //}

                                                if (vendPauseCount == 0)
                                                {
                                                    return(true);
                                                }
                                            }
                                            else
                                            {
                                                // Disable the bin
                                                BaseDAL.DisableBin(bin.BinId);

                                                AlertController.TransactionFailureAlert("Bin " + bin.BinId.ToString() + " Disabled");

                                                // Don't continue iterating through bin
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                AlertController.TransactionFailureAlert(ex.Message);
                BaseController.RaiseOnThrowExceptionEvent();
                return(false);
            }
            return(true);
        }
コード例 #7
0
        /// <summary>
        /// Vends the empty case.
        /// </summary>
        /// <param name="totalEmptyCases">The total empty cases.</param>
        public static void VendEmptyCase(int totalEmptyCases)
        {
            var  totalBins        = BaseDAL.GetTotalQuantitybyProduct(ProductTypes.Cartridge);
            bool isVendBinSuccess = false;

            int vendedFreeCases = 0;

            if (totalBins > 0)
            {
                VendEventArgs vendEventArgs = new VendEventArgs(totalEmptyCases);

                try
                {
                    List <BinProduct> cartridgeBins = BaseDAL.GetBinsbyProduct(ProductTypes.Cartridge);
                    foreach (BinProduct bin in cartridgeBins)
                    {
                        if (totalEmptyCases == 0)
                        {
                            break;
                        }

                        if (bin.Quantity > 0)
                        {
                            BinProduct decrementBin = new BinProduct {
                                BinId = bin.BinId, Quantity = 0
                            };

                            for (int i = 0; i < bin.Quantity; i++)
                            {
                                if (totalEmptyCases == 0)
                                {
                                    break;
                                }

                                isVendBinSuccess = BaseController.SendCommandToSerialPort(bin.BinId);

                                if (isVendBinSuccess)
                                {
                                    totalEmptyCases--;
                                    vendedFreeCases++;
                                    decrementBin.Quantity++;
                                    if (OnVending != null)
                                    {
                                        vendEventArgs.VendedEmptyCases = vendedFreeCases;
                                        OnVendingCase.Invoke(vendEventArgs);
                                    }
                                }
                                else
                                {
                                    BaseDAL.DisableBin(bin.BinId);
                                    AlertController.TransactionFailureAlert("Bin " + bin.BinId.ToString() + " Disabled");
                                    // Don't continue iterating through bin
                                    break;
                                }
                            }

                            if (isVendBinSuccess && decrementBin.Quantity > 0)
                            {
                                BaseDAL.DecrementBinInventory(decrementBin);
                            }
                            isVendBinSuccess = false;
                        }
                    }

                    using (KioskServiceClient proxy = new KioskServiceClient())
                    {
                        //  Update the members remaining free cases.
                        proxy.EmptyCaseVend(BaseController.LoggedOnUser.MemberId, vendedFreeCases);
                        proxy.Close();
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                    AlertController.TransactionFailureAlert(ex.Message);
                    BaseController.RaiseOnThrowExceptionEvent();
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Checks the out.
        /// </summary>
        /// <param name="cardInfo">The card info.</param>
        /// <param name="zipCode">The zip code.</param>
        /// <returns>Error message</returns>
        public static string CheckOut(string cardInfo, string zipCode)
        {
            try
            {
                if (BaseController.SelectedBettery != null)
                {
                    if (BaseController.CurrentTransaction == null)
                    {
                        BaseController.CurrentTransaction = new Entities.TransactionQueueData();
                    }

                    // Gen order number
                    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;
                    BaseController.CurrentTransaction.TaxAmount      = BaseController.SelectedBettery.TotalTaxAmount;
                    BaseController.CurrentTransaction.ChargeAmount   = BaseController.SelectedBettery.TotalAmount;
                    if (BaseController.LoggedOnUser != null)
                    {
                        BaseController.CurrentTransaction.Email = BaseController.LoggedOnUser.UserName;
                        BaseController.CurrentTransaction.BatteryPacksCheckedOut = BaseController.LoggedOnUser.BatteriesCheckedOut + BaseController.SelectedBettery.NewCartridges;
                    }

                    BaseController.CurrentTransaction.AaForgotVend  = BaseController.SelectedBettery.AaForgotDrainedVend;
                    BaseController.CurrentTransaction.AaaForgotVend = BaseController.SelectedBettery.AaaForgotDrainedVend;

                    BaseController.CurrentTransaction.PromoCode       = BaseController.SelectedBettery.PromotionCode;
                    BaseController.CurrentTransaction.PromoCodeAmount = BaseController.SelectedBettery.PromotionalAmount;
                    BaseController.CurrentTransaction.OrderNumber     = Guid.NewGuid().ToString();
                    BaseController.CurrentTransaction.ZipCode         = zipCode;

                    // Use the Credit Card Helper to parse cc fields
                    CreditCard cc = new CreditCard(cardInfo);

                    if (BaseController.LoggedOnUser != null)
                    {
                        Logger.Log(EventLogEntryType.Information, "User Transaction:  Sending to Authorize.NET Id = " + BaseController.CurrentTransaction.OrderNumber.ToString() + " Card Name = " + cc.Name + " Logged on User = "******" Transaction Amount = " + BaseController.SelectedBettery.TotalAmount.ToString(), BaseController.StationId);
                    }
                    else
                    {
                        Logger.Log(EventLogEntryType.Information, "User Transaction:  Sending to Authorize.NET Id = " + BaseController.CurrentTransaction.OrderNumber.ToString() + " Card Name = " + cc.Name + " Transaction Amount = " + BaseController.SelectedBettery.TotalAmount.ToString(), BaseController.StationId);
                    }

                    if (BaseController.SelectedBettery.TotalAmount > 0)
                    {
                        // TODO: process for credit case

                        int retries = 3;
                        while (true)
                        {
                            try
                            {
                                BaseController.CurrentTransaction.Authorization = ProcessCC(cc.Number, cc.ExpDate, BaseController.SelectedBettery.TotalAmount, BaseController.CurrentTransaction.OrderNumber, zipCode, cc.Name);
                                break; // success!
                            }
                            catch
                            {
                                if (--retries == 0)
                                {
                                    throw;
                                }
                                else
                                {
                                    Logger.Log(EventLogEntryType.Warning, "ProcessCC exception, connection to authorize.net, retrying", BaseController.StationId);
                                    Thread.Sleep(5000);
                                }
                            }
                        }
                        BaseController.CurrentTransaction.CardInfo   = cc.Number.Substring(cc.Number.Length - 4);
                        BaseController.CurrentTransaction.NameOnCard = cc.Name;

                        // We use the default SHA-256 & 4 byte length
                        HashUtils hashUtils = new HashUtils();

                        // We have a password, which will generate a Hash and Salt
                        string Hash;

                        // Gen a hash with Card Name and last 4 of card number
                        hashUtils.GetHashString(cc.Name + cc.Number.Substring(cc.Number.Length - 4), out Hash);
                        BaseController.CurrentTransaction.CardHash = Hash;
                    }
                }

                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);
            }
        }
コード例 #9
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);
            }
        }
コード例 #10
0
        /// <summary>
        /// Memberships the checkout.
        /// </summary>
        /// <returns></returns>
        public static string MembershipCheckout()
        {
            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 price = 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;
                        price = BaseController.SelectedBettery.TotalAmount;
                        BaseController.CurrentTransaction.TaxAmount = BaseController.SelectedBettery.TotalTaxAmount;
                        if (BaseController.LoggedOnUser.CCOnFileLastFourDigits != null)
                        {
                            BaseController.CurrentTransaction.CardInfo = BaseController.LoggedOnUser.CCOnFileLastFourDigits;
                        }
                        else
                        {
                            BaseController.CurrentTransaction.CardInfo = String.Empty;
                        }

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

                    long customerProfileId = 0, customerPaymentProfileId = 0;
                    bool result;
                    result = long.TryParse(BaseController.LoggedOnUser.CustomerProfileId, out customerProfileId);
                    if (result && customerProfileId > 0)
                    {
                        result = long.TryParse(BaseController.LoggedOnUser.PaymentProfileId, out customerPaymentProfileId);

                        if (result && customerPaymentProfileId > 0)
                        {
                            BaseController.CurrentTransaction.CustomerProfileId = BaseController.LoggedOnUser.CustomerProfileId;
                            BaseController.CurrentTransaction.PaymentProfileID  = BaseController.LoggedOnUser.PaymentProfileId;

                            if (price > 0)
                            {
                                CreateTransaction(customerProfileId, customerPaymentProfileId, price);
                            }
                            //else
                            //{
                            //    price = Math.Abs(price);
                            //}

                            //MembershipRegistrationController.UpdateMembershipProfile(BaseController.LoggedOnUser.MemberId, BaseController.LoggedOnUser.CustomerProfileId, BaseController.LoggedOnUser.PaymentProfileId, BaseController.LoggedOnUser.BatteriesInPlan, price, 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);
            }
        }