- Added localization support for API responses in English and Spanish. - Introduced a middleware to set the API locale based on the Accept-Language header. - Updated various exception messages and validation responses to use localized strings. - Created new language files for English and Spanish translations. - Refactored existing code to replace hardcoded messages with localized strings. - Added tests to verify localization functionality and response correctness.
32 lines
967 B
PHP
32 lines
967 B
PHP
<?php
|
|
|
|
namespace App\Domains\Integration\Controllers;
|
|
|
|
use App\Domains\Integration\Requests\TelepagosWebhookRequest;
|
|
use App\Domains\Integration\Services\TelepagosWebhookService;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class TelepagosWebhookController extends Controller
|
|
{
|
|
/**
|
|
* Handle the incoming Telepagos webhook.
|
|
*/
|
|
public function handle(TelepagosWebhookRequest $request, string $tenantCodigo, TelepagosWebhookService $service): JsonResponse
|
|
{
|
|
try {
|
|
$cashinId = $request->validated('id');
|
|
|
|
$service->handleWebhook($tenantCodigo, $cashinId);
|
|
|
|
return response()->json(['status' => 'success']);
|
|
} catch (\Exception $e) {
|
|
return response()->json([
|
|
'status' => 'error',
|
|
'code' => 'integration.webhook_failed',
|
|
'message' => __('api.integration.webhook_failed'),
|
|
], 500);
|
|
}
|
|
}
|
|
}
|