Class: Spree::PaymentMethod
Defined Under Namespace
Classes: Check, StoreCredit
Constant Summary
Constants included
from DisplayOn
DisplayOn::DISPLAY
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.find_with_destroyed(*args) ⇒ Object
60
61
62
|
# File 'app/models/spree/payment_method.rb', line 60
def self.find_with_destroyed(*args)
unscoped { find(*args) }
end
|
.providers ⇒ Object
31
32
33
|
# File 'app/models/spree/payment_method.rb', line 31
def self.providers
Spree.payment_methods
end
|
Instance Method Details
#auto_capture? ⇒ Boolean
86
87
88
|
# File 'app/models/spree/payment_method.rb', line 86
def auto_capture?
auto_capture.nil? ? Spree::Config[:auto_capture] : auto_capture
end
|
#available_for_order?(order) ⇒ Boolean
Custom PaymentMethod/Gateway can redefine this method to check method availability for concrete order.
104
105
106
|
# File 'app/models/spree/payment_method.rb', line 104
def available_for_order?(order)
!order.covered_by_store_credit?
end
|
#available_for_store?(store) ⇒ Boolean
108
109
110
111
112
|
# File 'app/models/spree/payment_method.rb', line 108
def available_for_store?(store)
return true if store.blank?
store_ids.include?(store.id)
end
|
#cancel(_response) ⇒ Object
94
95
96
|
# File 'app/models/spree/payment_method.rb', line 94
def cancel(_response)
raise ::NotImplementedError, 'You must implement cancel method for this payment method.'
end
|
#confirmation_required? ⇒ Boolean
64
65
66
|
# File 'app/models/spree/payment_method.rb', line 64
def confirmation_required?
false
end
|
#default_name ⇒ Object
52
53
54
|
# File 'app/models/spree/payment_method.rb', line 52
def default_name
self.class.name.demodulize.titleize.gsub(/Gateway/, '').strip
end
|
#method_type ⇒ Object
48
49
50
|
# File 'app/models/spree/payment_method.rb', line 48
def method_type
type.demodulize.downcase
end
|
#payment_icon_name ⇒ Object
56
57
58
|
# File 'app/models/spree/payment_method.rb', line 56
def payment_icon_name
type.demodulize.gsub(/(^Spree::Gateway::|Gateway$)/, '').downcase.gsub(/\s+/, '').strip
end
|
#payment_profiles_supported? ⇒ Boolean
68
69
70
|
# File 'app/models/spree/payment_method.rb', line 68
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
42
43
44
45
46
|
# File 'app/models/spree/payment_method.rb', line 42
def payment_source_class
return unless source_required?
raise ::NotImplementedError, 'You must implement payment_source_class method for this gateway.'
end
|
#provider_class ⇒ Object
35
36
37
|
# File 'app/models/spree/payment_method.rb', line 35
def provider_class
raise ::NotImplementedError, 'You must implement provider_class method for this gateway.'
end
|
#public_preferences ⇒ Object
114
115
116
117
118
|
# File 'app/models/spree/payment_method.rb', line 114
def public_preferences
public_preference_keys.each_with_object({}) do |key, hash|
hash[key] = preferences[key]
end
end
|
#reusable_sources(_order) ⇒ Object
Custom gateways should redefine this method. See Gateway implementation as an example
82
83
84
|
# File 'app/models/spree/payment_method.rb', line 82
def reusable_sources(_order)
[]
end
|
#show_in_admin? ⇒ Boolean
76
77
78
|
# File 'app/models/spree/payment_method.rb', line 76
def show_in_admin?
true
end
|
#source_required? ⇒ Boolean
72
73
74
|
# File 'app/models/spree/payment_method.rb', line 72
def source_required?
true
end
|
#store_credit? ⇒ Boolean
98
99
100
|
# File 'app/models/spree/payment_method.rb', line 98
def store_credit?
self.class == Spree::PaymentMethod::StoreCredit
end
|
#supports?(_source) ⇒ Boolean
90
91
92
|
# File 'app/models/spree/payment_method.rb', line 90
def supports?(_source)
true
end
|