Class: Spree::PaymentMethod
Defined Under Namespace
Classes: Check, StoreCredit
Constant Summary
collapse
- DISPLAY =
[:both, :front_end, :back_end]
Class Method Summary
collapse
Instance Method Summary
collapse
#preference_source=, #preferences, #preferences=
Methods inherited from Base
page
#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Class Method Details
.active? ⇒ Boolean
39
40
41
|
# File 'app/models/spree/payment_method.rb', line 39
def self.active?
where(type: self.to_s, active: true).count > 0
end
|
.available(display_on = 'both', store: nil) ⇒ Object
31
32
33
34
35
36
37
|
# File 'app/models/spree/payment_method.rb', line 31
def self.available(display_on = 'both', store: nil)
all.select do |p|
p.active &&
(p.display_on == display_on.to_s || p.display_on.blank?) &&
(store.nil? || store.payment_methods.empty? || store.payment_methods.include?(p))
end
end
|
.find_with_destroyed(*args) ⇒ Object
47
48
49
|
# File 'app/models/spree/payment_method.rb', line 47
def self.find_with_destroyed *args
unscoped { find(*args) }
end
|
.providers ⇒ Object
16
17
18
|
# File 'app/models/spree/payment_method.rb', line 16
def self.providers
Rails.application.config.spree.payment_methods
end
|
Instance Method Details
#auto_capture? ⇒ Boolean
65
66
67
|
# File 'app/models/spree/payment_method.rb', line 65
def auto_capture?
self.auto_capture.nil? ? Spree::Config[:auto_capture] : self.auto_capture
end
|
#cancel(response) ⇒ Object
73
74
75
|
# File 'app/models/spree/payment_method.rb', line 73
def cancel(response)
raise ::NotImplementedError, 'You must implement cancel method for this payment method.'
end
|
#method_type ⇒ Object
43
44
45
|
# File 'app/models/spree/payment_method.rb', line 43
def method_type
type.demodulize.downcase
end
|
#payment_profiles_supported? ⇒ Boolean
51
52
53
|
# File 'app/models/spree/payment_method.rb', line 51
def payment_profiles_supported?
false
end
|
#payment_source_class ⇒ Object
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
27
28
29
|
# File 'app/models/spree/payment_method.rb', line 27
def payment_source_class
raise ::NotImplementedError, "You must implement payment_source_class method for #{self.class}."
end
|
#provider_class ⇒ Object
20
21
22
|
# File 'app/models/spree/payment_method.rb', line 20
def provider_class
raise ::NotImplementedError, "You must implement provider_class method for #{self.class}."
end
|
#reusable_sources(order) ⇒ Object
Custom gateways should redefine this method. See Gateway implementation as an example
61
62
63
|
# File 'app/models/spree/payment_method.rb', line 61
def reusable_sources(order)
[]
end
|
#source_required? ⇒ Boolean
55
56
57
|
# File 'app/models/spree/payment_method.rb', line 55
def source_required?
true
end
|
#supports?(source) ⇒ Boolean
69
70
71
|
# File 'app/models/spree/payment_method.rb', line 69
def supports?(source)
true
end
|