Class: Spree::PaymentMethod

Inherits:
Base
  • Object
show all
Defined in:
app/models/spree/payment_method.rb

Direct Known Subclasses

Gateway, Check, StoreCredit

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

Methods included from Spree::Preferences::Preferable

#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



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

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

.providersObject



20
21
22
# File 'app/models/spree/payment_method.rb', line 20

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

Instance Method Details

#auto_capture?Boolean

Returns:

  • (Boolean)


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

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.

Returns:

  • (Boolean)


75
76
77
# File 'app/models/spree/payment_method.rb', line 75

def available_for_order?(_order)
  true
end

#cancel(_response) ⇒ Object

Raises:

  • (::NotImplementedError)


65
66
67
# File 'app/models/spree/payment_method.rb', line 65

def cancel(_response)
  raise ::NotImplementedError, 'You must implement cancel method for this payment method.'
end

#method_typeObject



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

def method_type
  type.demodulize.downcase
end

#payment_profiles_supported?Boolean

Returns:

  • (Boolean)


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

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

Raises:

  • (::NotImplementedError)


31
32
33
# File 'app/models/spree/payment_method.rb', line 31

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

#provider_classObject

Raises:

  • (::NotImplementedError)


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

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



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

def reusable_sources(_order)
  []
end

#source_required?Boolean

Returns:

  • (Boolean)


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

def source_required?
  true
end

#store_credit?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'app/models/spree/payment_method.rb', line 69

def store_credit?
  self.class == Spree::PaymentMethod::StoreCredit
end

#supports?(_source) ⇒ Boolean

Returns:

  • (Boolean)


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

def supports?(_source)
  true
end