lib/braintree/configuration.rb in braintree-2.88.0 vs lib/braintree/configuration.rb in braintree-2.89.0
- old
+ new
@@ -121,10 +121,13 @@
@client_id = parser.client_id
@client_secret = parser.client_secret
@environment = parser.environment
elsif options[:access_token]
parser.parse_access_token(options[:access_token])
+
+ _check_for_mixed_environment(options[:environment], parser.environment)
+
@access_token = parser.access_token
@environment = parser.environment
@merchant_id = parser.merchant_id
else
@merchant_id = options[:merchant_id] || options[:partner_id]
@@ -140,9 +143,15 @@
raise ConfigurationError.new("Braintree::Gateway cannot be initialized with mixed credential types: client_id and client_secret mixed with access_token.")
end
if (options[:public_key] || options[:private_key]) && (options[:access_token])
raise ConfigurationError.new("Braintree::Gateway cannot be initialized with mixed credential types: public_key and private_key mixed with access_token.")
+ end
+ end
+
+ def _check_for_mixed_environment(options_environment, token_environment)
+ if options_environment && options_environment.to_sym != token_environment.to_sym
+ warn "Braintree::Gateway should not be initialized with mixed environments: environment parameter and access_token do not match, environment from access_token is used."
end
end
def api_version # :nodoc:
API_VERSION