Class: SolidusPaypalCommercePlatform::Configuration
- Inherits:
-
Object
- Object
- SolidusPaypalCommercePlatform::Configuration
- Defined in:
- lib/solidus_paypal_commerce_platform/configuration.rb
Constant Summary collapse
- InvalidEnvironment =
Class.new(StandardError)
- DEFAULT_PARTNER_ID =
{ sandbox: "5LQZV7RJDGKG2", live: "NBKVLAA7K2V5S", }.freeze
- DEFAULT_PARTNER_CLIENT_ID =
{ sandbox: "ATDpQjHzjCz_C_qbbJ76Ca0IjcmwlS4FztD6YfuRFZXDCmcWWw8-8QWcF3YIkbC85ixTUuuSEvrBMVSX", live: "ASOxaUMkeX5bv7PbXnWUDnqb3SVYkzRSosApmLGFih-eAhB_OS_Wo6juijE5t8NCmWDgpN2ugHMmQFWA", }.freeze
Instance Attribute Summary collapse
Instance Method Summary collapse
- #default_env ⇒ Object
- #env ⇒ Object
- #env=(value) ⇒ Object
- #env_class ⇒ Object
- #env_domain ⇒ Object
- #partner_code ⇒ Object
Instance Attribute Details
#partner_client_id ⇒ Object
66 67 68 |
# File 'lib/solidus_paypal_commerce_platform/configuration.rb', line 66 def partner_client_id @partner_client_id ||= ENV.fetch('PAYPAL_PARTNER_CLIENT_ID') { DEFAULT_PARTNER_CLIENT_ID[env.to_sym] } end |
#partner_id ⇒ Object
62 63 64 |
# File 'lib/solidus_paypal_commerce_platform/configuration.rb', line 62 def partner_id @partner_id ||= ENV.fetch('PAYPAL_PARTNER_ID') { DEFAULT_PARTNER_ID[env.to_sym] } end |
#state_guesser_class ⇒ Object
21 22 23 24 25 |
# File 'lib/solidus_paypal_commerce_platform/configuration.rb', line 21 def state_guesser_class self.state_guesser_class = "SolidusPaypalCommercePlatform::StateGuesser" unless @state_guesser_class @state_guesser_class.constantize end |
Instance Method Details
#default_env ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/solidus_paypal_commerce_platform/configuration.rb', line 41 def default_env return ENV['PAYPAL_ENV'] if ENV['PAYPAL_ENV'] case Rails.env when 'production' 'live' when 'test', 'development' 'sandbox' else raise InvalidEnvironment, "Unable to guess the PayPal env, please set #{self}.env= explicitly." end end |
#env ⇒ Object
35 36 37 38 39 |
# File 'lib/solidus_paypal_commerce_platform/configuration.rb', line 35 def env self.env = default_env unless @env @env end |
#env=(value) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/solidus_paypal_commerce_platform/configuration.rb', line 27 def env=(value) unless %w[live sandbox].include? value raise InvalidEnvironment, "#{value} is not a valid environment" end @env = ActiveSupport::StringInquirer.new(value) end |
#env_class ⇒ Object
54 55 56 |
# File 'lib/solidus_paypal_commerce_platform/configuration.rb', line 54 def env_class env.live? ? PayPal::LiveEnvironment : PayPal::SandboxEnvironment end |
#env_domain ⇒ Object
58 59 60 |
# File 'lib/solidus_paypal_commerce_platform/configuration.rb', line 58 def env_domain env.live? ? "www.paypal.com" : "www.sandbox.paypal.com" end |
#partner_code ⇒ Object
70 71 72 |
# File 'lib/solidus_paypal_commerce_platform/configuration.rb', line 70 def partner_code "Solidus_PCP_SP" end |