Limit-Status im Upload-Flow anzeigen (Warnbanner + Sperrzustände).
Upload-Fehlercodes auswerten und freundliche Dialoge zeigen.
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Jobs\ProcessRevenueCatWebhook;
|
||||
use App\Support\ApiError;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RevenueCatWebhookController extends Controller
|
||||
{
|
||||
@@ -15,17 +17,33 @@ class RevenueCatWebhookController extends Controller
|
||||
|
||||
if ($secret === '') {
|
||||
Log::error('RevenueCat webhook secret not configured');
|
||||
return response()->json(['error' => 'Webhook not configured'], 500);
|
||||
|
||||
return ApiError::response(
|
||||
'webhook_not_configured',
|
||||
'Webhook Not Configured',
|
||||
'RevenueCat webhook secret is missing.',
|
||||
Response::HTTP_INTERNAL_SERVER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
$signature = trim((string) $request->header('X-Signature', ''));
|
||||
if ($signature === '') {
|
||||
return response()->json(['error' => 'Signature missing'], 400);
|
||||
return ApiError::response(
|
||||
'signature_missing',
|
||||
'Signature Missing',
|
||||
'The RevenueCat webhook request did not include a signature.',
|
||||
Response::HTTP_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
$payload = $request->getContent();
|
||||
if (! $this->signatureMatches($payload, $signature, $secret)) {
|
||||
return response()->json(['error' => 'Invalid signature'], 400);
|
||||
return ApiError::response(
|
||||
'signature_invalid',
|
||||
'Invalid Signature',
|
||||
'The webhook signature could not be validated.',
|
||||
Response::HTTP_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
$decoded = json_decode($payload, true);
|
||||
@@ -33,7 +51,14 @@ class RevenueCatWebhookController extends Controller
|
||||
Log::warning('RevenueCat webhook received invalid JSON', [
|
||||
'error' => json_last_error_msg(),
|
||||
]);
|
||||
return response()->json(['error' => 'Invalid payload'], 400);
|
||||
|
||||
return ApiError::response(
|
||||
'payload_invalid',
|
||||
'Invalid Payload',
|
||||
'The webhook payload could not be decoded as JSON.',
|
||||
Response::HTTP_BAD_REQUEST,
|
||||
['json_error' => json_last_error_msg()]
|
||||
);
|
||||
}
|
||||
|
||||
ProcessRevenueCatWebhook::dispatch(
|
||||
|
||||
Reference in New Issue
Block a user