Class: Spree::PaymentMethod

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spree/payment_method.rb

Direct Known Subclasses

BillingIntegration, Gateway, Check

Defined Under Namespace

Classes: Check

Constant Summary collapse

DISPLAY =
[:both, :front_end, :back_end]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.active?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/models/spree/payment_method.rb', line 27

def self.active?
  self.count(:conditions => { :type => self.to_s, :environment => Rails.env, :active => true }) > 0
end

.available(display_on = 'both') ⇒ Object



23
24
25
# File 'app/models/spree/payment_method.rb', line 23

def self.available(display_on='both')
  all.select { |p| p.active && (p.display_on == display_on.to_s || p.display_on.blank?) && (p.environment == Rails.env || p.environment.blank?) }
end

.currentObject

TODO: Remove this method by 1.0



32
33
34
35
# File 'app/models/spree/payment_method.rb', line 32

def self.current
  ActiveSupport::Deprecation.warn "Gateway.current is deprecated and will be removed in Spree > 1.0. Use current_order.payment_method instead."
  first(:conditions => { :active => true, :environment => Rails.env })
end

.find_with_destroyed(*args) ⇒ Object



45
46
47
# File 'app/models/spree/payment_method.rb', line 45

def self.find_with_destroyed *args
  self.with_exclusive_scope { find(*args) }
end

.providersObject



8
9
10
# File 'app/models/spree/payment_method.rb', line 8

def self.providers
  Rails.application.config.spree.payment_methods
end

Instance Method Details

#destroyObject



41
42
43
# File 'app/models/spree/payment_method.rb', line 41

def destroy
  self.update_attribute(:deleted_at, Time.now.utc)
end

#method_typeObject



37
38
39
# File 'app/models/spree/payment_method.rb', line 37

def method_type
  type.demodulize.downcase
end

#payment_profiles_supported?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'app/models/spree/payment_method.rb', line 49

def payment_profiles_supported?
  false
end

#payment_source_classObject

The class that will process payments for this payment type, used for @payment.source e.g. Creditcard in the case of a the Gateway payment type nil means the payment method doesn’t require a source e.g. check



19
20
21
# File 'app/models/spree/payment_method.rb', line 19

def payment_source_class
  raise 'You must implement payment_source_class method for this gateway.'
end

#provider_classObject



12
13
14
# File 'app/models/spree/payment_method.rb', line 12

def provider_class
  raise 'You must implement provider_class method for this gateway.'
end

#source_required?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/models/spree/payment_method.rb', line 53

def source_required?
  true
end