/// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
     SetPayPalStandardConfigurationProperties();
     paymentServiceSettings = PaymentService.FetchConfiguredPaymentProviders();
     if(paymentServiceSettings != null) {
       foreach(ProviderSettings providerSettings in paymentServiceSettings.ProviderSettingsCollection) {
     if(providerSettings.Name == typeof(PayPalStandardPaymentProvider).Name) {
       payPalStandardConfigurationSettings = providerSettings;
     }
       }
       if(payPalStandardConfigurationSettings != null) {
     bool isLive = false;
     bool isParsed = bool.TryParse(payPalStandardConfigurationSettings.Parameters[PayPalStandardPaymentProvider.ISLIVE], out isLive);
     chkIsLive.Checked = isLive;
     txtBusinessEmail.Text = payPalStandardConfigurationSettings.Parameters[PayPalStandardPaymentProvider.BUSINESS_EMAIL];
     txtPdtId.Text = payPalStandardConfigurationSettings.Parameters[PayPalStandardPaymentProvider.PDTID];
       }
     }
     else {
       paymentServiceSettings = new PaymentServiceSettings();
     }
       }
       catch(Exception ex) {
     Logger.Error(typeof(paypalstandardconfiguration).Name + ".Page_Load", ex);
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
     SetAuthorizeNetConfigurationProperties();
     paymentServiceSettings = PaymentService.FetchConfiguredPaymentProviders();
     if(paymentServiceSettings != null) {
       foreach(ProviderSettings providerSettings in paymentServiceSettings.ProviderSettingsCollection) {
     if(providerSettings.Name == typeof(AuthorizeNetPaymentProvider).Name) {
       authorizeNetConfigurationSettings = providerSettings;
     }
       }
       if (authorizeNetConfigurationSettings != null) {
     txtApiUserName.Text = authorizeNetConfigurationSettings.Parameters[AuthorizeNetPaymentProvider.API_USERNAME];
     txtApiTransactionKey.Text = authorizeNetConfigurationSettings.Parameters[AuthorizeNetPaymentProvider.API_TRANSACTION_KEY];
     bool isInTestMode = true;
     bool isParsed = bool.TryParse(authorizeNetConfigurationSettings.Parameters[AuthorizeNetPaymentProvider.IS_IN_TEST_MODE], out isInTestMode);
     chkIsInTestMode.Checked = isInTestMode;
     bool isLive = false;
     isParsed = bool.TryParse(authorizeNetConfigurationSettings.Parameters[AuthorizeNetPaymentProvider.ISLIVE], out isLive);
     chkIsLive.Checked = isLive;
       }
     }
     else {
       paymentServiceSettings = new PaymentServiceSettings();
     }
       }
       catch(Exception ex) {
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Fetches the payment service settings.
        /// </summary>
        /// <returns></returns>
        private static PaymentServiceSettings FetchPaymentServiceSettings()
        {
            DatabaseConfigurationProvider _databaseConfigurationProvider = new DatabaseConfigurationProvider();
            PaymentServiceSettings        paymentServiceSettings         =
                _databaseConfigurationProvider.FetchConfigurationByName(PaymentServiceSettings.SECTION_NAME) as PaymentServiceSettings;

            return(paymentServiceSettings);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Sets the default payment provider.
        /// </summary>
        /// <param name="defaultPaymentProvider">The default payment provider.</param>
        /// <returns></returns>
        public static int SetDefaultPaymentProvider(string defaultPaymentProvider, string userName)
        {
            Validator.ValidateStringArgumentIsNotNullOrEmptyString(defaultPaymentProvider, DEFAULT_PAYMENT_PROVIDER);
            DatabaseConfigurationProvider _databaseConfigurationProvider = new DatabaseConfigurationProvider();
            PaymentServiceSettings        paymentServiceSettings         =
                _databaseConfigurationProvider.FetchConfigurationByName(PaymentServiceSettings.SECTION_NAME) as PaymentServiceSettings;

            paymentServiceSettings.DefaultProvider = defaultPaymentProvider;
            int id = _databaseConfigurationProvider.SaveConfiguration(PaymentServiceSettings.SECTION_NAME, paymentServiceSettings, userName);

            return(id);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Saves the specified payment service settings.
        /// </summary>
        /// <param name="paymentServiceSettings">The payment service settings.</param>
        /// <returns></returns>
        public static int Save(PaymentServiceSettings paymentServiceSettings, string userName)
        {
            Validator.ValidateObjectIsNotNull(paymentServiceSettings, PAYMENT_SERVICE_SETTINGS);
            Validator.ValidateObjectType(paymentServiceSettings, typeof(PaymentServiceSettings));
            //Set a default provider, regardless of whether or not the service uses one.
            if (paymentServiceSettings.ProviderSettingsCollection.Count == 1)
            {
                paymentServiceSettings.DefaultProvider = paymentServiceSettings.ProviderSettingsCollection[0].Name;
            }
            DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
            int id = databaseConfigurationProvider.SaveConfiguration(PaymentServiceSettings.SECTION_NAME, paymentServiceSettings, userName);

            return(id);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Loads the providers.
        /// </summary>
        private void LoadProviders()
        {
            PaymentServiceSettings paymentServiceSettings = FetchPaymentServiceSettings();
            IPaymentProvider       paymentProvider        = null;
            Type type = null;

            foreach (ProviderSettings providerSettings in paymentServiceSettings.ProviderSettingsCollection)
            {
                //We only want to load the defaultProvider
                //if(paymentServiceSettings.DefaultProvider == providerSettings.Name) {
                type            = Type.GetType(providerSettings.Type);
                paymentProvider = Activator.CreateInstance(type, providerSettings.Arguments) as IPaymentProvider;
                Validator.ValidateObjectIsNotNull(paymentProvider, PAYMENT_PROVIDER);
                _paymentProviderCollection.Add(paymentProvider);
                //}
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Removes the payment provider.
        /// </summary>
        /// <param name="providerName">Name of the provider.</param>
        public static void RemovePaymentProvider(string providerName, string userName)
        {
            Validator.ValidateStringArgumentIsNotNullOrEmptyString(providerName, PROVIDER_NAME);
            DatabaseConfigurationProvider _databaseConfigurationProvider = new DatabaseConfigurationProvider();
            PaymentServiceSettings        paymentServiceSettings         =
                _databaseConfigurationProvider.FetchConfigurationByName(PaymentServiceSettings.SECTION_NAME) as PaymentServiceSettings;

            if (providerName == paymentServiceSettings.DefaultProvider)
            {
                throw new InvalidOperationException(Strings.ResourceManager.GetString("UnableToDeleteDefaultProvider"));
            }
            ProviderSettings providerSettings = paymentServiceSettings.ProviderSettingsCollection.Find(delegate(ProviderSettings theProviderSettings) { return(theProviderSettings.Name == providerName); });

            if (providerSettings != null)
            {
                paymentServiceSettings.ProviderSettingsCollection.Remove(providerSettings);
                _databaseConfigurationProvider.SaveConfiguration(PaymentServiceSettings.SECTION_NAME, paymentServiceSettings, userName);
            }
        }
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
     SetNullPaymentConfigurationProperties();
     paymentServiceSettings = PaymentService.FetchConfiguredPaymentProviders();
     if(paymentServiceSettings != null) {
       foreach(ProviderSettings providerSettings in paymentServiceSettings.ProviderSettingsCollection) {
     if(providerSettings.Name == typeof(NullPaymentProvider).Name) {
       nullPaymentConfigurationSettings = providerSettings;
     }
       }
     }
     else {
       paymentServiceSettings = new PaymentServiceSettings();
     }
       }
       catch(Exception ex) {
     Logger.Error(typeof(nullpaymentconfiguration).Name + ".Page_Load", ex);
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
 /// <summary>
 /// Handles the Click event of the btnSave control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try {
     PaymentServiceSettings paymentServiceSettings = new PaymentServiceSettings();
     ProviderSettings settings = new ProviderSettings();
     settings.Name = typeof(PayPalProPaymentProvider).Name;
     settings.Type = typeof(PayPalProPaymentProvider).AssemblyQualifiedName;
     settings.Parameters.Add("ApiUserName", "username");
     settings.Parameters.Add("ApiPassword", "password");
     settings.Parameters.Add("Signature", "signature");
     settings.Parameters.Add("IsLive", "false");
     paymentServiceSettings.ProviderSettingsCollection.Add(settings);
     DatabaseConfigurationProvider config = new DatabaseConfigurationProvider();
     config.SaveConfiguration(PaymentServiceSettings.SECTION_NAME, paymentServiceSettings, WebUtility.GetUserName());
     SiteSettingCache.RemoveSiteSettingsFromCache();
       }
       catch (Exception ex) {
     Logger.Error(typeof(paymentserviceconfiguration).Name + ".Page_Load", ex);
     Master.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Fetches the configured payment providers.
        /// </summary>
        /// <returns></returns>
        public static PaymentServiceSettings FetchConfiguredPaymentProviders()
        {
            PaymentServiceSettings paymentServiceSettings = FetchPaymentServiceSettings();

            return(paymentServiceSettings);
        }
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
     SetPayPalProConfigurationProperties();
     paymentServiceSettings = PaymentService.FetchConfiguredPaymentProviders();
     if(paymentServiceSettings != null) {
       foreach(ProviderSettings providerSettings in paymentServiceSettings.ProviderSettingsCollection) {
     if(providerSettings.Name == typeof(PayPalProPaymentProvider).Name) {
       payPalProConfigurationSettings = providerSettings;
       break;
     }
       }
       if(payPalProConfigurationSettings != null) {
     txtApiUserName.Text = payPalProConfigurationSettings.Parameters[PayPalProPaymentProvider.API_USERNAME];
     txtApiPassword.Text = payPalProConfigurationSettings.Parameters[PayPalProPaymentProvider.API_PASSWORD];
     txtSignature.Text = payPalProConfigurationSettings.Parameters[PayPalProPaymentProvider.SIGNATURE];
     bool isLive = false;
     bool isParsed = bool.TryParse(payPalProConfigurationSettings.Parameters[PayPalProPaymentProvider.ISLIVE], out isLive);
     chkIsLive.Checked = isLive;
       }
     }
     else {
       paymentServiceSettings = new PaymentServiceSettings();
     }
       }
       catch(Exception ex) {
     Logger.Error(typeof(paypalproconfiguration).Name + ".Page_Load", ex);
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Saves the specified payment service settings.
 /// </summary>
 /// <param name="paymentServiceSettings">The payment service settings.</param>
 /// <returns></returns>
 public static int Save(PaymentServiceSettings paymentServiceSettings, string userName)
 {
     Validator.ValidateObjectIsNotNull(paymentServiceSettings, PAYMENT_SERVICE_SETTINGS);
       Validator.ValidateObjectType(paymentServiceSettings, typeof(PaymentServiceSettings));
       //Set a default provider, regardless of whether or not the service uses one.
       if(paymentServiceSettings.ProviderSettingsCollection.Count == 1) {
     paymentServiceSettings.DefaultProvider = paymentServiceSettings.ProviderSettingsCollection[0].Name;
       }
       DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
       int id = databaseConfigurationProvider.SaveConfiguration(PaymentServiceSettings.SECTION_NAME, paymentServiceSettings, userName);
       return id;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            paymentServiceSettings = PaymentService.FetchConfiguredPaymentProviders();
              if (paymentServiceSettings != null) {
            foreach (ProviderSettings providerSettings in paymentServiceSettings.ProviderSettingsCollection) {
              if (providerSettings.Name == typeof(PayPalProPaymentProvider).Name) {
            payPalProConfigurationSettings = providerSettings;
            break;
              }
            }
            if (!Page.IsPostBack) {
              if (payPalProConfigurationSettings != null) {
            bool isLive = false;
            bool isParsed = bool.TryParse(payPalProConfigurationSettings.Parameters[PayPalProPaymentProvider.ISLIVE],
                                          out isLive);
            if (isLive) {
              rbProductionMode.Checked = true;
            }
            else {
              rbSandboxMode.Checked = true;
            }

            if (!string.IsNullOrEmpty(payPalProConfigurationSettings.Parameters[PayPalProPaymentProvider.BUSINESS_EMAIL])) {
              txtEmailAddress.Text = payPalProConfigurationSettings.Parameters[PayPalProPaymentProvider.BUSINESS_EMAIL];
              txtApiUserName.Text = txtApiPassword.Text = txtSignature.Text = string.Empty;
              txtEmailAddress.Enabled = rfvEmailAddress.Enabled = true;
              pnlPayPalApiCredentials.Enabled = false;
              txtApiUserName.Enabled = txtApiPassword.Enabled = txtSignature.Enabled = false;
              rfvApiUserName.Enabled = rfvApiPassword.Enabled = rfvApiSignature.Enabled = false;
              rbEmailAddress.Checked = true;
            }
            else {
              txtApiUserName.Text = payPalProConfigurationSettings.Parameters[PayPalProPaymentProvider.API_USERNAME];
              txtApiPassword.Text = payPalProConfigurationSettings.Parameters[PayPalProPaymentProvider.API_PASSWORD];
              txtSignature.Text = payPalProConfigurationSettings.Parameters[PayPalProPaymentProvider.SIGNATURE];
              txtEmailAddress.Text = string.Empty;
              txtEmailAddress.Enabled = rfvEmailAddress.Enabled = false;
              pnlPayPalApiCredentials.Enabled = true;
              txtApiUserName.Enabled = txtApiPassword.Enabled = txtSignature.Enabled = true;
              rfvApiUserName.Enabled = rfvApiPassword.Enabled = rfvApiSignature.Enabled = true;
              rbAPICredentials.Checked = true;
            }
              }
            }
              }
              else {
            paymentServiceSettings = new PaymentServiceSettings();
            if (!Page.IsPostBack) {
              rbProductionMode.Checked = true;
              rbEmailAddress.Checked = true;
            }
              }
        }
 /// <summary>
 /// Saves the specified payment service settings.
 /// </summary>
 /// <param name="paymentServiceSettings">The payment service settings.</param>
 public int Save(PaymentServiceSettings paymentServiceSettings, string userName)
 {
     int id = PaymentService.Save(paymentServiceSettings, userName);
       return id;
 }