Sha256: 20d62827acfdaac8ba2c4784ce3a1ab79fb6b98203b5c9fd101d34ff2369cc81

Contents?: true

Size: 1.92 KB

Versions: 29

Compression:

Stored size: 1.92 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

      # 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?
        mode == :test
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
activemerchant-1.108.0 lib/active_merchant/billing/base.rb
activemerchant-1.107.4 lib/active_merchant/billing/base.rb
activemerchant-1.107.3 lib/active_merchant/billing/base.rb
activemerchant-1.107.2 lib/active_merchant/billing/base.rb
activemerchant-1.107.1 lib/active_merchant/billing/base.rb
activemerchant-1.106.0 lib/active_merchant/billing/base.rb
activemerchant-1.105.0 lib/active_merchant/billing/base.rb
activemerchant-1.104.0 lib/active_merchant/billing/base.rb
activemerchant-1.103.0 lib/active_merchant/billing/base.rb
activemerchant-1.102.0 lib/active_merchant/billing/base.rb
activemerchant-1.101.0 lib/active_merchant/billing/base.rb
activemerchant-1.100.0 lib/active_merchant/billing/base.rb
activemerchant-1.99.0 lib/active_merchant/billing/base.rb
activemerchant-1.98.0 lib/active_merchant/billing/base.rb
active_accountability_merchant-1.97.1 lib/active_merchant/billing/base.rb
activemerchant-1.97.0 lib/active_merchant/billing/base.rb
activemerchant-1.96.0 lib/active_merchant/billing/base.rb
activemerchant-1.95.0 lib/active_merchant/billing/base.rb
activemerchant-1.94.0 lib/active_merchant/billing/base.rb
activemerchant-1.93.0 lib/active_merchant/billing/base.rb