Sha256: a508a3de6cb38a54b0d9bc422586e26f8c2f30b7560597d92e1ca4f86a5faf00

Contents?: true

Size: 1.42 KB

Versions: 26

Compression:

Stored size: 1.42 KB

Contents

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Base
      GATEWAY_MODE_DEPRECATION_MESSAGE = 'Base#gateway_mode is deprecated in favor of Base#mode and will be removed in a future version'

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

      def self.gateway_mode=(mode)
        ActiveMerchant.deprecated(GATEWAY_MODE_DEPRECATION_MESSAGE)
        @@mode = mode
      end

      def self.gateway_mode
        ActiveMerchant.deprecated(GATEWAY_MODE_DEPRECATION_MESSAGE)
        @@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)
        name_str = name.to_s.strip.downcase

        raise(ArgumentError, 'A gateway provider must be specified') if name_str.blank?

        begin
          Billing.const_get("#{name_str}_gateway".camelize)
        rescue
          raise ArgumentError, "The specified gateway is not valid (#{name_str})"
        end
      end

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

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
swiss-activemerchant-1.0.5 lib/active_merchant/billing/base.rb
swiss-activemerchant-1.0.4 lib/active_merchant/billing/base.rb
activemerchant-1.137.0 lib/active_merchant/billing/base.rb
swiss-activemerchant-1.0.2 lib/active_merchant/billing/base.rb
swiss-activemerchant-1.0.1 lib/active_merchant/billing/base.rb
activemerchant-1.133.0 lib/active_merchant/billing/base.rb
activemerchant-1.131.0 lib/active_merchant/billing/base.rb
activemerchant-1.130.0 lib/active_merchant/billing/base.rb
activemerchant-1.129.0 lib/active_merchant/billing/base.rb
activemerchant-1.126.0 lib/active_merchant/billing/base.rb
activemerchant-1.125.0 lib/active_merchant/billing/base.rb
archetype2142_activemerchant-1.124.0 lib/active_merchant/billing/base.rb
activemerchant-1.124.0 lib/active_merchant/billing/base.rb
activemerchant-1.123.0 lib/active_merchant/billing/base.rb
activemerchant-1.121.0 lib/active_merchant/billing/base.rb
activemerchant-1.120.0 lib/active_merchant/billing/base.rb
activemerchant-1.119.0 lib/active_merchant/billing/base.rb
activemerchant-1.118.0 lib/active_merchant/billing/base.rb
activemerchant-1.117.0 lib/active_merchant/billing/base.rb
activemerchant-1.116.0 lib/active_merchant/billing/base.rb