Page MenuHomePhabricator

PaymentProviders should be able to indicate required fields for each call
Open, Needs TriagePublicSpike

Description

Payment normalization libraries have a hard job - they want to let you make a payment without caring which processor you're talking to, but different processors require different data for similar operations.

Some options:

  1. require all the possible necessary information for all processors
  2. define a different request class for each different combination of required information
  3. accept arrays (with normalized parameter names) for requests and indicate which parameters are required at runtime

So far we have gone down road 3, but we don't have a way of marking which parameters are required for which calls

Maybe we could use attributes https://www.php.net/manual/en/language.attributes.overview.php for programatically marking which keys are required for each call. Then the base PaymentProvider class could have a getRequiredParameters call taking the method name and returning an array of required keys.