Module: Workarea::Affirm

Defined in:
lib/workarea/affirm.rb,
lib/workarea/affirm/engine.rb,
lib/workarea/affirm/gateway.rb,
lib/workarea/affirm/version.rb,
lib/workarea/affirm/response.rb,
lib/workarea/affirm/bogus_gateway.rb,
app/services/workarea/affirm/order.rb,
app/services/workarea/affirm/update.rb

Defined Under Namespace

Classes: BogusGateway, Engine, Gateway, Order, Response, Update

Constant Summary collapse

VERSION =
"1.0.0".freeze

Class Method Summary collapse

Class Method Details

.api_configured?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/workarea/affirm.rb', line 19

def self.api_configured?
  public_key.present? && private_key.present?
end

.enabled?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/workarea/affirm.rb', line 23

def self.enabled?
  Workarea.config.affirm_enabled && api_configured?
end

.gateway(_options = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/workarea/affirm.rb', line 39

def self.gateway(_options = {})
  if Rails.env.test?
    Affirm::BogusGateway.new
  else
    Affirm::Gateway.new(
      test: test?,
      public_key: public_key,
      private_key: private_key
    )
  end
end

.js_sdk_urlObject



27
28
29
30
31
32
33
# File 'lib/workarea/affirm.rb', line 27

def self.js_sdk_url
  if test?
    "https://cdn1-sandbox.affirm.com/js/v2/affirm.js"
  else
    "https://cdn1.affirm.com/js/v2/affirm.js"
  end
end

.private_keyObject



15
16
17
# File 'lib/workarea/affirm.rb', line 15

def self.private_key
  Workarea.config.affirm_private_key
end

.public_keyObject



11
12
13
# File 'lib/workarea/affirm.rb', line 11

def self.public_key
  Workarea.config.affirm_public_key
end

.test?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/workarea/affirm.rb', line 35

def self.test?
  !Workarea.config.affirm_use_production_environment
end