Sha256: b834fb5a7717982aa993db51dea791fbbe78bb6ade4bdbf896747ad1cea62914

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

module Spree
  class Gateway < PaymentMethod
    delegate_belongs_to :provider, :authorize, :purchase, :capture, :void, :credit

    validates :name, :type, :presence => true

    preference :server, :string, :default => 'test'
    preference :test_mode, :boolean, :default => true

    attr_accessible :preferred_server, :preferred_test_mode

    def payment_source_class
      CreditCard
    end

    # instantiates the selected gateway and configures with the options stored in the database
    def self.current
      super
    end

    def provider
      gateway_options = options
      gateway_options.delete :login if gateway_options.has_key?(:login) and gateway_options[:login].nil?
      ActiveMerchant::Billing::Base.gateway_mode = gateway_options[:server].to_sym
      @provider ||= provider_class.new(gateway_options)
    end

    def options
      self.preferences.inject({}){ |memo, (key, value)| memo[key.to_sym] = value; memo }
    end

    def method_missing(method, *args)
      if @provider.nil? || !@provider.respond_to?(method)
        super
      else
        provider.send(method)
      end
    end

    def payment_profiles_supported?
      false
    end

    def method_type
      'gateway'
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
spree_core-1.3.2 app/models/spree/gateway.rb
spree_core-1.3.1 app/models/spree/gateway.rb
spree_core-1.3.0 app/models/spree/gateway.rb
spree_core-1.3.0.rc2 app/models/spree/gateway.rb
dup_spree_core-1.3.0.rc1 app/models/spree/gateway.rb
spree_core-1.3.0.rc1 app/models/spree/gateway.rb