module Workarea::WorldpayXml

Constants

VERSION

Public Class Methods

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

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

Credentials for WorldpayGateway from Rails secrets.

@return [Hash]

# File lib/workarea/worldpay_xml.rb, line 17
def self.credentials
  return {} unless Rails.application.secrets.worldpay.present?
  Rails.application.secrets.worldpay.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/worldpay_xml.rb, line 26
def self.gateway
  Workarea.config.gateways.credit_card
end
gateway=(gateway) click to toggle source
# File lib/workarea/worldpay_xml.rb, line 30
def self.gateway=(gateway)
  Workarea.config.gateways.credit_card = gateway
end