When adyen sends a non successful notification e.g. cancel a payment the following code is triggered:
# Invalidate payments that doesnt receive a successful notification
def handle!
if (authorisation? || capture?) && !success?
payment = Spree::Payment.find_by(response_code: psp_reference)
if payment && !payment.failed? && !payment.invalid?
payment.invalidate!
end
end
end
Now if you look at the state machine code in payment.rb ( spree core )
event :void do
transition from: [:pending, :completed, :checkout], to: :void
end
# when the card brand isnt supported
event :invalidate do
transition from: [:checkout], to: :invalid
end
It looks as though we should be calling void rather than invalidate ? or am I missing something?