Ejemplo n.º 1
0
            public UpdateRecurringOrderResult UpdateRecurringOrder(int recurringOrderId, Address address, CreditCardViewModel creditCard, Customer customer)
            {
                if (creditCard != null && customer.MasterShouldWeStoreCreditCardInfo)
                {
                    address.PaymentMethodLastUsed = AppLogic.ro_PMCreditCard;
                    address.CardName            = creditCard.Name;
                    address.CardType            = creditCard.CardType;
                    address.CardNumber          = creditCard.Number;
                    address.CardExpirationMonth = creditCard.ExpirationMonth.ToString();
                    address.CardExpirationYear  = creditCard.ExpirationYear.ToString();
                    address.CardIssueNumber     = creditCard.CardIssueNumber;
                    address.CardStartDate       = string.Format("{0:00}{1:0000}",
                                                                creditCard.CardStartMonth,
                                                                creditCard.CardStartYear);
                }

                address.UpdateDB();

                var recurringOrderManager = new RecurringOrderMgr();
                var result = recurringOrderManager
                             .ProcessAutoBillAddressUpdate(recurringOrderId, address);

                if (result == AppLogic.ro_OK)
                {
                    return(new UpdateRecurringOrderResult());
                }
                else
                {
                    return(new UpdateRecurringOrderResult(RecurringOrderActionStatus.Failure, result));
                }
            }
        private void ProcessForm(bool UseValidationService, int AddressID)
        {
            string ResidenceType = ddlResidenceType.SelectedValue;
            bool   valid         = true;
            string errormsg      = string.Empty;
            bool   CardIncluded  = false;

            errormsg += "<ul>";

            if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardName")))
            {
                valid     = false;
                errormsg += "<li>" + AppLogic.GetString("admin.editaddressrecurring.CardNameIsRequired", SkinID, LocaleSetting) + "</li>";
            }
            if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardType")))
            {
                valid     = false;
                errormsg += "<li>" + AppLogic.GetString("admin.editaddressrecurring.CardTypeIsRequired", SkinID, LocaleSetting) + "</li>";
            }
            if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardNumber")))
            {
                valid     = false;
                errormsg += "<li>" + AppLogic.GetString("admin.editaddressrecurring.CardNumberIsRequired", SkinID, LocaleSetting) + "</li>";
            }
            else
            {
                CardIncluded = true;
            }

            int    iexpMonth = 0;
            int    iexpYear  = 0;
            string expMonth  = CommonLogic.FormCanBeDangerousContent("CardExpirationMonth");
            string expYear   = CommonLogic.FormCanBeDangerousContent("CardExpirationYear");

            if (string.IsNullOrEmpty(expMonth) ||
                !int.TryParse(expMonth, out iexpMonth) ||
                !(iexpMonth > 0))
            {
                valid     = false;
                errormsg += "<li>" + AppLogic.GetString("admin.editaddressrecurring.CardExpirationMonthNotification", SkinID, LocaleSetting) + "</li>";
            }
            else
            {
                CardIncluded = true;
            }

            if (string.IsNullOrEmpty(expYear) ||
                !int.TryParse(expYear, out iexpYear) ||
                !(iexpYear > 0))
            {
                valid     = false;
                errormsg += "<li>" + AppLogic.GetString("admin.editaddressrecurring.CardExpirationYearNotification", SkinID, LocaleSetting) + "</li>";
            }
            else
            {
                CardIncluded = true;
            }

            if (!CardIncluded)
            {
                valid = true;
            }

            if (!valid)
            {
                errormsg           += "</ul>";
                ErrorMsgLabel.Text += errormsg;
                InitializePageContent();
                return;
            }
            else
            {
                ErrorMsgLabel.Text = String.Empty;
            }

            theAddress.AddressType = AddressTypes.Billing;
            theAddress.NickName    = txtAddressNickName.Text;
            theAddress.FirstName   = txtFirstName.Text;
            theAddress.LastName    = txtLastName.Text;
            theAddress.Company     = txtCompany.Text;
            theAddress.Address1    = txtAddress1.Text;
            theAddress.Address2    = txtAddress2.Text;
            theAddress.Suite       = txtSuite.Text;
            theAddress.City        = txtCity.Text;
            theAddress.State       = ddlState.SelectedValue;
            theAddress.Zip         = txtZip.Text;
            theAddress.Country     = ddlCountry.SelectedValue;
            theAddress.Phone       = txtPhone.Text;
            if (ResidenceType == "2")
            {
                theAddress.ResidenceType = ResidenceTypes.Commercial;
            }
            else if (ResidenceType == "1")
            {
                theAddress.ResidenceType = ResidenceTypes.Residential;
            }
            else
            {
                theAddress.ResidenceType = ResidenceTypes.Unknown;
            }

            if (CardIncluded)
            {
                theAddress.PaymentMethodLastUsed = AppLogic.ro_PMCreditCard;
                theAddress.CardName = CommonLogic.FormCanBeDangerousContent("CardName");
                theAddress.CardType = CommonLogic.FormCanBeDangerousContent("CardType");

                string tmpS = CommonLogic.FormCanBeDangerousContent("CardNumber");
                if (!tmpS.StartsWith("*"))
                {
                    theAddress.CardNumber = tmpS;
                }
                theAddress.CardExpirationMonth = CommonLogic.FormCanBeDangerousContent("CardExpirationMonth");
                theAddress.CardExpirationYear  = CommonLogic.FormCanBeDangerousContent("CardExpirationYear");
            }

            theAddress.UpdateDB();

            SetupCreditCardForm();

            RecurringOrderMgr rmgr = new RecurringOrderMgr();

            errormsg           = rmgr.ProcessAutoBillAddressUpdate(OriginalRecurringOrderNumber, theAddress);
            ErrorMsgLabel.Text = errormsg != AppLogic.ro_OK ? errormsg : String.Empty;
            if (!AddressCustomer.MasterShouldWeStoreCreditCardInfo)
            {
                theAddress.ClearCCInfo();
                theAddress.UpdateDB();
            }
        }
Ejemplo n.º 3
0
        private void ProcessForm(bool UseValidationService, int AddressID)
        {
            string ResidenceType = ddlResidenceType.SelectedValue;
            bool   valid         = true;
            string errormsg      = string.Empty;

            bool CardIncluded = false;

            if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardName")))
            {
                valid     = false;
                errormsg += "&bull;Card Name is required";
            }

            if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardType")))
            {
                valid     = false;
                errormsg += "&bull;Card Type is required";
            }

            if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardNumber")))
            {
                valid     = false;
                errormsg += "&bull;Card Number is required";
            }
            else
            {
                CardIncluded = true;
            }

            int    iexpMonth = 0;
            int    iexpYear  = 0;
            string expMonth  = CommonLogic.FormCanBeDangerousContent("CardExpirationMonth");
            string expYear   = CommonLogic.FormCanBeDangerousContent("CardExpirationYear");

            if (string.IsNullOrEmpty(expMonth) ||
                !int.TryParse(expMonth, out iexpMonth) ||
                !(iexpMonth > 0))
            {
                valid     = false;
                errormsg += "&bull;Please select the Card Expiration Month";
            }
            else
            {
                CardIncluded = true;
            }

            if (string.IsNullOrEmpty(expYear) ||
                !int.TryParse(expYear, out iexpYear) ||
                !(iexpYear > 0))
            {
                valid     = false;
                errormsg += "&bull;Please select the Card Expiration Year";
            }
            else
            {
                CardIncluded = true;
            }

            if (!CardIncluded)
            {
                valid = true;
            }

            if (!Page.IsValid || !valid)
            {
                ErrorMsgLabel.Text = "" + AppLogic.GetString("editaddress.aspx.15", SkinID, ThisCustomer.LocaleSetting) + "";
                foreach (IValidator aValidator in this.Validators)
                {
                    if (!aValidator.IsValid)
                    {
                        ErrorMsgLabel.Text += "&bull; " + aValidator.ErrorMessage + "";
                    }
                }
                ErrorMsgLabel.Text += "";
                ErrorMsgLabel.Text += errormsg;
                InitializePageContent();
                return;
            }
            else
            {
                ErrorMsgLabel.Text = String.Empty;
            }

            theAddress.AddressType = AddressTypes.Billing;
            theAddress.NickName    = txtAddressNickName.Text;
            theAddress.FirstName   = txtFirstName.Text;
            theAddress.LastName    = txtLastName.Text;
            theAddress.Company     = txtCompany.Text;
            theAddress.Address1    = txtAddress1.Text;
            theAddress.Address2    = txtAddress2.Text;
            theAddress.Suite       = txtSuite.Text;
            theAddress.City        = txtCity.Text;
            theAddress.State       = ddlState.SelectedValue;
            theAddress.Zip         = txtZip.Text;
            theAddress.Country     = ddlCountry.SelectedValue;
            theAddress.Phone       = txtPhone.Text;
            if (ResidenceType == "2")
            {
                theAddress.ResidenceType = ResidenceTypes.Commercial;
            }
            else if (ResidenceType == "1")
            {
                theAddress.ResidenceType = ResidenceTypes.Residential;
            }
            else
            {
                theAddress.ResidenceType = ResidenceTypes.Unknown;
            }

            if (CardIncluded)
            {
                theAddress.PaymentMethodLastUsed = AppLogic.ro_PMCreditCard;
                theAddress.CardName = CommonLogic.FormCanBeDangerousContent("CardName");
                theAddress.CardType = CommonLogic.FormCanBeDangerousContent("CardType");

                string tmpS = CommonLogic.FormCanBeDangerousContent("CardNumber");
                if (!tmpS.StartsWith("*"))
                {
                    theAddress.CardNumber = tmpS;
                }
                theAddress.CardExpirationMonth = CommonLogic.FormCanBeDangerousContent("CardExpirationMonth");
                theAddress.CardExpirationYear  = CommonLogic.FormCanBeDangerousContent("CardExpirationYear");
            }

            theAddress.UpdateDB();

            litCCForm.Text = theAddress.InputCardHTML(ThisCustomer, false, false);

            RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);

            errormsg           = rmgr.ProcessAutoBillAddressUpdate(OriginalRecurringOrderNumber, theAddress);
            ErrorMsgLabel.Text = errormsg != AppLogic.ro_OK ? errormsg : String.Empty;
            if (!ThisCustomer.MasterShouldWeStoreCreditCardInfo)
            {
                theAddress.ClearCCInfo();
                theAddress.UpdateDB();
            }
        }