Fix payout account-status route ordering
Move /account-status route before /:id to prevent Express from matching "account-status" as a payout ID parameter. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,29 @@ router.get('/', authenticate, async (req, res, next) => {
|
||||
}
|
||||
});
|
||||
|
||||
// --- Check Stripe Connect account status ---
|
||||
router.get('/account-status', authenticate, async (req, res, next) => {
|
||||
try {
|
||||
if (!stripe) throw new AppError(500, 'Stripe not configured');
|
||||
|
||||
const user = await prisma.user.findUnique({ where: { id: req.userId } });
|
||||
if (!user?.stripeAccountId) {
|
||||
return res.json({ connected: false, detailsSubmitted: false, chargesEnabled: false, payoutsEnabled: false });
|
||||
}
|
||||
|
||||
const account = await stripe.accounts.retrieve(user.stripeAccountId);
|
||||
|
||||
res.json({
|
||||
connected: true,
|
||||
detailsSubmitted: account.details_submitted,
|
||||
chargesEnabled: account.charges_enabled,
|
||||
payoutsEnabled: account.payouts_enabled,
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
// --- Get payout details ---
|
||||
router.get('/:id', authenticate, async (req, res, next) => {
|
||||
try {
|
||||
@@ -90,27 +113,4 @@ router.post('/setup-account', authenticate, async (req, res, next) => {
|
||||
}
|
||||
});
|
||||
|
||||
// --- Check Stripe Connect account status ---
|
||||
router.get('/account-status', authenticate, async (req, res, next) => {
|
||||
try {
|
||||
if (!stripe) throw new AppError(500, 'Stripe not configured');
|
||||
|
||||
const user = await prisma.user.findUnique({ where: { id: req.userId } });
|
||||
if (!user?.stripeAccountId) {
|
||||
return res.json({ connected: false, detailsSubmitted: false, chargesEnabled: false, payoutsEnabled: false });
|
||||
}
|
||||
|
||||
const account = await stripe.accounts.retrieve(user.stripeAccountId);
|
||||
|
||||
res.json({
|
||||
connected: true,
|
||||
detailsSubmitted: account.details_submitted,
|
||||
chargesEnabled: account.charges_enabled,
|
||||
payoutsEnabled: account.payouts_enabled,
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user