module Workarea::AuthorizeCim

Constants

VERSION

Public Class Methods

auto_initialize_gateway() click to toggle source
# File lib/workarea/authorize_cim.rb, line 33
def self.auto_initialize_gateway
  if credentials.present?
    if ENV['HTTP_PROXY'].present?
      uri = URI.parse(ENV['HTTP_PROXY'])
      ActiveMerchant::Billing::AuthorizeNetCimGateway.proxy_address = uri.host
      ActiveMerchant::Billing::AuthorizeNetCimGateway.proxy_port = uri.port
    end

    self.gateway = ActiveMerchant::Billing::AuthorizeNetCimGateway.new credentials
  else
    self.gateway = ActiveMerchant::Billing::BogusAuthorizeNetCimGateway.new
  end
end
credentials() click to toggle source

Credentials for Authorize.Net from Rails secrets.

@return [Hash]

# File lib/workarea/authorize_cim.rb, line 16
def self.credentials
  return {} unless Rails.application.secrets.authorize.present?
  Rails.application.secrets.authorize.symbolize_keys
end
gateway() click to toggle source

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

@return [ActiveMerchant::Billing::Gateway]

# File lib/workarea/authorize_cim.rb, line 25
def self.gateway
  Workarea.config.gateways.credit_card
end
gateway=(gateway) click to toggle source
# File lib/workarea/authorize_cim.rb, line 29
def self.gateway=(gateway)
  Workarea.config.gateways.credit_card = gateway
end