Page MenuHomePhabricator

Adyen webhooks for Gravy-orchestrated transactions arriving with a colon-separated merchantReference breaking Base62 conversion
Open, Needs TriagePublic

Description

Some Adyen CAPTURE webhooks for Gravy-orchestrated transactions are arriving with a colon-separated merchantReference. e.g.:
"merchantReference":"61SCO9jPrV41AIP8Wl5xkm:4Fn2bJ6cThbEiEdI1zGkYi"

The colon is not in the Base62 alphabet, so the subsequent Base62Helper::toUuid( $notification['merchantReference'] ); fails

It looks like we don't need to perform this conversion anyway for these cases, as CaptureResponseAction::execute() drops these messages later on in this check:

public function execute( ListenerMessage $msg ): bool {
	$tl = new TaggedLogger( 'CaptureResponseAction' );

	if ( $msg instanceof Capture ) {
		if ( $msg->success ) {
			// drop Gr4vy initiated message
			if ( $msg->gateway === 'gravy' ) {
				return true;
			}
			$tl->info(
				"Adding record capture job for {$msg->currency} {$msg->amount} with psp reference {$msg->pspReference}."
			);
			$recordJob = RecordCaptureJob::factory( $msg );
			QueueWrapper::push( 'jobs-adyen', $recordJob );
		} else {
			$tl->warning(
				"Capture failed for payment with reference {$msg->pspReference}.",
				$msg
			);
		}
	}

	return true;
}

I'll add some code to detect and skip this conversion

Event Timeline

Change #1297103 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[wikimedia/fundraising/SmashPig@master] Skip Base62 conversions for problematic Gravyy-related Adyen capture webhooks.

https://gerrit.wikimedia.org/r/1297103

Change #1297103 merged by jenkins-bot:

[wikimedia/fundraising/SmashPig@master] Skip Base62 conversions for problematic Gravy-related Adyen webhooks.

https://gerrit.wikimedia.org/r/1297103

Change #1297112 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[wikimedia/fundraising/SmashPig@master] Restrict b10ee0a45 to only apply for CAPTURE events

https://gerrit.wikimedia.org/r/1297112