Page MenuHomePhabricator

Create rules for gateway tiebreaking based on querystring
Closed, ResolvedPublic4 Estimated Story Points

Description

Add a function in FormChooser whose arguments are two arrays, the querystring and a list of processors (presumably already narrowed down by country/currency/method support). The function should consult a config variable with a list of rules and return a single processor.

Potential format for rules:

$wgDonationInterfaceProcessorPriorityRules = [
	[
		'condition' => [ 'utm_medium' => 'endowment' ],
		'processors' => [ 'ingenico' ]
	],
	[
		'condition' => [ 'country' => 'FR' ],
		'processors' => [ 'adyen' ]
	],
	[
		'condition' => 'default',
		'processors' => [ 'ingenico', 'adyen', 'paypal' ]
	]
];

A rule could include values for any of the URL parameters. Rules would be evaluated from first to last, and the first matching rule would be used to determine the processor priority.

Event Timeline

DStrine set the point value for this task to 4.

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

[mediawiki/extensions/DonationInterface@master] WIP: Create rules for gateway tiebreaking based on querystring

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

I've pushed up a WIP patch for this here. I went with an approach of iterating across the priority rules and checking each condition against the current user parameters. If the parameter matches the condition, the gateways specified in the 'processors' key for that rule are given a point. The score is kept in the $scoreKeeper array and at the end of the rules loop, the processor with the highest score is returned.

I've been using TDD to try this out as it's in the early stages and not being called from anywhere in the code. To test it yourself run

./payments-phpunit.sh --filter testGetMeAGateway

Check out code comments also!

jgleeson moved this task from Doing to Backlog on the Fundraising Sprint High velocity swallows board.
jgleeson subscribed.

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

[mediawiki/extensions/DonationInterface@master] Tiebreaker rules for gateways

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

Change 789675 abandoned by Jgleeson:

[mediawiki/extensions/DonationInterface@master] WIP: Create rules for gateway tiebreaking based on querystring

Reason:

using approach in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DonationInterface/+/789731

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

Change 789731 merged by jenkins-bot:

[mediawiki/extensions/DonationInterface@master] Tiebreaker rules for gateways

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

XenoRyet set Final Story Points to 4.