Sha256: e6f209839dc5b123e49f878c9de9dda65fe1198b156ce495a466c0c9a77f7a14

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

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

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?
        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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
workarea-usaepay-1.2.0 lib/workarea/usaepay.rb
workarea-usaepay-1.1.1 lib/workarea/usaepay.rb
workarea-usaepay-1.1.0 lib/workarea/usaepay.rb
workarea-usaepay-1.0.44 lib/workarea/usaepay.rb
workarea-usaepay-1.0.43 lib/workarea/usaepay.rb
workarea-usaepay-1.0.42 lib/workarea/usaepay.rb
workarea-usaepay-1.0.41 lib/workarea/usaepay.rb