feat(payment): add GET /api/v1/my/payments for the logged-in user

Add PaymentRepository::findByUser/countByUser and a paginated
my/payments endpoint that returns the authenticated user's own payments
(derived from the token, never a userId in the URL). Public dashboard's
transactions tab can now list payments instead of hitting a nonexistent
route.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-15 19:21:31 +03:30
co-authored by Claude Opus 4.8
parent 5d204d7460
commit 038cb73ea7
3 changed files with 180 additions and 0 deletions
@@ -518,6 +518,23 @@ class PaymentController extends BaseController
]);
}
#[IsGranted('IS_AUTHENTICATED_FULLY')]
#[Route('/api/v1/my/payments', methods: ['GET'])]
public function myPayments(Request $request, #[CurrentUser] User $user): JsonResponse
{
$page = max(1, (int) $request->query->get('page', 1));
$limit = min(100, max(1, (int) $request->query->get('limit', 20)));
$status = $request->query->get('status');
$items = array_map(
fn(Payment $p) => $p->toArray(),
$this->paymentRepo->findByUser($user, $status, $page, $limit)
);
$total = $this->paymentRepo->countByUser($user, $status);
return $this->paginated($items, $total, $page, $limit);
}
#[IsGranted('IS_AUTHENTICATED_FULLY')]
#[Route('/api/v1/payment/{uuid}', methods: ['GET'])]
public function getStatus(string $uuid, #[CurrentUser] User $user): JsonResponse