Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Non successful notifications creates an illegal state change from pending / complete -> invalid ( invalidate ) #9

@DangerDawson

Description

@DangerDawson

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions