Class: SolidusAfterpay::PaymentSource

Inherits:
Object
  • Object
show all
Defined in:
app/models/solidus_afterpay/payment_source.rb

Instance Method Summary collapse

Instance Method Details

#actionsObject



9
10
11
# File 'app/models/solidus_afterpay/payment_source.rb', line 9

def actions
  %w[capture void credit]
end

#can_void?(payment) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
# File 'app/models/solidus_afterpay/payment_source.rb', line 13

def can_void?(payment)
  payment_method = payment.payment_method

  return false if payment_method.auto_capture

  payment_state = payment_method.gateway.find_payment(order_id: payment.response_code).try(:[], :paymentState)

  ::SolidusAfterpay::Gateway::VOIDABLE_STATUSES.include?(payment_state)
end