File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,12 +37,18 @@ public function handle($event)
3737 $ apiEnvironment = session ()->get ('api_environment ' , $ event ->apiEnvironment ?? 'live ' );
3838 $ isSandbox = session ()->get ('is_sandbox ' , $ event ->isSandbox );
3939
40+ // Compute the event payload exactly once so the persisted ApiEvent record and the
41+ // outbound webhook body are guaranteed to be identical. $event->getEventData() resolves
42+ // the model live at handle time, whereas $event->data is a snapshot frozen at dispatch
43+ // time; using each in a different place lets the DB record and the webhook diverge.
44+ $ payload = $ event ->getEventData ();
45+
4046 // Prepare event
4147 $ eventData = [
4248 'company_uuid ' => $ companyId ,
4349 'event ' => $ event ->broadcastAs (),
4450 'source ' => $ apiCredentialId ? 'api ' : 'console ' ,
45- 'data ' => $ event -> getEventData () ,
51+ 'data ' => $ payload ,
4652 'method ' => $ event ->requestMethod ,
4753 'description ' => $ this ->getHumanReadableEventDescription ($ event ),
4854 ];
@@ -100,7 +106,7 @@ public function handle($event)
100106 'sent_at ' => Carbon::now (),
101107 ])
102108 ->url ($ webhook ->url )
103- ->payload ($ event -> data )
109+ ->payload ($ payload )
104110 ->useSecret ($ apiSecret )
105111 ->dispatch ();
106112 } catch (\Exception |\Aws \Sqs \Exception \SqsException $ exception ) {
You can’t perform that action at this time.
0 commit comments