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 <noreply@anthropic.com>

* Fix phpstan: instantiate HookManager before use in ipn.php

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Erwan-Wiwit
2026-02-23 01:43:25 +01:00
committed by GitHub
parent dd3709be29
commit 08feb72c6c

View File

@@ -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));