Intégration fonctionnalites V1

This commit is contained in:
bastien
2026-07-04 22:30:18 +02:00
parent 55a558b536
commit 10ee859602
54 changed files with 4802 additions and 1018 deletions
@@ -17,6 +17,7 @@ class HealthController extends Controller
return $this->success([
'status' => 'ok',
'service' => 'laverie-api',
'timezone' => config('app.timezone'),
'timestamp' => now()->toIso8601String(),
]);
}
@@ -22,7 +22,6 @@ class WalletController extends Controller
public function __construct(
private readonly WalletService $walletService,
private readonly PaymentService $paymentService,
) {}
public function index(Request $request): JsonResponse
@@ -63,9 +62,9 @@ class WalletController extends Controller
]);
}
public function initiateTopUp(InitiateTopUpRequest $request): JsonResponse
public function initiateTopUp(InitiateTopUpRequest $request, PaymentService $paymentService): JsonResponse
{
$payment = $this->paymentService->initiateTopUp(
$payment = $paymentService->initiateTopUp(
$request->user(),
(float) $request->input('amount'),
$request->string('idempotency_key')->toString(),
@@ -77,9 +76,9 @@ class WalletController extends Controller
], 'Rechargement initié.');
}
public function confirmTopUp(ConfirmTopUpRequest $request): JsonResponse
public function confirmTopUp(ConfirmTopUpRequest $request, PaymentService $paymentService): JsonResponse
{
$payment = $this->paymentService->confirmTopUp(
$payment = $paymentService->confirmTopUp(
$request->string('payment_uuid')->toString(),
);
@@ -93,9 +92,20 @@ class WalletController extends Controller
], 'Rechargement confirmé.');
}
public function webhook(Request $request, string $provider): JsonResponse
public function webhook(Request $request, string $provider, PaymentService $paymentService): JsonResponse
{
$this->paymentService->handleWebhook($provider, $request->all());
if ($provider === 'stripe') {
try {
$paymentService->handleStripeWebhook(
$request->getContent(),
$request->header('Stripe-Signature', ''),
);
} catch (\InvalidArgumentException $e) {
return $this->error($e->getMessage(), 400);
}
} else {
$paymentService->handleWebhook($provider, $request->all());
}
return $this->success(message: 'Webhook traité.');
}