Module: Workarea::Usaepay

Defined in:
lib/workarea/usaepay.rb,
lib/workarea/usaepay/engine.rb,
lib/workarea/usaepay/version.rb

Defined Under Namespace

Classes: Engine

Constant Summary collapse

VERSION =
"1.2.0".freeze

Class Method Summary collapse

Class Method Details

.auto_initialize_gatewayObject



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/workarea/usaepay.rb', line 31

def self.auto_initialize_gateway
  if credentials.present?
    if Rails.env.test?
      self.gateway = ActiveMerchant::Billing::BogusUsaEpayGateway.new credentials
    else
      self.gateway = ActiveMerchant::Billing::UsaEpayCustom.new credentials
    end
  else
    self.gateway = ActiveMerchant::Billing::BogusUsaEpayGateway.new
  end
end

.credentialsHash

Credentials for PayFlowPro from Rails secrets.

Returns:

  • (Hash)


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

def self.credentials
  return {} unless Rails.application.secrets.usaepay_transaction_gateway.present?
  Rails.application.secrets.usaepay_transaction_gateway.symbolize_keys
end

.gatewayActiveMerchant::Billing::Gateway

Conditionally use the real gateway when secrets are present. Otherwise, use the bogus gateway.

Returns:

  • (ActiveMerchant::Billing::Gateway)


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

def self.gateway
  Workarea.config.gateways.credit_card
end

.gateway=(gateway) ⇒ Object



27
28
29
# File 'lib/workarea/usaepay.rb', line 27

def self.gateway=(gateway)
  Workarea.config.gateways.credit_card = gateway
end