Sha256: 673da26330868864567c1808d1e546e8a68f6ae9c3ac1225c8e7fb2ba8b76b51

Contents?: true

Size: 1.77 KB

Versions: 18

Compression:

Stored size: 1.77 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)
        raise NameError if (name_str = name.to_s.downcase).blank?
        Billing.const_get("#{name_str}_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

18 entries across 18 versions & 2 rubygems

Version Path
tanga_activemerchant-1.38.0.5 lib/active_merchant/billing/base.rb
tanga_activemerchant-1.38.0.4 lib/active_merchant/billing/base.rb
tanga_activemerchant-1.38.0.3 lib/active_merchant/billing/base.rb
tanga_activemerchant-1.38.0.2 lib/active_merchant/billing/base.rb
tanga_activemerchant-1.38.0.1 lib/active_merchant/billing/base.rb
tanga_activemerchant-1.38.0 lib/active_merchant/billing/base.rb
tanga_activemerchant-1.37.0 lib/active_merchant/billing/base.rb
activemerchant-1.42.2 lib/active_merchant/billing/base.rb
activemerchant-1.42.1 lib/active_merchant/billing/base.rb
activemerchant-1.42.0 lib/active_merchant/billing/base.rb
activemerchant-1.41.0 lib/active_merchant/billing/base.rb
activemerchant-1.40.0 lib/active_merchant/billing/base.rb
activemerchant-1.39.2 lib/active_merchant/billing/base.rb
activemerchant-1.39.1 lib/active_merchant/billing/base.rb
activemerchant-1.39.0 lib/active_merchant/billing/base.rb
activemerchant-1.38.1 lib/active_merchant/billing/base.rb
activemerchant-1.38.0 lib/active_merchant/billing/base.rb
activemerchant-1.37.0 lib/active_merchant/billing/base.rb