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)


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

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

.available(display_on = 'both') ⇒ Object



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

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



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

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

.providersObject



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

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

Instance Method Details

#auto_capture?Boolean

Returns:

  • (Boolean)


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

def auto_capture?
  self.auto_capture.nil? ? Spree::Config[:auto_capture] : self.auto_capture
end

#method_typeObject



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

def method_type
  type.demodulize.downcase
end

#payment_profiles_supported?Boolean

Returns:

  • (Boolean)


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

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



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

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

#provider_classObject



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

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

#source_required?Boolean

Returns:

  • (Boolean)


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

def source_required?
  true
end

#supports?(source) ⇒ Boolean

Returns:

  • (Boolean)


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

def supports?(source)
  true
end