From 08feb72c6cd4de169cd2f1f987dee89e36bf1b74 Mon Sep 17 00:00:00 2001 From: Erwan-Wiwit Date: Mon, 23 Feb 2026 01:43:25 +0100 Subject: [PATCH] Add hook stripeWebhookEvent in Stripe IPN for external modules (#37293) * Add hook stripeWebhookEvent in Stripe IPN for external modules Allow external modules to intercept and handle Stripe webhook events via the standard Dolibarr hook system. The hook is called before the built-in event processing, and modules can return >0 to stop default processing if they handled the event entirely. Hook context: stripeipn Hook method: stripeWebhookEvent Parameters: event (full Stripe event), servicestatus, service Co-Authored-By: Claude Opus 4.6 * Fix phpstan: instantiate HookManager before use in ipn.php Co-Authored-By: Claude Opus 4.6 --------- Co-authored-by: Claude Opus 4.6 Co-authored-by: Laurent Destailleur --- htdocs/public/stripe/ipn.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index d8a88530bbd..839a67edc22 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -191,6 +191,18 @@ dol_syslog("***** Stripe IPN was called with event->type=".$event->type." servic sleep(2); +// Hook to allow external modules to handle Stripe webhook events +$hookmanager = new HookManager($db); +$hookmanager->initHooks(array('stripeipn')); +$parameters = array('event' => $event, 'servicestatus' => $servicestatus, 'service' => $service); +$reshook = $hookmanager->executeHooks('stripeWebhookEvent', $parameters, $event->data->object, $event->type); +if ($reshook > 0) { + // A hook handled the event entirely, stop processing + http_response_code(200); + return; +} + + if ($event->type == 'payout.created' && getDolGlobalString('STRIPE_AUTO_RECORD_PAYOUT')) { // When a payout is created by Stripe to transfer money to your account dol_syslog("object = ".formatLogObject($event->data));