Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Application\Shopify;
|
||||
|
||||
use App\Framework\Attributes\Route;
|
||||
use App\Framework\Config\External\ExternalApiConfig;
|
||||
use App\Framework\Http\Method;
|
||||
use App\Framework\Http\Request;
|
||||
use App\Framework\Http\Status;
|
||||
@@ -11,6 +13,11 @@ use App\Framework\Router\Result\JsonResult;
|
||||
|
||||
final class ShopifyWebhookHandler
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ExternalApiConfig $externalApiConfig
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Verarbeitet eingehende Shopify-Webhooks
|
||||
*
|
||||
@@ -27,9 +34,10 @@ final class ShopifyWebhookHandler
|
||||
// Validiere den HMAC, um sicherzustellen, dass der Request von Shopify kommt
|
||||
$rawData = $request->body;
|
||||
|
||||
if (!$this->validateWebhookHmac($hmac, $rawData)) {
|
||||
if (! $this->validateWebhookHmac($hmac, $rawData)) {
|
||||
$result = new JsonResult(['error' => 'Ungültiger HMAC']);
|
||||
$result->status = Status::UNAUTHORIZED;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -40,15 +48,18 @@ final class ShopifyWebhookHandler
|
||||
switch ($topic) {
|
||||
case 'orders/create':
|
||||
$this->processOrderCreated($data);
|
||||
|
||||
break;
|
||||
case 'products/create':
|
||||
case 'products/update':
|
||||
$this->processProductUpdate($data);
|
||||
|
||||
break;
|
||||
case 'customers/create':
|
||||
$this->processCustomerCreated($data);
|
||||
|
||||
break;
|
||||
// Weitere Webhook-Themen...
|
||||
// Weitere Webhook-Themen...
|
||||
default:
|
||||
// Unbekanntes Thema, loggen oder ignorieren
|
||||
break;
|
||||
@@ -63,12 +74,11 @@ final class ShopifyWebhookHandler
|
||||
*/
|
||||
private function validateWebhookHmac(?string $hmac, string $data): bool
|
||||
{
|
||||
if (!$hmac) {
|
||||
if (! $hmac) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Das Shared Secret sollte eigentlich in ApiConfig sein
|
||||
$secret = 'dein_webhook_shared_secret'; // ODER aus ApiConfig holen
|
||||
$secret = $this->externalApiConfig->shopify->webhookSecret;
|
||||
$calculatedHmac = base64_encode(hash_hmac('sha256', $data, $secret, true));
|
||||
|
||||
return hash_equals($calculatedHmac, $hmac);
|
||||
|
||||
Reference in New Issue
Block a user