Sha256: 3eafc918ce9588065c41a7e98f32656f19e7ff2ba5eb957cbf1e5f565651e015

Contents?: true

Size: 1.87 KB

Versions: 29

Compression:

Stored size: 1.87 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 gateways in test mode.
      #
      #   ActiveMerchant::Billing::Base.gateway_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 - Does nothing (for testing)
      # * <tt>paypal</tt>: Chronopay - Does nothing (for testing)
      #   
      #   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

29 entries across 29 versions & 10 rubygems

Version Path
johnideal-activemerchant-1.4.10 lib/active_merchant/billing/base.rb
johnideal-activemerchant-1.4.11 lib/active_merchant/billing/base.rb
johnideal-activemerchant-1.4.4 lib/active_merchant/billing/base.rb
johnideal-activemerchant-1.4.5 lib/active_merchant/billing/base.rb
johnideal-activemerchant-1.4.6 lib/active_merchant/billing/base.rb
johnideal-activemerchant-1.4.7 lib/active_merchant/billing/base.rb
johnideal-activemerchant-1.4.8 lib/active_merchant/billing/base.rb
martinstannard-activemerchant-0.1.0 lib/active_merchant/billing/base.rb
mattbauer-activemerchant-1.4.2 lib/active_merchant/billing/base.rb
seamusabshere-active_merchant-1.4.2.1 lib/active_merchant/billing/base.rb
seamusabshere-active_merchant-1.4.2.3 lib/active_merchant/billing/base.rb
tomriley-active_merchant-1.4.2.3 lib/active_merchant/billing/base.rb
tomriley-active_merchant-1.4.2.4 lib/active_merchant/billing/base.rb
tomriley-active_merchant-1.4.2.5 lib/active_merchant/billing/base.rb
tomriley-active_merchant-1.4.2.6 lib/active_merchant/billing/base.rb
tomriley-active_merchant-1.4.2.7 lib/active_merchant/billing/base.rb
tomriley-active_merchant-1.4.2.8 lib/active_merchant/billing/base.rb
tomriley-tomriley-active_merchant-1.4.2.4 lib/active_merchant/billing/base.rb
tomriley-active_merchant-1.4.2.11 lib/active_merchant/billing/base.rb
tomriley-active_merchant-1.4.2.10 lib/active_merchant/billing/base.rb