class Braintree::Configuration
Constants
- NON_REQUIRED_READABLE_ATTRIBUTES
- READABLE_ATTRIBUTES
- WRITABLE_ATTRIBUTES
Public Class Methods
environment=(env)
click to toggle source
Sets the Braintree
environment to use. Valid values are :sandbox
and :production
# File lib/braintree/configuration.rb, line 62 def self.environment=(env) env = env.to_sym unless [:development, :qa, :sandbox, :production].include?(env) raise ArgumentError, "#{env.inspect} is not a valid environment" end @environment = env end
http_open_timeout()
click to toggle source
# File lib/braintree/configuration.rb, line 93 def self.http_open_timeout @http_open_timeout ||= 60 end
http_read_timeout()
click to toggle source
# File lib/braintree/configuration.rb, line 97 def self.http_read_timeout @http_read_timeout ||= 60 end
logger()
click to toggle source
# File lib/braintree/configuration.rb, line 101 def self.logger @logger ||= _default_logger end
new(options = {})
click to toggle source
# File lib/braintree/configuration.rb, line 113 def initialize(options = {}) WRITABLE_ATTRIBUTES.each do |attr| instance_variable_set "@#{attr}", options[attr] end @environment = @environment.to_sym if @environment _check_for_mixed_credentials(options) parser = Braintree::CredentialsParser.new if options[:client_id] || options[:client_secret] parser.parse_client_credentials(options[:client_id], options[:client_secret]) @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] end end
sha256_signature_service()
click to toggle source
# File lib/braintree/configuration.rb, line 109 def self.sha256_signature_service instantiate.sha256_signature_service end
signature_service()
click to toggle source
# File lib/braintree/configuration.rb, line 105 def self.signature_service instantiate.signature_service end
Public Instance Methods
_check_for_mixed_credentials(options)
click to toggle source
# File lib/braintree/configuration.rb, line 141 def _check_for_mixed_credentials(options) if (options[:client_id] || options[:client_secret]) && (options[:public_key] || options[:private_key]) raise ConfigurationError.new("Braintree::Gateway cannot be initialized with mixed credential types: client_id and client_secret mixed with public_key and private_key.") end if (options[:client_id] || options[:client_secret]) && (options[:access_token]) 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
_check_for_mixed_environment(options_environment, token_environment)
click to toggle source
# File lib/braintree/configuration.rb, line 155 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
assert_has_access_token_or_keys()
click to toggle source
# File lib/braintree/configuration.rb, line 308 def assert_has_access_token_or_keys if (public_key.nil? || private_key.nil?) && access_token.nil? raise ConfigurationError.new("Braintree::Gateway access_token or public_key and private_key are required.") end end
assert_has_client_credentials()
click to toggle source
# File lib/braintree/configuration.rb, line 302 def assert_has_client_credentials if client_id.nil? || client_secret.nil? raise ConfigurationError.new("Braintree::Gateway client_id and client_secret are required.") end end
auth_url()
click to toggle source
# File lib/braintree/configuration.rb, line 261 def auth_url case @environment when :development, :integration "http://auth.venmo.dev:9292" when :production "https://auth.venmo.com" when :qa "https://auth.venmo.qa2.braintreegateway.com" when :sandbox "https://auth.venmo.sandbox.braintreegateway.com" end end
base_url()
click to toggle source
# File lib/braintree/configuration.rb, line 173 def base_url "#{protocol}://#{server}:#{port}" end
client_credentials?()
click to toggle source
# File lib/braintree/configuration.rb, line 298 def client_credentials? !client_id.nil? end
endpoint()
click to toggle source
# File lib/braintree/configuration.rb, line 189 def endpoint @endpoint || DEFAULT_ENDPOINT end
graphql_base_url()
click to toggle source
# File lib/braintree/configuration.rb, line 177 def graphql_base_url "#{protocol}://#{graphql_server}:#{graphql_port}/graphql" end
graphql_client()
click to toggle source
# File lib/braintree/configuration.rb, line 197 def graphql_client GraphQLClient.new(self) end
http_open_timeout()
click to toggle source
# File lib/braintree/configuration.rb, line 227 def http_open_timeout @http_open_timeout end
http_read_timeout()
click to toggle source
# File lib/braintree/configuration.rb, line 231 def http_read_timeout @http_read_timeout end
inspect()
click to toggle source
Calls superclass method
# File lib/braintree/configuration.rb, line 294 def inspect super.gsub(/@private_key=\".*\"/, '@private_key="[FILTERED]"') end
logger()
click to toggle source
# File lib/braintree/configuration.rb, line 201 def logger @logger ||= self.class._default_logger end
sha256_signature_service()
click to toggle source
# File lib/braintree/configuration.rb, line 318 def sha256_signature_service @sha256_signature_service ||= SignatureService.new(@private_key, SHA256Digest) end
signature_service()
click to toggle source
# File lib/braintree/configuration.rb, line 314 def signature_service @signature_service ||= SignatureService.new(@private_key) end