Ejemplo n.º 1
0
        private void SaveGateWayProviderDHL()
        {
            DHLInternational provider = (DHLInternational)_ShipGateway.GetProviderInstance();

            provider.UseDebugMode         = UseDebugMode.Checked;
            provider.UseTestMode          = UseTestMode.Checked;
            provider.EnablePackageBreakup = EnablePackaging.Checked;
            provider.ShippingKey          = ShippingKey.Text;
            provider.AccountNumber        = AccountNumber.Text;
            provider.UserID     = UserID.Text;
            provider.Password   = Password.Text;
            provider.DaysToShip = AlwaysConvert.ToInt(DaysToShip.Text, 1);
            if (provider.DaysToShip < 1)
            {
                provider.DaysToShip = 1;
            }
            DaysToShip.Text                 = provider.DaysToShip.ToString();
            provider.LiveModeUrl            = LiveServerURL.Text;
            provider.TestModeUrl            = TestServerURL.Text;
            provider.TrackingUrl            = TrackingURL.Text;
            provider.MaxPackageWeight       = AlwaysConvert.ToDecimal(MaxWeight.Text, (decimal)provider.MaxPackageWeight);
            provider.MinPackageWeight       = AlwaysConvert.ToDecimal(MinWeight.Text, (decimal)provider.MinPackageWeight);
            provider.DutiableFlag           = DutiableFlag.Checked;
            provider.CustomsValueMultiplier = AlwaysConvert.ToDecimal(CustomsValueMultiplier.Text, 1);
            provider.CommerceLicensed       = CommerceLicensed.Checked;
            provider.FilingType             = (DHLInternational.FilingTypeFlags)AlwaysConvert.ToEnum(typeof(DHLInternational.FilingTypeFlags), FilingType.SelectedValue, DHLInternational.FilingTypeFlags.ITN);
            provider.FTRExemptionCode       = FTRExemptionCode.Text;
            provider.ITNNumber              = ITNNumber.Text;
            provider.EINCode                = EINCode.Text;
            _ShipGateway.UpdateConfigData(provider.GetConfigData());
            _ShipGateway.Save();
        }
Ejemplo n.º 2
0
        protected void RegisterButton_Click(object sender, System.EventArgs e)
        {
            // make sure conditions appear for store
            Store  store      = AbleContext.Current.Store;
            string conditions = store.Settings.CheckoutTermsAndConditions;

            if (string.IsNullOrEmpty(conditions))
            {
                conditions = ConditionText.Text;
            }
            else
            {
                if (!conditions.Contains(ConditionText.Text))
                {
                    conditions += "\r\n\r\n<p>" + ConditionText.Text + "</p>";
                }
            }
            store.Settings.CheckoutTermsAndConditions = conditions;
            store.Save();

            AustraliaPost provider = new AustraliaPost();

            provider.AccountActive = true;
            ShipGateway gateway = new ShipGateway();

            gateway.Name    = provider.Name;
            gateway.ClassId = Misc.GetClassId(provider.GetType());
            gateway.UpdateConfigData(provider.GetConfigData());
            gateway.Enabled = true;
            gateway.Save();
            Response.Redirect("Configure.aspx?ShipGatewayId=" + gateway.Id.ToString());
        }
Ejemplo n.º 3
0
        private void SaveShipGateWay()
        {
            AustraliaPost provider = (AustraliaPost)_ShipGateway.GetProviderInstance();

            provider.UseDebugMode         = UseDebugMode.Checked;
            provider.EnablePackageBreakup = EnablePackaging.Checked;
            provider.MaxPackageWeight     = AlwaysConvert.ToDecimal(MaxWeight.Text, (decimal)provider.MaxPackageWeight);
            provider.MinPackageWeight     = AlwaysConvert.ToDecimal(MinWeight.Text, (decimal)provider.MinPackageWeight);
            _ShipGateway.UpdateConfigData(provider.GetConfigData());
            _ShipGateway.Save();
        }
Ejemplo n.º 4
0
        protected void RegisterButton_Click(object sender, System.EventArgs e)
        {
            CanadaPost provider = new CanadaPost();

            provider.MerchantCPCID = MerchantId.Text;
            provider.AccountActive = true;
            ShipGateway gateway = new ShipGateway();

            gateway.Name    = provider.Name;
            gateway.ClassId = Misc.GetClassId(typeof(CanadaPost));
            gateway.UpdateConfigData(provider.GetConfigData());
            gateway.Enabled = true;
            gateway.Save();
            Response.Redirect("Configure.aspx?ShipGatewayId=" + gateway.Id);
        }
Ejemplo n.º 5
0
 protected void NextButton_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         USPS provider = new USPS();
         provider.UserId       = UserId.Text;
         provider.UserIdActive = true;
         ShipGateway gateway = new ShipGateway();
         gateway.Name    = provider.Name;
         gateway.ClassId = Misc.GetClassId(typeof(USPS));
         gateway.UpdateConfigData(provider.GetConfigData());
         gateway.Enabled = true;
         gateway.Save();
         Response.Redirect("Configure.aspx?ShipGatewayId=" + gateway.Id);
     }
 }
Ejemplo n.º 6
0
 protected void RegisterButton_Click(object sender, System.EventArgs e)
 {
     if (Page.IsValid)
     {
         DHLInternational provider = new DHLInternational();
         provider.UserID   = DHLUserID.Text;
         provider.Password = DHLPassword.Text;
         ShipGateway gateway = new ShipGateway();
         gateway.Name    = provider.Name;
         gateway.ClassId = Misc.GetClassId(typeof(DHLInternational));
         gateway.UpdateConfigData(provider.GetConfigData());
         gateway.Enabled = true;
         gateway.Save();
         Response.Redirect("Configure.aspx?ShipGatewayId=" + gateway.Id);
     }
 }
Ejemplo n.º 7
0
        private void SaveShipGateWayProvider()
        {
            CanadaPost provider = (CanadaPost)_ShipGateway.GetProviderInstance();

            provider.UseDebugMode         = UseDebugMode.Checked;
            provider.UseTestMode          = UseTestMode.Checked;
            provider.EnablePackageBreakup = EnablePackaging.Checked;
            provider.MerchantCPCID        = MerchantId.Text;
            provider.LiveModeUrl          = LiveServerURL.Text;
            provider.TestModeUrl          = TestServerURL.Text;
            provider.TrackingUrl          = TrackingURL.Text;
            provider.MaxPackageWeight     = AlwaysConvert.ToDecimal(MaxWeight.Text, (decimal)provider.MaxPackageWeight);
            provider.MinPackageWeight     = AlwaysConvert.ToDecimal(MinWeight.Text, (decimal)provider.MinPackageWeight);
            _ShipGateway.UpdateConfigData(provider.GetConfigData());
            _ShipGateway.Save();
        }
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                UPS provider = (UPS)_ShipGateway.GetProviderInstance();
                provider.UserId    = UserId.Text;
                provider.Password  = Password.Text;
                provider.AccessKey = AccessKey.Text;
                provider.EnableAddressValidation = EnableAddressValidation.Checked;
                provider.AddressServiceTestUrl   = AddressServiceTestUrl.Text;
                provider.AddressServiceLiveUrl   = AddressServiceLiveUrl.Text;

                _ShipGateway.UpdateConfigData(provider.GetConfigData());
                _ShipGateway.Save();
                Response.Redirect("Configure.aspx?ShipGatewayId=" + _ShipGateway.Id);
            }
        }
Ejemplo n.º 9
0
        private void SaveGateWayUSPS()
        {
            USPS provider = (USPS)_ShipGateway.GetProviderInstance();

            provider.UseDebugMode            = UseDebugMode.Checked;
            provider.UseTestMode             = UseTestMode.Checked;
            provider.UserId                  = UserId.Text;
            provider.LiveModeUrl             = LiveServerURL.Text;
            provider.TestModeUrl             = TestServerURL.Text;
            provider.TrackingUrl             = TrackingURL.Text;
            provider.MaxPackageWeight        = AlwaysConvert.ToDecimal(MaxWeight.Text, (decimal)provider.MaxPackageWeight);
            provider.MinPackageWeight        = AlwaysConvert.ToDecimal(MinWeight.Text, (decimal)provider.MinPackageWeight);
            provider.EnablePackageBreakup    = EnablePackaging.Checked;
            provider.EnableAddressValidation = EnableAddressValidation.Checked;
            provider.AddressServiceUrl       = AddressServiceUrl.Text;
            provider.UseOnlineRate           = UseOnlineRates.Checked;
            provider.IntlMailType            = IntlMailType.SelectedValue;
            _ShipGateway.UpdateConfigData(provider.GetConfigData());
            _ShipGateway.Save();
        }
Ejemplo n.º 10
0
        private void SaveGateWayUPS()
        {
            UPS provider = (UPS)_ShipGateway.GetProviderInstance();
            int customerTypeIndex;

            if (CustomerType_DailyPickup.Checked)
            {
                customerTypeIndex = 0;
            }
            else if (CustomerType_Occasional.Checked)
            {
                customerTypeIndex = 1;
            }
            else if (CustomerType_Retail.Checked)
            {
                customerTypeIndex = 2;
            }
            else
            {
                customerTypeIndex = 3;
            }
            provider.CustomerType         = ((UPS.UpsCustomerType)(customerTypeIndex));
            provider.UseInsurance         = UseInsurance.Checked;
            provider.UseDebugMode         = UseDebugMode.Checked;
            provider.UseTestMode          = UseTestMode.Checked;
            provider.LiveModeUrl          = LiveServerURL.Text;
            provider.TestModeUrl          = TestServerURL.Text;
            provider.TrackingUrl          = TrackingURL.Text;
            provider.ShipperNumber        = ShipperNumber.Text;
            provider.EnableShipping       = EnableLabels.Checked;
            provider.MaxPackageWeight     = AlwaysConvert.ToDecimal(MaxWeight.Text, (decimal)provider.MaxPackageWeight);
            provider.MinPackageWeight     = AlwaysConvert.ToDecimal(MinWeight.Text, (decimal)provider.MinPackageWeight);
            provider.EnablePackageBreakup = EnablePackaging.Checked;
            //provider.EnableAddressValidation = EnableAddressValidation.Checked;
            //provider.AddressServiceTestUrl = AddressServiceTestUrl.Text;
            //provider.AddressServiceLiveUrl = AddressServiceLiveUrl.Text;
            _ShipGateway.UpdateConfigData(provider.GetConfigData());
            _ShipGateway.Save();
        }
Ejemplo n.º 11
0
        protected void NextButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                // CUSTOM ERROR VALIDATION
                if (Country.SelectedValue.Equals("US"))
                {
                    // MAKE SURE POSTALCODE AND PROVINCECODE WERE PROVIDED
                    if (string.IsNullOrEmpty(Province.Text))
                    {
                        AddCustomErrorMessage("You must enter a valid 2 letter state abbreviation.", Province);
                    }
                    else
                    {
                        // MAKE SURE THE VALUE IS VALID
                        Province.Text = Province.Text.ToUpperInvariant();
                        string[] states = "AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY|AE|AA|AE|AE|AP".Split("|".ToCharArray());
                        if (Array.IndexOf(states, Province.Text) < 0)
                        {
                            AddCustomErrorMessage("You must enter a valid 2 letter state abbreviation.", Province);
                        }
                    }
                    if (string.IsNullOrEmpty(PostalCode.Text))
                    {
                        AddCustomErrorMessage("Your 5 digit ZIP code is required.", PostalCode);
                    }
                    else
                    {
                        // MAKE SURE ZIP IS VALID FORMAT
                        if (!Regex.IsMatch(PostalCode.Text, "^\\d{5}$"))
                        {
                            AddCustomErrorMessage("You must enter a valid 5 digit ZIP code.", PostalCode);
                        }
                    }
                }
                else if (Country.SelectedValue.Equals("CA"))
                {
                    // MAKE SURE POSTALCODE AND PROVINCECODE WERE PROVIDED
                    if (string.IsNullOrEmpty(Province.Text))
                    {
                        AddCustomErrorMessage("You must enter a valid 2 letter province abbreviation.", Province);
                    }
                    else
                    {
                        // MAKE SURE THE VALUE IS VALID
                        Province.Text = Province.Text.ToUpperInvariant();
                        string[] states = "AB|BC|MB|NB|NL|NT|NS|NU|ON|PE|QC|SK|YT".Split("|".ToCharArray());
                        if ((Array.IndexOf(states, Province.Text) < 0))
                        {
                            AddCustomErrorMessage("You must enter a valid 2 letter province abbreviation.", Province);
                        }
                    }
                    if (string.IsNullOrEmpty(PostalCode.Text))
                    {
                        AddCustomErrorMessage("Your 6 character postal code is required.", PostalCode);
                    }
                    else
                    {
                        // MAKE SURE ZIP IS VALID FORMAT
                        PostalCode.Text = PostalCode.Text.ToUpperInvariant().Replace(" ", "");
                        if (!Regex.IsMatch(PostalCode.Text, "^([A-Za-z]\\d[A-Za-z]( |-)*\\d[A-Za-z]\\d)$"))
                        {
                            AddCustomErrorMessage("You must enter a valid postal code.", PostalCode);
                        }
                    }
                }
                // CHECK FOR VALID PHONE NUMBER
                Phone.Text = Regex.Replace(Phone.Text, "[^0-9]", "");
                Regex phoneRegex = new Regex(@"^\d{10,16}$");
                if (!phoneRegex.IsMatch(Phone.Text))
                {
                    PhoneValidator2.IsValid = false;
                }

                if (Page.IsValid)
                {
                    // CONTINUE WITH REGISTRATION
                    UPS.UpsRegistrationInformation registration = new UPS.UpsRegistrationInformation();
                    registration.ContactName  = ContactName.Text;
                    registration.ContactTitle = ContactTitle.Text;
                    registration.Company      = CompanyName.Text;
                    registration.CompanyUrl   = CompanyUrl.Text;
                    registration.Address1     = Address1.Text;
                    if (!String.IsNullOrEmpty(Address2.Text))
                    {
                        registration.Address2 = Address2.Text;
                    }
                    registration.City        = City.Text;
                    registration.CountryCode = Country.SelectedValue;
                    if ((registration.CountryCode.Equals("US") || registration.CountryCode.Equals("CA")))
                    {
                        registration.StateProvinceCode = Province.Text;
                        registration.PostalCode        = PostalCode.Text;
                    }
                    else
                    {
                        registration.StateProvinceCode = string.Empty;
                        registration.PostalCode        = string.Empty;
                    }
                    Phone.Text = Phone.Text;
                    registration.ContactPhone   = Phone.Text;
                    registration.ContactEmail   = Email.Text;
                    registration.ShipperNumber  = UpsAccount.Text;
                    registration.RequestContact = RequestContact.SelectedValue.Equals("YES");
                    try
                    {
                        // SEND THE REGISTRATION
                        UPS         provider = new UPS();
                        ShipGateway gateway  = new ShipGateway();
                        gateway.Name    = provider.Name;
                        gateway.ClassId = Misc.GetClassId(typeof(UPS));
                        provider.Register(gateway, registration);
                        if (provider.IsActive)
                        {
                            gateway.UpdateConfigData(provider.GetConfigData());
                            gateway.Enabled = true;
                            gateway.Save();
                            Response.Redirect("Register.aspx?ShipGatewayId=" + gateway.Id);
                        }
                    }
                    catch (Exception ex)
                    {
                        AddCustomErrorMessage("Error during registration: " + ex.Message, RequestContact);
                    }
                }
            }
        }