Page MenuHomePhabricator

Adyen 905 errors
Closed, ResolvedPublic

Description

We've been getting a bunch of 905 errors back from Adyen, resulting in failmail.

In some (not all) cases, this appears to be due to a missing payment submethod. 107254500 logs show the first & second donation attempts have no submethod, but then on the third attempt, we get a submethod (visa) and the donation complete as expected.

Currently, we're reliant on Adyen telling us the payment submethod as part of the onSubmit event pasted below for convenience (check comment):

https://github.com/wikimedia/mediawiki-extensions-DonationInterface/blob/aecd47b9cd1899603cf0ea5d793762ca4071a8b5/adyen_gateway/checkout/forms/adyen.js#L206

// The code should be available in state.data.paymentMethod.brand, but
// sometimes it's not there. We can usually still find it via component.
payment_submethod: mapAdyenSubmethod(
	state.data.paymentMethod.brand || component.state.brand
)

The code comments suggest it's possible for us to not always receive the payment submethod in the state property, but what if the fallback is also unreliable? The frontend code that expects this data is here

Let's add some extra logging to this mapping method to work out what's going on here. Luckily we already have a MediaWiki API that we can use to log client-side errors, we're using it here for the generic window.error events:

( function ( $, mw ) {
	window.onerror = function ( message, file, line, col, error ) {
		var postdata = {
			action: 'logPaymentsFormError',
			message: message,
			file: file,
			line: line,
			col: col,
			userAgent: navigator.userAgent
		};
		if ( error && error.stack ) {
			postdata.stack = error.stack;
		}
		$.ajax( {
			url: mw.util.wikiScript( 'api' ),
			data: postdata,
			dataType: 'json',
			type: 'POST'
		} );
	};
} )( jQuery, mediaWiki );

We can reuse the bits above that make the ajax call to the ClientErrorApi API. The submethod/brandCode mapper method can then call this new code if Adyen does not supply us with a submethod, hopefully allowing us to dig in and work out why this might be happening.

Event Timeline

Looking in the corresponding IPN messages I see we have the following counts of 905 errors for each Adyen-side paymentMethod value (this month)
60 uatp
4 korean_local_card
3 elo
1 vias

Meanwhile we're getting orders of magnitude more 'Redirecting ' log messages with blank payment_submethod. In just one day's logs I see ~7000 different ct_ids with that blank vs ~15000 ct_ids with that field populated, or about 1 in 3 where the brand isn't ending up in state.data.paymentMethod.brand || component.state.brand

Of the ct_ids with no brand on the front end, 7454 came back with a successful auth IPN and 357 came back with a failed auth IPN, so it's not preventing donations from going through.

Here are the counts of paymentMethod values from IPNs for those ct_ids with no brand:

   5 amex
1769 cartebancaire
   2 discover
   2 korean_local_card
1483 mc
  13 uatp
   7 unknowncard
4530 visa

Wow, thanks for all the research, @Ejegg !!! It's good news that donations are still getting through when this issue is hit, at least!

We could reach out to Adyen to see if they know of valid scenarios which result in the brand not being set. The lookup call you found may be failing, but these numbers sound too high for failures.

Change 732803 had a related patch set uploaded (by Ejegg; author: Ejegg):

[wikimedia/fundraising/SmashPig@master] Adyen Checkout: map error code 905 to submethod

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

Change 732804 had a related patch set uploaded (by Ejegg; author: Ejegg):

[mediawiki/extensions/DonationInterface@master] Adyen Checkout: message to try another card

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

@jgleeson we could also add a 'debugMessages' field to the standard payment submission API call, which would just let us piggy-back diagnostic info on the normal call. That would be useful for this type of error where the form still appears valid, but wouldn't help with errors that prevent form submission.

Change 732837 had a related patch set uploaded (by Ejegg; author: Ejegg):

[mediawiki/extensions/DonationInterface@master] Add client-side debug messages to submission

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

Change 733965 had a related patch set uploaded (by AndyRussG; author: AndyRussG):

[mediawiki/extensions/DonationInterface@master] Add DonationApiBase::getLogger()

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

Change 733934 had a related patch set uploaded (by AndyRussG; author: AndyRussG):

[wikimedia/fundraising/dev@master] Enable debug-level logging for payments

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

Change 734003 had a related patch set uploaded (by AndyRussG; author: AndyRussG):

[mediawiki/extensions/DonationInterface@master] Only send debug messages from API if LogDebug is true

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

Change 732837 merged by jenkins-bot:

[mediawiki/extensions/DonationInterface@master] Add client-side debug messages to submission

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

Change 733934 merged by Ejegg:

[wikimedia/fundraising/dev@master] Enable debug-level logging for payments

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

Change 734003 merged by jenkins-bot:

[mediawiki/extensions/DonationInterface@master] Only send debug messages from API if LogDebug is true

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

Change 736109 had a related patch set uploaded (by AndyRussG; author: AndyRussG):

[wikimedia/fundraising/SmashPig@master] [WIP] Refactor ExceptionMapper to handle error code 905

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

Change 736110 had a related patch set uploaded (by AndyRussG; author: AndyRussG):

[mediawiki/extensions/DonationInterface@master] [WIP] Adyen Checkout: Update for Exceptionmapper refactor and error 905

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

Change 736109 abandoned by AndyRussG:

[wikimedia/fundraising/SmashPig@master] [WIP] Refactor ExceptionMapper to handle error code 905

Reason:

See comments on Id1052686281c and T294957

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

Change 736110 abandoned by AndyRussG:

[mediawiki/extensions/DonationInterface@master] [WIP] Adyen Checkout: Update for Exceptionmapper refactor and error 905

Reason:

See comments on Ibc7f5eb75c631 and T294957

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

Change 732803 merged by jenkins-bot:

[wikimedia/fundraising/SmashPig@master] Adyen Checkout: map error code 905 to submethod

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

Change 732804 merged by jenkins-bot:

[mediawiki/extensions/DonationInterface@master] Adyen Checkout: message to try another card

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

XenoRyet set Final Story Points to 4.

Change 733965 merged by jenkins-bot:

[mediawiki/extensions/DonationInterface@master] Add DonationApiBase::getLogger()

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