Class: Spree::PaymentMethod
- Inherits:
-
Base
- Object
- ApplicationRecord
- Base
- Spree::PaymentMethod
show all
- Defined in:
- app/models/spree/payment_method.rb
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, page, spree_base_scopes
#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Class Method Details
.find_with_destroyed(*args) ⇒ Object
41
42
43
|
# File 'app/models/spree/payment_method.rb', line 41
def self.find_with_destroyed(*args)
unscoped { find(*args) }
end
|
.providers ⇒ Object
22
23
24
|
# File 'app/models/spree/payment_method.rb', line 22
def self.providers
Rails.application.config.spree.payment_methods
end
|
Instance Method Details
#auto_capture? ⇒ Boolean
59
60
61
|
# File 'app/models/spree/payment_method.rb', line 59
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.
77
78
79
|
# File 'app/models/spree/payment_method.rb', line 77
def available_for_order?(_order)
true
end
|
#available_for_store?(store) ⇒ Boolean
81
82
83
84
85
|
# File 'app/models/spree/payment_method.rb', line 81
def available_for_store?(store)
return true if store.blank? || store_id.blank?
store_id == store.id
end
|
#cancel(_response) ⇒ Object
67
68
69
|
# File 'app/models/spree/payment_method.rb', line 67
def cancel(_response)
raise ::NotImplementedError, 'You must implement cancel method for this payment method.'
end
|
#method_type ⇒ Object
37
38
39
|
# File 'app/models/spree/payment_method.rb', line 37
def method_type
type.demodulize.downcase
end
|
#payment_profiles_supported? ⇒ Boolean
45
46
47
|
# File 'app/models/spree/payment_method.rb', line 45
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
33
34
35
|
# File 'app/models/spree/payment_method.rb', line 33
def payment_source_class
raise ::NotImplementedError, 'You must implement payment_source_class method for this gateway.'
end
|
#provider_class ⇒ Object
26
27
28
|
# File 'app/models/spree/payment_method.rb', line 26
def provider_class
raise ::NotImplementedError, 'You must implement provider_class method for this gateway.'
end
|
#reusable_sources(_order) ⇒ Object
Custom gateways should redefine this method. See Gateway implementation as an example
55
56
57
|
# File 'app/models/spree/payment_method.rb', line 55
def reusable_sources(_order)
[]
end
|
#source_required? ⇒ Boolean
49
50
51
|
# File 'app/models/spree/payment_method.rb', line 49
def source_required?
true
end
|
#supports?(_source) ⇒ Boolean
63
64
65
|
# File 'app/models/spree/payment_method.rb', line 63
def supports?(_source)
true
end
|