payment info updates

This commit is contained in:
Gerhard Scheikl
2026-05-09 21:05:09 +02:00
parent 35dea965f6
commit 8bc86ef985
2 changed files with 32 additions and 7 deletions
+19 -3
View File
@@ -43,16 +43,28 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
return cors(Response.json({ showPaymentInstructions: false, reason: "no-iban-or-disabled" }));
}
const { admin } = await unauthenticated.admin(shop);
let orderInfo: OrderInfo | null = null;
try {
const { admin } = await unauthenticated.admin(shop);
orderInfo = await fetchOrderInfo(admin, orderGid);
} catch (err) {
const msg = (err as Error)?.message ?? String(err);
console.warn(`payment-info: failed to load order ${orderGid} for ${shop}:`, err);
return cors(Response.json({ showPaymentInstructions: false, error: "order-load-failed" }, { status: 502 }));
return cors(
Response.json(
{ showPaymentInstructions: false, error: "order-load-failed", detail: msg.slice(0, 500) },
{ status: 502 },
),
);
}
if (!orderInfo || !orderInfo.isManual) {
return cors(Response.json({ showPaymentInstructions: false, reason: "not-manual-payment" }));
return cors(
Response.json({
showPaymentInstructions: false,
reason: "not-manual-payment",
debug: { shop, orderGid, hasOrder: !!orderInfo, txCount: orderInfo?.txCount ?? 0, manualFlags: orderInfo?.manualFlags ?? [] },
}),
);
}
const language = pickLanguage(orderInfo.customerLocale ?? settings.defaultLanguage);
@@ -113,6 +125,8 @@ interface OrderInfo {
currency: string;
orderName: string;
customerLocale?: string;
txCount: number;
manualFlags: Array<{ status?: string; manual?: boolean }>;
}
async function fetchOrderInfo(
@@ -161,5 +175,7 @@ async function fetchOrderInfo(
currency: o.currencyCode ?? "EUR",
orderName: o.name ?? "",
customerLocale: o.customerLocale ?? undefined,
txCount: txs.length,
manualFlags: txs.map((t) => ({ status: t.status, manual: t.manualPaymentGateway })),
};
}