You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The PaymentMethods::update_active_payment_methods() is not very scalable with a 'nopaging' => trueWP_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 {
}
}
The text was updated successfully, but these errors were encountered:
Currently, a payment method can be listed as 'Active' on the 'Payment methods' tab in the payment gateway configuration settings, while the method does not appear in e.g. WooCommerce. Updating the payment gateway configuration resolved the issue.
In pronamic/wp-pronamic-pay#334 I ran into a problem with the
PaymentMethods::update_active_payment_methods()
method.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 thePaymentMethods
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
'active'
''
'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 (''
ornull
). 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
orPaymentMethodsCollection
class. Both theGateway
class and thePlugin
class could use this class.The text was updated successfully, but these errors were encountered: