From 74f8a634073fc04be9983f0e0c39ad46b8df5b67 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 26 Aug 2025 21:53:38 -0700 Subject: fix autopay with tip logic --- src/routes/(app)/invoice/[id]/tip/+page.server.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/routes/(app)/invoice/[id]/tip/+page.server.ts b/src/routes/(app)/invoice/[id]/tip/+page.server.ts index 23e3a07c..851d3f1b 100644 --- a/src/routes/(app)/invoice/[id]/tip/+page.server.ts +++ b/src/routes/(app)/invoice/[id]/tip/+page.server.ts @@ -19,14 +19,13 @@ export async function load({ cookies, params, parent }) { if (user.tip > 0) { invoice.tip = Math.round(invoice.amount * (user.tip / 100)); invoice = await post(`/invoice/${id}`, { invoice }, auth(cookies)); - } else { - throw new Error("tip"); + p = await post("/payments", { ...invoice, pin }, auth(cookies)); } + } else { + p = await post("/payments", { ...invoice, pin }, auth(cookies)); } - p = await post("/payments", { ...invoice, pin }, auth(cookies)); } catch (e) { const { message } = e as Error; - if (message === "tip") redirect(307, `/invoice/${id}/tip`); fail(400, { message }); } if (p) redirect(307, `/sent/${p.id}`); -- cgit v1.2.3