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)


35
36
37
# File 'app/models/spree/payment_method.rb', line 35

def self.active?
  where(type: self.to_s, environment: Rails.env, active: true).count > 0
end

.available(display_on = 'both') ⇒ Object



27
28
29
30
31
32
33
# File 'app/models/spree/payment_method.rb', line 27

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

.find_with_destroyed(*args) ⇒ Object



43
44
45
# File 'app/models/spree/payment_method.rb', line 43

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

.providersObject



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

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

Instance Method Details

#auto_capture?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'app/models/spree/payment_method.rb', line 55

def auto_capture?
  Spree::Config[:auto_capture]
end

#method_typeObject



39
40
41
# File 'app/models/spree/payment_method.rb', line 39

def method_type
  type.demodulize.downcase
end

#payment_profiles_supported?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/models/spree/payment_method.rb', line 47

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



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

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

#provider_classObject



16
17
18
# File 'app/models/spree/payment_method.rb', line 16

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

#source_required?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'app/models/spree/payment_method.rb', line 51

def source_required?
  true
end

#supports?(source) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'app/models/spree/payment_method.rb', line 59

def supports?(source)
  true
end