payment info updates
This commit is contained in:
@@ -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 })),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user