module MerbMerchant #:nodoc: module Billing #:nodoc: module Base # Set MerbMerchant gateways in test mode. # # MerbMerchant::Billing::Base.gateway_mode = :test def self.gateway_mode @@gateway_mode end def self.gateway_mode=(gateway_mode) @@gateway_mode = gateway_mode end # Set MerbMerchant gateways in test mode. # # MerbMerchant::Billing::Base.gateway_mode = :test def self.integration_mode @@integration_mode end def self.integration_mode=(integration_mode) @@integration_mode = integration_mode end # Set both the mode of both the gateways and integrations # at once def self.mode @@mode end 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 # * bogus: BogusGateway - Does nothing (for testing) # * moneris: MonerisGateway # * authorize_net: AuthorizeNetGateway # * trust_commerce: TrustCommerceGateway # # MerbMerchant::Billing::Base.gateway('moneris').new def self.gateway(name) Billing.const_get(MerbMerchant::Inflector.camelize("#{name.to_s.downcase}_gateway")) end # Return the matching integration module # You can then get the notification from the module # * bogus: Bogus - Does nothing (for testing) # * chronopay: Chronopay - Does nothing (for testing) # * paypal: Chronopay - Does nothing (for testing) # # chronopay = MerbMerchant::Billing::Base.integration('chronopay') # notification = chronopay.notification(raw_post) # def self.integration(name) Billing::Integrations.const_get(MerbMerchant::Inflector.camelize("#{name.to_s.downcase}")) end # A check to see if we're in test mode def self.test? self.gateway_mode == :test end end end end