コード例 #1
0
        public void Login(bool isTestMode, params MerchantConfigValue[] MerchantConfigValues)
        {
            MerchantId = MerchantConfigValues.Where(r => r.Key.Equals("MerchantId")).FirstOrDefault().Value;
            PublicKey  = MerchantConfigValues.Where(r => r.Key.Equals("PublicKey")).FirstOrDefault().Value;
            PrivateKey = MerchantConfigValues.Where(r => r.Key.Equals("PrivateKey")).FirstOrDefault().Value;

            if (isTestMode)
            {
                Environment = Braintree.Environment.SANDBOX;
            }
            else
            {
                Environment = Braintree.Environment.PRODUCTION;
            }
        }
コード例 #2
0
        public PaymentFormHandler(IReferenceDataService referenceDataService, IPolicies policyApi, IBicyclePolicies bicyclePolicyApi, IEmailService emailService) : base(referenceDataService, policyApi, bicyclePolicyApi)
        {
            _emailService = emailService;

            Environment environment = GetBraintreeMode(ConfigurationManager.AppSettings["Braintree.Environment"]);

            if (environment == null)
            {
                throw new ArgumentException("Cannot determine Braintree Environment from value: " + ConfigurationManager.AppSettings["Braintree.Environment"]);
            }

            _brainTreeGateway = new BraintreeGateway
            {
                Environment = environment,
                PublicKey   = _publicKey,
                PrivateKey  = _privateKey,
                MerchantId  = _merchantId
            };
        }
コード例 #3
0
        public Configuration(Environment environment, string merchantId, string publicKey, string privateKey) : this()
        {
            if (environment == null)
            {
                throw new ConfigurationException("Configuration.environment needs to be set");
            }
            else if (string.IsNullOrEmpty(merchantId))
            {
                throw new ConfigurationException("Configuration.merchantId needs to be set");
            }
            else if (string.IsNullOrEmpty(publicKey))
            {
                throw new ConfigurationException("Configuration.publicKey needs to be set");
            }
            else if (string.IsNullOrEmpty(privateKey))
            {
                throw new ConfigurationException("Configuration.privateKey needs to be set");
            }

            Environment = environment;
            MerchantId = merchantId;
            PublicKey = publicKey;
            PrivateKey = privateKey;
        }