Class: Spree::AffirmCheckout

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

Instance Method Summary collapse

Instance Method Details

#actionsObject



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

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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

#detailsObject



12
13
14
# File 'app/models/spree/affirm_checkout.rb', line 12

def details
  @details ||= payment_method.provider.get_checkout token
end

#nameObject



8
9
10
# File 'app/models/spree/affirm_checkout.rb', line 8

def name
  "Affirm Checkout"
end