Class: SolidusBolt::BoltConfiguration

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/solidus_bolt/bolt_configuration.rb

Constant Summary collapse

PRODUCTION_REGISTER_URL =
'https://merchant.bolt.com/register?platform=solidus'
SANDBOX_REGISTER_URL =
'https://merchant-sandbox.bolt.com/register?platform=solidus'
EVENTS =
%w[all payment credit capture void auth pending rejected_irreversible rejected_reversible no_op
failed_payment newsletter_subscription risk_insights credit_card_deleted].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.can_create?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/models/solidus_bolt/bolt_configuration.rb', line 30

def self.can_create?
  count.zero?
end

.config_empty?Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
40
# File 'app/models/solidus_bolt/bolt_configuration.rb', line 34

def self.config_empty?
  whitelist = %w[id created_at updated_at environment]

  fetch.attributes.all? do |attr, val|
    whitelist.include?(attr) || val.blank?
  end
end

.fetchObject



26
27
28
# File 'app/models/solidus_bolt/bolt_configuration.rb', line 26

def self.fetch
  first_or_create
end

Instance Method Details

#account_jsObject



57
58
59
60
61
62
63
# File 'app/models/solidus_bolt/bolt_configuration.rb', line 57

def 
  case BoltConfiguration.environments[environment]
  when 0 then 'https://connect.bolt.com/account.js'
  else
    'https://connect-sandbox.bolt.com/account.js'
  end
end

#division_public_idObject



22
23
24
# File 'app/models/solidus_bolt/bolt_configuration.rb', line 22

def division_public_id
  publishable_key&.split('.')&.second
end

#embed_jsObject



50
51
52
53
54
55
# File 'app/models/solidus_bolt/bolt_configuration.rb', line 50

def embed_js
  case BoltConfiguration.environments[environment]
  when 0 then 'https://connect.bolt.com/embed.js'
  else 'https://connect-sandbox.bolt.com/embed.js'
  end
end

#environment_urlObject



42
43
44
45
46
47
48
# File 'app/models/solidus_bolt/bolt_configuration.rb', line 42

def environment_url
  case BoltConfiguration.environments[environment]
  when 0 then 'https://api.bolt.com'
  when 1 then 'https://api-sandbox.bolt.com'
  when 2 then 'https://api-staging.bolt.com'
  end
end

#merchant_public_idObject



18
19
20
# File 'app/models/solidus_bolt/bolt_configuration.rb', line 18

def merchant_public_id
  publishable_key&.split('.')&.first
end