Sha256: dddbe742656e3dc40c4252b94d3feed42c10082b9349df43cc4c2e5090d7b397

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'workarea'
require 'workarea/storefront'
require 'workarea/admin'
require 'workarea/usaepay/engine'
require 'workarea/usaepay/version'
require 'usaepay/gateway'

module Workarea
  module Usaepay
    # Credentials for PayFlowPro from Rails secrets.
    #
    # @return [Hash]
    def self.credentials
      return {} unless Rails.application.secrets.usaepay_transaction_gateway.present?
      Rails.application.secrets.usaepay_transaction_gateway.symbolize_keys
    end

    # Conditionally use the real gateway when secrets are present.
    # Otherwise, use the bogus gateway.
    #
    # @return [ActiveMerchant::Billing::Gateway]
    def self.gateway
      Workarea.config.gateways.credit_card
    end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-usaepay-1.0.26 lib/workarea/usaepay.rb