Ejemplo n.º 1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ZNode.Libraries.Shipping.FedEx fdx = new ZNode.Libraries.Shipping.FedEx();
        ZNodeEncryption decrypt = new ZNodeEncryption();

        if (ZNodeConfigManager.SiteConfig.FedExProductionKey.Length == 0 || ZNodeConfigManager.SiteConfig.FedExSecurityCode.Length == 0)
        {
            lblErrorMsg.Text = "Please obtain user account first using RegisterCSPUSer.";
            return;
        }

        fdx.ClientProductId = ZNodeConfigManager.SiteConfig.FedExClientProductId;
        fdx.ClientProductVersion = ZNodeConfigManager.SiteConfig.FedExClientProductVersion;
        fdx.CSPAccessKey = ZNodeConfigManager.SiteConfig.FedExCSPKey;
        fdx.CSPPassword = ZNodeConfigManager.SiteConfig.FedExCSPPassword;
        fdx.FedExAccountNumber = decrypt.DecryptData(ZNodeConfigManager.SiteConfig.FedExAccountNumber);
        fdx.CurrencyCode = ZNode.Libraries.ECommerce.Catalog.ZNodeCurrencyManager.CurrencyCode();
        fdx.FedExAccessKey = decrypt.DecryptData(ZNodeConfigManager.SiteConfig.FedExProductionKey);
        fdx.FedExSecurityCode = decrypt.DecryptData(ZNodeConfigManager.SiteConfig.FedExSecurityCode);

        ZNode.Libraries.Shipping.FedExSubscribeService.Address BillingAddress = new ZNode.Libraries.Shipping.FedExSubscribeService.Address();
        BillingAddress.StreetLines = new string[] { txtBillingStreet1.Text.Trim(), txtBillingStreet2.Text.Trim() };
        BillingAddress.PostalCode = txtBillingPostalCode.Text.Trim();
        BillingAddress.City = txtBillingCity.Text.Trim();
        BillingAddress.StateOrProvinceCode = txtBillingState.Text.Trim();
        BillingAddress.CountryCode = lstBillingCountryCode.SelectedValue;

        string meterNumber = fdx.SubscribeUser(FirstName.Text.Trim() + " " + LastName.Text.Trim(), PhoneNumber.Text.Trim(), "", "", EmailID.Text, BillingAddress);

        if (fdx.ErrorCode == "0")//Check for success
        {
            PortalService portalService = new PortalService();
            Portal _portal = portalService.GetByPortalID(ZNodeConfigManager.SiteConfig.PortalID);

            _portal.FedExMeterNumber = decrypt.EncryptData(meterNumber);

            portalService.Update(_portal);

            Response.Redirect("~/admin/secure/settings/default.aspx?mode=fedex");
        }
        else
        {
            lblErrorMsg.Text = fdx.ErrorDescription;
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ZNode.Libraries.Shipping.FedEx fdx = new ZNode.Libraries.Shipping.FedEx();
        ZNodeEncryption decrypt = new ZNodeEncryption ();

        fdx.ClientProductId = ZNodeConfigManager.SiteConfig.FedExClientProductId;
        fdx.ClientProductVersion = ZNodeConfigManager.SiteConfig.FedExClientProductVersion;
        fdx.CSPAccessKey = ZNodeConfigManager.SiteConfig.FedExCSPKey;
        fdx.CSPPassword = ZNodeConfigManager.SiteConfig.FedExCSPPassword;
        fdx.CurrencyCode = ZNode.Libraries.ECommerce.Catalog.ZNodeCurrencyManager.CurrencyCode();
        fdx.FedExAccountNumber = decrypt.DecryptData(ZNodeConfigManager.SiteConfig.FedExAccountNumber);

        ZNode.Libraries.Shipping.FedExRegisterCspUserService.Address BillingAddress = new ZNode.Libraries.Shipping.FedExRegisterCspUserService.Address();

        BillingAddress.StreetLines =  new string[]{txtBillingStreet1.Text.Trim(),txtBillingStreet2.Text.Trim()};
        BillingAddress.City = txtBillingCity.Text.Trim();
        BillingAddress.StateOrProvinceCode = txtBillingState.Text.Trim();
        BillingAddress.PostalCode = txtBillingPostalCode.Text.Trim();
        BillingAddress.CountryCode = lstBillingCountryCode.SelectedValue;

        ZNode.Libraries.Shipping.FedExRegisterCspUserService.WebAuthenticationCredential userCredential = fdx.RegisterCPCUser(FirstName.Text.Trim(), LastName.Text.Trim(), PhoneNumber.Text.Trim(), "", "", EmailId.Text.Trim(), BillingAddress);

        if (fdx.ErrorCode == "0")
        {
            //User Credential
            string userKey = userCredential.Key;
            string password = userCredential.Password;

            PortalService portalService = new PortalService();
            Portal _portal = portalService.GetByPortalID(ZNodeConfigManager.SiteConfig.PortalID);

            _portal.FedExProductionKey = decrypt.EncryptData(userKey);
            _portal.FedExSecurityCode = decrypt.EncryptData(password);

            portalService.Update(_portal);

            //remove the siteconfig from session
            ZNodeConfigManager.SiteConfig = null;

            Response.Redirect("~/admin/secure/settings/default.aspx?mode=fedex");
        }
        else
        {
            lblErrorMsg.Text = fdx.ErrorDescription;
        }
    }