Class: Spree::PaymentMethod
Defined Under Namespace
Classes: Check, StoreCredit
Constant Summary
collapse
- DISPLAY =
[:both, :front_end, :back_end].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
belongs_to_required_by_default, for_store, has_many_inversing, json_api_columns, json_api_permitted_attributes, json_api_type, page, spree_base_scopes, spree_base_uniqueness_scope
#clear_preferences, #default_preferences, #defined_preferences, #deprecated_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_deprecated, #preference_type, #set_preference
Class Method Details
.find_with_destroyed(*args) ⇒ Object
50
51
52
|
# File 'app/models/spree/payment_method.rb', line 50
def self.find_with_destroyed(*args)
unscoped { find(*args) }
end
|
.providers ⇒ Object
29
30
31
|
# File 'app/models/spree/payment_method.rb', line 29
def self.providers
Rails.application.config.spree.payment_methods
end
|
Instance Method Details
#auto_capture? ⇒ Boolean
68
69
70
|
# File 'app/models/spree/payment_method.rb', line 68
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.
86
87
88
|
# File 'app/models/spree/payment_method.rb', line 86
def available_for_order?(_order)
true
end
|
#available_for_store?(store) ⇒ Boolean
90
91
92
93
94
|
# File 'app/models/spree/payment_method.rb', line 90
def available_for_store?(store)
return true if store.blank?
store_ids.include?(store.id)
end
|
#cancel(_response) ⇒ Object
76
77
78
|
# File 'app/models/spree/payment_method.rb', line 76
def cancel(_response)
raise ::NotImplementedError, 'You must implement cancel method for this payment method.'
end
|
#method_type ⇒ Object
46
47
48
|
# File 'app/models/spree/payment_method.rb', line 46
def method_type
type.demodulize.downcase
end
|
#payment_profiles_supported? ⇒ Boolean
54
55
56
|
# File 'app/models/spree/payment_method.rb', line 54
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
40
41
42
43
44
|
# File 'app/models/spree/payment_method.rb', line 40
def payment_source_class
return unless source_required?
raise ::NotImplementedError, 'You must implement payment_source_class method for this gateway.'
end
|
#provider_class ⇒ Object
33
34
35
|
# File 'app/models/spree/payment_method.rb', line 33
def provider_class
raise ::NotImplementedError, 'You must implement provider_class method for this gateway.'
end
|
#public_preferences ⇒ Object
96
97
98
99
100
|
# File 'app/models/spree/payment_method.rb', line 96
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
64
65
66
|
# File 'app/models/spree/payment_method.rb', line 64
def reusable_sources(_order)
[]
end
|
#source_required? ⇒ Boolean
58
59
60
|
# File 'app/models/spree/payment_method.rb', line 58
def source_required?
true
end
|
#supports?(_source) ⇒ Boolean
72
73
74
|
# File 'app/models/spree/payment_method.rb', line 72
def supports?(_source)
true
end
|