Class: Spree::AffirmCheckout
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::AffirmCheckout
- Defined in:
- app/models/spree/affirm_checkout.rb
Instance Method Summary collapse
- #actions ⇒ Object
-
#can_capture?(payment) ⇒ Boolean
Indicates whether its possible to capture the payment.
-
#can_credit?(payment) ⇒ Boolean
Indicates whether its possible to credit the payment.
-
#can_void?(payment) ⇒ Boolean
Indicates whether its possible to void the payment.
- #details ⇒ Object
- #name ⇒ Object
Instance Method Details
#actions ⇒ Object
16 17 18 |
# File 'app/models/spree/affirm_checkout.rb', line 16 def actions %w{capture void credit} end |
#can_capture?(payment) ⇒ Boolean
Indicates whether its possible to capture the payment
21 22 23 |
# File 'app/models/spree/affirm_checkout.rb', line 21 def can_capture?(payment) (payment.pending? || payment.checkout?) && !payment.response_code.blank? 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.
32 33 34 35 36 |
# File 'app/models/spree/affirm_checkout.rb', line 32 def can_credit?(payment) return false unless payment.completed? return false unless payment.order.payment_state == 'credit_owed' payment.credit_allowed > 0 end |
#can_void?(payment) ⇒ Boolean
Indicates whether its possible to void the payment.
26 27 28 |
# File 'app/models/spree/affirm_checkout.rb', line 26 def can_void?(payment) !payment.void? && payment.pending? && !payment.response_code.blank? end |
#details ⇒ Object
12 13 14 |
# File 'app/models/spree/affirm_checkout.rb', line 12 def details @details ||= payment_method.provider.get_checkout token end |
#name ⇒ Object
8 9 10 |
# File 'app/models/spree/affirm_checkout.rb', line 8 def name "Affirm Checkout" end |