-
Notifications
You must be signed in to change notification settings - Fork 3
Description
In pronamic/wp-pronamic-pay#334 I ran into a problem with the PaymentMethods::update_active_payment_methods() method.
Saving a gateway configuration will trigger the
Pronamic\WordPress\Pay\Core\PaymentMethods::update_active_payment_methods( )method, exceptions in this method are not handled, how should we proceed?
Originally posted by @remcotolsma in pronamic/wp-pronamic-pay#334 (comment)
The PaymentMethods::update_active_payment_methods() is not very scalable with a 'nopaging' => true WP_Query. Currently we mainly use the PaymentMethods class to hide some less common payment methods in for example the WooCommerce checkout settings page and in the payment methods field of forms plugins.
We need a way to register payment methods globally in the plugin. I would like to suggest that we create a settings page to give each registered payment method a status.
Payment Methods
| Payment Method | Status |
|---|---|
| iDEAL | 'active' |
| AfterPay | '' |
| Credit Card | 'inactive' |
Payment methods with an undefined status ('') could be auto activated by a gateway. If a user disabled a payment method (inactive) the status would never be auto updated. On saving a gateway configuration we only have to activate the payment methods that have an undefined status ('' or null). We no longer need to loop through all the gateway configurations and request which payment methods are active. We also no longer have to save that information per gateway configuration.
To implement this we could introduce a PaymentMethodsContainer or PaymentMethodsCollection class. Both the Gateway class and the Plugin class could use this class.
class PaymentMethodsCollection {
}
class Gateway {
public function get_payment_methods() : PaymentMethodsCollection {
}
}
class Plugin {
public function get_payment_methods() : PaymentMethodsCollection {
}
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status