Skip to content

Notification resolution question #186

@mbertoneri

Description

@mbertoneri

We are running sylius/adyen-plugin (version: 2.0.5 on Sylius version: 2.2.5).

We sometimes hit a race condition on AUTHORISATION webhooks: Adyen delivers the webhook almost immediately after payment completion, sometimes before the local AdyenReference row has been committed to the database.

Current behavior:

ProcessNotificationsAction::__invoke resolves and dispatches the command synchronously inside the HTTP request:

  try {
      $command = $this->notificationCommandResolver->resolve($paymentMethodCode, $notificationItem);
      $this->messageBus->dispatch($command);
  } catch (NoCommandResolvedException) {
      $this->logger->error(sprintf(
          'Tried to dispatch an unknown command. Notification body: %s',
          json_encode($notificationItem, JSON_PARTIAL_OUTPUT_ON_ERROR),
      ));
  }

The failure point seems to be the resolve step: PaymentNotificationResolver::getPayment calls AdyenReferenceRepository::getOneByCodeAndReference, which throws NoResultException when the AdyenReference row is not yet committed. This propagates as NoCommandResolvedException.

Example of the logged error we observe:

Tried to dispatch an unknown command. Notification body: {"eventCode":"authorisation","merchantReference":"XXXXX","pspReference":"XXXXX","originalReference":null,...}

Questions

  1. Would it be safe to defer the entire resolve + dispatch block to a Messenger message — acknowledging the webhook immediately and performing the resolution in a handler that can be retried on failure ?

  2. Is there a reason the plugin resolves and dispatches the command inline in the HTTP request rather than deferring the entire block to a message bus (which the application could configure as synchronous or asynchronous) ?

  3. Are there webhook event types for which async processing would be problematic ?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions