Sha256: c26b93b7a54bcc868aac130550199657fcc4d93020bdb770afc034915ba6917c

Contents?: true

Size: 1006 Bytes

Versions: 19

Compression:

Stored size: 1006 Bytes

Contents

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

  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
    ActiveMerchant::Billing::Base.gateway_mode = gateway_options[:server].to_sym
    @provider ||= provider_class.new(gateway_options)
  end

	def options
    options_hash = {}
    self.preferences.each do |key,value|
      options_hash[key.to_sym] = value
    end
    options_hash
	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

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
apispree_core-0.0.0 app/models/gateway.rb
My-Commerce_core-1.1.0 app/models/gateway.rb
My-Commerce_core-1.0.0 app/models/gateway.rb
MyCommerceapi-1.0.0 core/app/models/gateway.rb
MyCommerce-0.0.3 core/app/models/gateway.rb
rfcommerce_core-0.0.3 app/models/gateway.rb
spree_core-0.60.6 app/models/gateway.rb
spree_core-0.60.5 app/models/gateway.rb
spree_core-0.50.4 app/models/gateway.rb
spree_core-0.60.4 app/models/gateway.rb
spree_core-0.50.3 app/models/gateway.rb
spree_core-0.60.3 app/models/gateway.rb
spree_core-0.60.2 app/models/gateway.rb
spree_core-0.60.1 app/models/gateway.rb
spree_core-0.60.0 app/models/gateway.rb
spree_core-0.60.0.RC1 app/models/gateway.rb
spree_core-0.50.2 app/models/gateway.rb
spree_core-0.50.1 app/models/gateway.rb
spree_core-0.50.0 app/models/gateway.rb