Intégration fonctionnalites V1
This commit is contained in:
@@ -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é.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user