File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change 2727
2828// load payload as JSON
2929$ payload = file_get_contents ($ payloadFile );
30- $ payload = json_decode ($ payload , true );
30+ $ jsonData = json_decode ($ payload , true );
31+
32+ if (json_last_error () !== JSON_ERROR_NONE ) {
33+ echo "Error: Invalid JSON in payload file. \n" ;
34+ exit (1 );
35+ }
36+
37+ if (!isset ($ jsonData ['notificationItems ' ]) || !is_array ($ jsonData ['notificationItems ' ])) {
38+ echo "Error: 'notificationItems' key is missing or not an array. \n" ;
39+ exit (1 );
40+ }
3141
3242// Fetch the first (and only) NotificationRequestItem
33- $ notificationItems = $ payload ['notificationItems ' ];
34- $ notificationRequestItem = array_shift ($ notificationItems );
43+ $ notificationRequestItem = $ jsonData ['notificationItems ' ][0 ]['NotificationRequestItem ' ] ?? null ;
44+
45+ if ($ notificationRequestItem === null ) {
46+ echo "Error: 'NotificationRequestItem' is not found. \n" ;
47+ exit (1 );
48+ }
49+
50+ // Log notificationRequestItem
51+ //print_r($notificationRequestItem);
3552
3653$ hmacSignature = new HmacSignature ();
3754$ signature = $ hmacSignature ->calculateNotificationHMAC ($ hmacKey , $ notificationRequestItem );
You can’t perform that action at this time.
0 commit comments