Пример #1
0
        private static void LoadProvider()
        {
            // Avoid claiming lock if providers are already loaded
            if (_provider == null)
            {
                lock (_lock)
                {
                    // Do this again to make sure _provider is still null
                    if (_provider == null)
                    {
                        // Get a reference to the <PaymentService> section
                        PaymentServiceSection section = (PaymentServiceSection)
                                                        WebConfigurationManager.GetSection
                                                            ("PaymentService");

                        // Load registered providers and point _provider
                        // to the default provider

                        //since this is a CC provider, we only want one
                        //so no collections for providers.
                        //however feel free to change this as needed.
                        _provider = (PaymentProvider)ProvidersHelper.InstantiateProvider(section.Providers[0], typeof(PaymentProvider));

                        if (_provider == null)
                        {
                            throw new ProviderException
                                      ("Unable to load default PaymentProvider");
                        }
                    }
                }
            }
        }
Пример #2
0
    protected void btnSetCC_Click(object sender, EventArgs e)
    {
        // Get the current configuration file.
        System.Configuration.Configuration       config  = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
        Commerce.Providers.PaymentServiceSection section = (Commerce.Providers.PaymentServiceSection)config.GetSection("PaymentService");

        //load up the ConfigSection
        ProviderSettings settings = new ProviderSettings();

        try {
            string userName     = txtCCUserName.Text;
            string password     = txtCCPassword.Text;
            string key          = txtCCKey.Text;
            string providerName = ddlCCProvider.SelectedValue;

            section.AcceptCreditCards = chkAcceptCC.Checked;
            //section.CurrencyCode = ddlCurrencyType.SelectedValue;
            section.Providers.Clear();
            //apply the settings based on the provider
            if (providerName == "PayPalPaymentProvider")
            {
                section.DefaultProvider = "PayPalPaymentProvider";
                settings.Name           = "PayPalPaymentProvider";
                settings.Parameters.Add("type", "Commerce.Providers.PayPalPaymentProvider");
                settings.Parameters.Add("apiUserName", txtPPAPIAccount.Text.Trim());
                settings.Parameters.Add("apiPassword", txtPPAPIPassword.Text.Trim());
                settings.Parameters.Add("signature", txtPPAPISignature.Text.Trim());
                bool isLive = !chkUsePPSandbox.Checked;
                settings.Parameters.Add("isLive", isLive.ToString());
                section.Providers.Add(settings);
            }
            else
            {
                section.DefaultProvider = providerName;
                settings.Name           = providerName;
                settings.Parameters.Add("type", "Commerce.Providers." + providerName);
                settings.Parameters.Add("serviceUserName", txtPPAPIAccount.Text);
                settings.Parameters.Add("servicePassword", txtPPAPIPassword.Text);
                settings.Parameters.Add("transactionKey", txtCCKey.Text);
                settings.Parameters.Add("serverURL", txtCCUrl.Text);
                settings.Parameters.Add("currencyCode", ddlCurrencyType.SelectedValue);
                section.Providers.Add(settings);
            }
            config.Save();
            ResultMessage5.ShowSuccess("Credit Card Settings Saved");
        }
        catch (Exception x) {
            ResultMessage5.ShowFail("Cannot write to the Web.Config file; in order to have the application update the configuration, you have to allow write access to the ASNET account (or NETWORK SERVICE) and make sure the file is not marked as Read Only");
        }
    }
Пример #3
0
    void LoadSettings()
    {
        //general settings
        ddlLogin.SelectedValue        = SiteConfig.RequireLogin;
        ddlCurrencyType.SelectedValue = Enum.GetName(typeof(Commerce.Common.CurrencyCode), SiteConfig.CurrencyCode);

        //standard
        chkUsePPStandard.Checked        = SiteConfig.UsePayPalPaymentsStandard;
        chkUsePPStandardSandbox.Checked = SiteConfig.UsePPStandardSandbox;
        txtBusinessEmail.Text           = SiteConfig.BusinessEmail;
        txtPDTID.Text = SiteConfig.PayPalPDTID;

        //pro settings
        chkUsePPPro.Checked     = SiteConfig.UsePayPalExpressCheckout;
        chkUsePPSandbox.Checked = SiteConfig.UsePPProSandbox;
        txtPPAPIAccount.Text    = SiteConfig.PayPalAPIUserName;
        txtPPAPIPassword.Text   = SiteConfig.PayPalAPIPassword;
        txtPPAPISignature.Text  = SiteConfig.PayPalAPISignature;

        //CC Bits
        chkAcceptCC.Checked = SiteConfig.AcceptCreditCards;

        //get the provider, if there is one, and set the boxes
        System.Configuration.Configuration       config  = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
        Commerce.Providers.PaymentServiceSection section = (Commerce.Providers.PaymentServiceSection)config.GetSection("PaymentService");

        if (section.Providers.Count > 0)
        {
            if (section.Providers[0].Name == "PayPalPaymentProvider")
            {
            }
            else
            {
                txtCCKey.Text      = section.Providers[0].Parameters["transactionKey"].ToString();
                txtCCPassword.Text = section.Providers[0].Parameters["servicePassword"].ToString();
                txtCCUrl.Text      = section.Providers[0].Parameters["serverURL"].ToString();
                txtCCUserName.Text = section.Providers[0].Parameters["serviceUserName"].ToString();
            }
        }
    }