diff --git a/app/routes/api.public.payment-info.tsx b/app/routes/api.public.payment-info.tsx index 3b1a51a..d55fd64 100644 --- a/app/routes/api.public.payment-info.tsx +++ b/app/routes/api.public.payment-info.tsx @@ -78,7 +78,6 @@ export const loader = async ({ request }: LoaderFunctionArgs) => { Response.json({ showPaymentInstructions: false, reason: "not-manual-payment", - debug: { shop, orderGid, hasOrder: !!orderInfo, txCount: orderInfo?.txCount ?? 0, manualFlags: orderInfo?.manualFlags ?? [] }, }), ); } diff --git a/extensions/invoice-thank-you-payment/src/Checkout.tsx b/extensions/invoice-thank-you-payment/src/Checkout.tsx index 13a488e..7c212b7 100644 --- a/extensions/invoice-thank-you-payment/src/Checkout.tsx +++ b/extensions/invoice-thank-you-payment/src/Checkout.tsx @@ -42,7 +42,6 @@ export default async () => { function Extension() { const shopify = (globalThis as any).shopify; const [data, setData] = useState(null); - const [debug, setDebug] = useState("init"); const [done, setDone] = useState(false); useEffect(() => { @@ -50,25 +49,21 @@ function Extension() { async function load() { try { const orderId: string | undefined = shopify?.orderConfirmation?.value?.order?.id; - setDebug(`orderId=${orderId ?? "(none)"}`); if (!orderId) { setDone(true); return; } const token: string = await shopify.sessionToken.get(); const appUrl = resolveAppUrl(shopify); - setDebug(`fetch ${appUrl} orderId=${orderId} tokenLen=${token?.length ?? 0}`); const res = await fetch( `${appUrl}/api/public/payment-info?orderId=${encodeURIComponent(orderId)}`, { headers: { Authorization: `Bearer ${token}` } }, ); - const text = await res.text(); - setDebug(`status=${res.status} body=${text.slice(0, 300)}`); if (!res.ok) { setDone(true); return; } - const json = JSON.parse(text) as { + const json = (await res.json()) as { showPaymentInstructions: boolean; payload?: PaymentInstructions; }; @@ -76,8 +71,8 @@ function Extension() { if (json.showPaymentInstructions && json.payload) { setData(json.payload); } - } catch (err) { - setDebug(`error: ${(err as Error)?.message ?? String(err)}`); + } catch { + // swallow; render nothing } finally { if (!cancelled) setDone(true); } @@ -88,22 +83,14 @@ function Extension() { }; }, []); - if (!done) { - return ; - } - if (!data) { - return ( - - {debug} - - ); + if (!done || !data) { + return null; } return ( {data.instructions} - - + {data.labels.recipient}: {data.recipient} @@ -117,7 +104,7 @@ function Extension() { {data.labels.amount}: {data.amountFormatted} {data.labels.reference}: {data.reference} - + ); }