module->getSignatureKey(), $payload, $this->getRequestHeaders() ); (new PaynowOrderStateProcessor($this->module))->processNotification($notification_data); } catch (SignatureVerificationException | InvalidArgumentException $e) { $notification_data['exception'] = $e->getMessage(); PaynowLogger::error('Notification: Signature verification failed', $notification_data); header('HTTP/1.1 400 Bad Request', true, 400); ob_clean(); exit; } catch (PaynowNotificationStopProcessing $e) { $e->logContext['responseCode'] = 202; PaynowLogger::debug('Notification: ' . $e->logMessage, $e->logContext); header('HTTP/1.1 202 OK', true, 202); ob_clean(); exit; } catch (PaynowNotificationRetryProcessing $e) { $e->logContext['responseCode'] = 400; PaynowLogger::debug('Notification: ' . $e->logMessage, $e->logContext); header('HTTP/1.1 400 Bad Request', true, 400); ob_clean(); exit; } catch (Exception $e) { $notification_data['responseCode'] = 400; $notification_data['exception'] = $e->getMessage(); $notification_data['file'] = $e->getFile(); $notification_data['line'] = $e->getLine(); PaynowLogger::error('Notification: unknown error', $notification_data); header('Content-Type: application/json'); header('HTTP/1.1 400 Bad Request', true, 400); ob_clean(); echo json_encode( array( 'message' => 'An error occurred during processing notification', 'reason' => $e->getMessage(), ) ); ob_flush(); exit; } header("HTTP/1.1 200 OK", true, 200); ob_clean(); exit; } private function getRequestHeaders(): array { $headers = []; foreach ($_SERVER as $key => $value) { if (Tools::substr($key, 0, 5) == 'HTTP_') { $subject = str_replace('_', ' ', Tools::strtolower(Tools::substr($key, 5))); $headers[str_replace(' ', '-', ucwords($subject))] = $value; } } return $headers; } }