/api/webhooks/paymob endpoint. This hits the PaymobWebhookController::handle method, which immediately delegates to the WebhookService.PAYMOB_HMAC environment variable is empty, the PaymobGateway throws a fatal exception. This fails-fast, preventing attackers from exploiting an empty-secret HMAC bypass.WebhookService applies three layers of defense before touching the database.Cache::lock("paymob_webhook_processing_{$merchantOrderId}", 60). If Paymob fires 5 identical webhooks simultaneously (network retries), 4 of them will hit the lock and gracefully return 200 OK without touching the DB.$payment->status is already PAID or FAILED.WebhookService.FulfillOrderListenerPaymentSucceeded event fires, the FulfillOrderListener takes over on the background queue. It iterates through the $order->items and determines the fulfillment strategy based on the product type.provider_ref matching the paymob_transaction_id already exists. If yes, it aborts (preventing double-upgrades).ACTIVE subscriptions for that user to CANCELLED.Subscription record with the correct billing cycle.ai_generations_count to 0 and extends the ai_reset_at date.FulfillOrderListener checks the database state before executing any mutations, guaranteeing safety on retries.