Class: Spree::PaymentSource
- Defined in:
- app/models/spree/payment_source.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#imported ⇒ Object
Returns the value of attribute imported.
Instance Method Summary collapse
-
#actions ⇒ Array<String>
The actions available on this payment source.
-
#can_capture?(payment) ⇒ Boolean
True when the payment is in the pending or checkout states.
-
#can_credit?(payment) ⇒ Boolean
Indicates whether its possible to credit the payment.
-
#can_void?(payment) ⇒ Boolean
True when the payment is not failed, voided or invalid.
-
#reusable? ⇒ Boolean
Indicates whether this payment source can be used more than once.
Methods inherited from Base
Methods included from Core::Permalinks
#generate_permalink, #save_permalink
Instance Attribute Details
#imported ⇒ Object
Returns the value of attribute imported.
16 17 18 |
# File 'app/models/spree/payment_source.rb', line 16 def imported @imported end |
Instance Method Details
#actions ⇒ Array<String>
Returns the actions available on this payment source.
19 20 21 |
# File 'app/models/spree/payment_source.rb', line 19 def actions %w(capture void credit) end |
#can_capture?(payment) ⇒ Boolean
Returns true when the payment is in the pending or checkout states.
25 26 27 |
# File 'app/models/spree/payment_source.rb', line 25 def can_capture?(payment) payment.pending? || payment.checkout? end |
#can_credit?(payment) ⇒ Boolean
Indicates whether its possible to credit the payment. Note that most gateways require that the payment be settled first which generally happens within 12-24 hours of the transaction.
41 42 43 |
# File 'app/models/spree/payment_source.rb', line 41 def can_credit?(payment) payment.completed? && payment.credit_allowed > 0 end |
#can_void?(payment) ⇒ Boolean
Returns true when the payment is not failed, voided or invalid.
31 32 33 |
# File 'app/models/spree/payment_source.rb', line 31 def can_void?(payment) payment.can_void? end |
#reusable? ⇒ Boolean
Indicates whether this payment source can be used more than once. E.g. a credit card with a ‘payment profile’.
47 48 49 |
# File 'app/models/spree/payment_source.rb', line 47 def reusable? false end |