Ejemplo n.º 1
0
        /// <summary>
        /// Construct a request object. Set the static setting from the
        /// web.config file.
        /// </summary>
        /// <param name="checkConfiguration">By default is true: will check config file if
        /// `Ris.Url`,
        /// `Ris.MerchantId`,
        /// `Ris.Config.Key` are set.</param>
        /// <param name="configuration">Instance of configuration.</param>
        /// <exception cref="Kount.Ris.RequestException">Thrown when there is
        /// static data missing for a RIS request.</exception>
        protected Request(bool checkConfiguration, Configuration configuration)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot cconfiguration = builder.Build();

            configuration.ConnectTimeout = "10000";



            if (checkConfiguration)
            {
                this.CheckConfigurationParameter(configuration.MerchantId, nameof(configuration.MerchantId));
                this.CheckConfigurationParameter(configuration.URL, nameof(configuration.URL));
                this.CheckConfigurationParameter(configuration.ConfigKey, nameof(configuration.ConfigKey));
            }

            // timeout must be always defined
            this.CheckConfigurationParameter(configuration.ConnectTimeout, nameof(configuration.ConnectTimeout));
            logTimeElapsed = (String.IsNullOrEmpty(cconfiguration.GetConnectionString("LOG.SIMPLE.ELAPSED"))
                ? false
                : cconfiguration.GetConnectionString("LOG.SIMPLE.ELAPSED").Trim().ToLower().Equals("on"));

            this.data = new System.Collections.Hashtable();
            this.SetMerchantId(Int32.Parse(configuration.MerchantId));

            Khash.ConfigKey = Khash.GetBase85ConfigKey(configuration.ConfigKey);

            var risVersion = String.IsNullOrEmpty(configuration.Version)
                        ? RisVersion
                        : configuration.Version;

            this.SetVersion(risVersion);
            this.SetUrl(configuration.URL);
            this.connectTimeout = Int32.Parse(configuration.ConnectTimeout);

            if (!String.IsNullOrEmpty(configuration.ApiKey))
            {
                this.SetApiKey(configuration.ApiKey);
            }
            else
            {
                this.CheckConfigurationParameter(configuration.CertificateFile, nameof(configuration.CertificateFile));
                this.CheckConfigurationParameter(configuration.PrivateKeyPassword, nameof(configuration.PrivateKeyPassword));
                this.SetCertificate(
                    configuration.CertificateFile,
                    configuration.PrivateKeyPassword);
            }

            // KHASH payment encoding is set by default.
            this.SetKhashPaymentEncoding(true);
        }
        /// <summary>
        /// Construct a request object. Set the static setting from the
        /// web.config file.
        /// </summary>
        /// <param name="checkConfiguration">By default is true: will check config file if
        /// `Ris.Url`,
        /// `Ris.MerchantId`,
        /// `Ris.Config.Key` are set.</param>
        /// <param name="configuration">Instance of configuration.</param>
        /// <exception cref="Kount.Ris.RequestException">Thrown when there is
        /// static data missing for a RIS request.</exception>
        protected Request(bool checkConfiguration, Configuration configuration)
        {
            XmlDocument log4netConfig = new XmlDocument();

            log4netConfig.Load(System.IO.File.OpenRead("log4net.config"));

            var repo = log4net.LogManager.CreateRepository(
                Assembly.GetEntryAssembly(), typeof(log4net.Repository.Hierarchy.Hierarchy));

            log4net.Config.XmlConfigurator.Configure(repo, log4netConfig["log4net"]);

            if (checkConfiguration)
            {
                this.CheckConfigurationParameter(configuration.MerchantId, nameof(configuration.MerchantId));
                this.CheckConfigurationParameter(configuration.URL, nameof(configuration.URL));
                this.CheckConfigurationParameter(configuration.ConfigKey, nameof(configuration.ConfigKey));
            }


            this.CheckConfigurationParameter(configuration.ConnectTimeout, nameof(configuration.ConnectTimeout));
            logTimeElapsed = (String.IsNullOrEmpty(configuration.LogSimpleElapsed)
               ? false
               : configuration.LogSimpleElapsed.Trim().ToLower().Equals("on"));

            this.data = new System.Collections.Hashtable();
            this.SetMerchantId(Int32.Parse(configuration.MerchantId));

            Khash.ConfigKey = Khash.GetBase85ConfigKey(configuration.ConfigKey);

            var risVersion = String.IsNullOrEmpty(configuration.Version)
                        ? RisVersion
                        : configuration.Version;

            this.SetVersion(risVersion);
            this.SetUrl(configuration.URL);
            this.connectTimeout = Int32.Parse(configuration.ConnectTimeout);

            if (!String.IsNullOrEmpty(configuration.ApiKey))
            {
                this.SetApiKey(configuration.ApiKey);
            }
            else
            {
                this.CheckConfigurationParameter(configuration.CertificateFile, nameof(configuration.CertificateFile));
                this.CheckConfigurationParameter(configuration.PrivateKeyPassword, nameof(configuration.PrivateKeyPassword));
                this.SetCertificate(
                    configuration.CertificateFile,
                    configuration.PrivateKeyPassword);
            }

            // KHASH payment encoding is set by default.
            this.SetKhashPaymentEncoding(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Construct a request object. Set the static setting from the
        /// web.config file.
        /// </summary>
        /// <param name="checkConfiguration">By default is true: will check config file if
        /// `Ris.Url`,
        /// `Ris.MerchantId`,
        /// `Ris.Config.Key` are set.</param>
        /// <param name="configuration">Instance of configuration.</param>
        /// <exception cref="Kount.Ris.RequestException">Thrown when there is
        /// static data missing for a RIS request.</exception>
        protected Request(bool checkConfiguration, Configuration configuration)
        {
            ILoggerFactory factory = LogFactory.GetLoggerFactory();

            this.logger = factory.GetLogger(typeof(Request).ToString());

            if (checkConfiguration)
            {
                this.CheckConfigurationParameter(configuration.MerchantId, nameof(configuration.MerchantId));
                this.CheckConfigurationParameter(configuration.URL, nameof(configuration.URL));
                this.CheckConfigurationParameter(configuration.ConfigKey, nameof(configuration.ConfigKey));
            }

            // timeout must be always defined
            this.CheckConfigurationParameter(configuration.ConnectTimeout, nameof(configuration.ConnectTimeout));

            this.data = new System.Collections.Hashtable();
            this.SetMerchantId(Int32.Parse(configuration.MerchantId));

            Khash.ConfigKey = Khash.GetBase85ConfigKey(configuration.ConfigKey);

            var risVersion = String.IsNullOrEmpty(configuration.Version)
                        ? RisVersion
                        : configuration.Version;

            this.SetVersion(risVersion);
            this.SetUrl(configuration.URL);
            this.connectTimeout = Int32.Parse(configuration.ConnectTimeout);

            if (!String.IsNullOrEmpty(configuration.ApiKey))
            {
                this.SetApiKey(configuration.ApiKey);
            }
            else
            {
                this.CheckConfigurationParameter(configuration.CertificateFile, nameof(configuration.CertificateFile));
                this.CheckConfigurationParameter(configuration.PrivateKeyPassword, nameof(configuration.PrivateKeyPassword));
                this.SetCertificate(
                    configuration.CertificateFile,
                    configuration.PrivateKeyPassword);
            }

            // KHASH payment encoding is set by default.
            this.SetKhashPaymentEncoding(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Construct a request object. Set the static setting from the
        /// web.config file.
        /// </summary>
        /// <param name="checkConfiguration">By default is true: will check config file if
        /// `Ris.Url`,
        /// `Ris.MerchantId`,
        /// `Ris.Config.Key` are set.</param>
        /// <param name="configuration">Instance of configuration.</param>
        /// <exception cref="Kount.Ris.RequestException">Thrown when there is
        /// static data missing for a RIS request.</exception>
        protected Request(bool checkConfiguration, Configuration configuration)
        {
            if (checkConfiguration)
            {
                this.CheckConfigurationParameter(configuration.MerchantId, nameof(configuration.MerchantId));
                this.CheckConfigurationParameter(configuration.URL, nameof(configuration.URL));
                this.CheckConfigurationParameter(configuration.ConfigKey, nameof(configuration.ConfigKey));
            }


            this.CheckConfigurationParameter(configuration.ConnectTimeout, nameof(configuration.ConnectTimeout));
            logTimeElapsed = (String.IsNullOrEmpty(configuration.LogSimpleElapsed)
               ? false
               : configuration.LogSimpleElapsed.Trim().ToLower().Equals("on"));

            this.data = new System.Collections.Hashtable();
            this.SetMerchantId(Int32.Parse(configuration.MerchantId));

            Khash.ConfigKey = Khash.GetBase85ConfigKey(configuration.ConfigKey);

            var risVersion = String.IsNullOrEmpty(configuration.Version)
                        ? RisVersion
                        : configuration.Version;

            this.SetVersion(risVersion);
            this.SetUrl(configuration.URL);
            this.connectTimeout = Int32.Parse(configuration.ConnectTimeout);

            if (!String.IsNullOrEmpty(configuration.ApiKey))
            {
                this.SetApiKey(configuration.ApiKey);
            }
            else
            {
                this.CheckConfigurationParameter(configuration.CertificateFile, nameof(configuration.CertificateFile));
                this.CheckConfigurationParameter(configuration.PrivateKeyPassword, nameof(configuration.PrivateKeyPassword));
                this.SetCertificate(
                    configuration.CertificateFile,
                    configuration.PrivateKeyPassword);
            }

            // KHASH payment encoding is set by default.
            this.SetKhashPaymentEncoding(true);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Construct a request object. Set the static setting from the
        /// web.config file.
        /// </summary>
        /// <param name="checkConfiguration">By default is true: will check config file if
        /// `Ris.Url`,
        /// `Ris.MerchantId`,
        /// `Ris.Config.Key` are set.</param>
        /// <param name="configuration">Instance of configuration.</param>
        /// <exception cref="Kount.Ris.RequestException">Thrown when there is
        /// static data missing for a RIS request.</exception>
        protected Request(bool checkConfiguration, Configuration configuration)
        {
            XmlDocument log4netConfig = new XmlDocument();


            log4netConfig.Load(System.IO.File.OpenRead("log4net.config"));
            var repo = log4net.LogManager.CreateRepository(
                Assembly.GetEntryAssembly(), typeof(log4net.Repository.Hierarchy.Hierarchy));

            log4net.Config.XmlConfigurator.Configure(repo, log4netConfig["log4net"]);


            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot cconfiguration = builder.Build();

            configuration.ConnectTimeout = "10000";

            //ILoggerFactory factory = LogFactory.GetLoggerFactory();
            //logger = factory.GetLogger(typeof(Request).ToString());



            if (checkConfiguration)
            {
                this.CheckConfigurationParameter(configuration.MerchantId, nameof(configuration.MerchantId));
                this.CheckConfigurationParameter(configuration.URL, nameof(configuration.URL));
                this.CheckConfigurationParameter(configuration.ConfigKey, nameof(configuration.ConfigKey));
            }

            // timeout must be always defined
            this.CheckConfigurationParameter(configuration.ConnectTimeout, nameof(configuration.ConnectTimeout));

            this.data = new System.Collections.Hashtable();
            this.SetMerchantId(Int32.Parse(configuration.MerchantId));

            Khash.ConfigKey = Khash.GetBase85ConfigKey(configuration.ConfigKey);

            var risVersion = String.IsNullOrEmpty(configuration.Version)
                        ? RisVersion
                        : configuration.Version;

            this.SetVersion(risVersion);
            this.SetUrl(configuration.URL);
            this.connectTimeout = Int32.Parse(configuration.ConnectTimeout);

            if (!String.IsNullOrEmpty(configuration.ApiKey))
            {
                this.SetApiKey(configuration.ApiKey);
            }
            else
            {
                this.CheckConfigurationParameter(configuration.CertificateFile, nameof(configuration.CertificateFile));
                this.CheckConfigurationParameter(configuration.PrivateKeyPassword, nameof(configuration.PrivateKeyPassword));
                this.SetCertificate(
                    configuration.CertificateFile,
                    configuration.PrivateKeyPassword);
            }

            // KHASH payment encoding is set by default.
            this.SetKhashPaymentEncoding(true);
        }