Sha256: a43f7e5aa0134993d5a7d0241c7398124f148458faaf351114279ce8a8e71ba5

Contents?: true

Size: 1.71 KB

Versions: 20

Compression:

Stored size: 1.71 KB

Contents

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Base
      # Set ActiveMerchant gateways in test mode.
      #
      #   ActiveMerchant::Billing::Base.gateway_mode = :test
      mattr_accessor :gateway_mode

      # Set ActiveMerchant integrations in test mode.
      #
      #   ActiveMerchant::Billing::Base.integration_mode = :test
      mattr_accessor :integration_mode

      # Set both the mode of both the gateways and integrations
      # at once
      mattr_reader :mode

      def self.mode=(mode)
        @@mode = mode
        self.gateway_mode = mode
        self.integration_mode = mode
      end

      self.mode = :production

      # Return the matching gateway for the provider
      # * <tt>bogus</tt>: BogusGateway - Does nothing (for testing)
      # * <tt>moneris</tt>: MonerisGateway
      # * <tt>authorize_net</tt>: AuthorizeNetGateway
      # * <tt>trust_commerce</tt>: TrustCommerceGateway
      #
      #   ActiveMerchant::Billing::Base.gateway('moneris').new
      def self.gateway(name)
        Billing.const_get("#{name.to_s.downcase}_gateway".camelize)
      end

      # Return the matching integration module
      # You can then get the notification from the module
      # * <tt>bogus</tt>: Bogus - Does nothing (for testing)
      # * <tt>chronopay</tt>: Chronopay
      # * <tt>paypal</tt>: Paypal
      #
      #   chronopay = ActiveMerchant::Billing::Base.integration('chronopay')
      #   notification = chronopay.notification(raw_post)
      #
      def self.integration(name)
        Billing::Integrations.const_get("#{name.to_s.downcase}".camelize)
      end

      # A check to see if we're in test mode
      def self.test?
        self.gateway_mode == :test
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
activemerchant-1.36.0 lib/active_merchant/billing/base.rb
activemerchant-1.35.0 lib/active_merchant/billing/base.rb
activemerchant-1.35.1 lib/active_merchant/billing/base.rb
activemerchant-1.34.1 lib/active_merchant/billing/base.rb
activemerchant-1.34.0 lib/active_merchant/billing/base.rb
activemerchant-1.33.0 lib/active_merchant/billing/base.rb
activemerchant-1.32.1 lib/active_merchant/billing/base.rb
activemerchant-1.32.0 lib/active_merchant/billing/base.rb
activemerchant-1.31.1 lib/active_merchant/billing/base.rb
activemerchant-1.31.0 lib/active_merchant/billing/base.rb
activemerchant-1.30.0 lib/active_merchant/billing/base.rb
jelaniharris-activemerchant-1.29.2 lib/active_merchant/billing/base.rb
activemerchant-1.29.3 lib/active_merchant/billing/base.rb
activemerchant-1.29.2 lib/active_merchant/billing/base.rb
activemerchant-1.29.1 lib/active_merchant/billing/base.rb
jelaniharris-activemerchant-1.29.1 lib/active_merchant/billing/base.rb
activemerchant-1.29.0 lib/active_merchant/billing/base.rb
activemerchant-nsp-1.27.0 lib/active_merchant/billing/base.rb
activemerchant-1.28.0 lib/active_merchant/billing/base.rb
activemerchant-1.27.0 lib/active_merchant/billing/base.rb