apply_filters request
-
Hi,
I am a developer that would love to have a filter available for
self::WEBHOOK_EVENTS
inwoocommerce-gateway-stripe/includes/class-wc-stripe-account.php
Specifically in the functionconfigure_webhooksa filter that allows to filter allowed events to be able to include custom ones, and then not have the webhook re configured with every update.
Namely instead of usingself::WEBHOOK_EVENTSdirectly here/**
* Configures webhooks for the account.
*
* @param string $mode The mode to configure webhooks for. Either 'live' or 'test'. Default is 'live'.
*
* @throws Exception If there was a problem setting up the webhooks.
* @return object The response from the API.
*/
public function configure_webhooks( $mode = 'live', $secret_key = '' ) {
$request = [
'enabled_events' => self::WEBHOOK_EVENTS,
'url' => WC_Stripe_Helper::get_webhook_url(),
'api_version' => WC_Stripe_API::STRIPE_API_VERSION,
];... Rest of function
}Adding a filter like for example ‘wc_stripe_enabled_events’ in this way
public function configure_webhooks( $mode = 'live', $secret_key = '' ) {
$request = [
'enabled_events' => apply_filters( 'wc_stripe_enabled_events', self::WEBHOOK_EVENTS ),
'url' => WC_Stripe_Helper::get_webhook_url(),
'api_version' => WC_Stripe_API::STRIPE_API_VERSION,
];... Rest of function
}This would be backwards compatible, as by default the returned events are exactly the same as defined in the the const at the start of the class.
I can submit a PR or whatever way is preferred to make this possible.Looking forward to your reply to whether we can do this.
Thank you
You must be logged in to reply to this topic.