fix(thank-you): serve GiroCode as signed PNG URL instead of data URL
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import type { LoaderFunctionArgs } from "react-router";
|
||||
import { authenticate, unauthenticated } from "../shopify.server";
|
||||
import db from "../db.server";
|
||||
import { buildGiroCodeDataUrl } from "../services/invoice/girocode";
|
||||
import { formatMoney, formatDate, addDays } from "../services/invoice/format";
|
||||
import { getStrings, pickLanguage } from "../services/invoice/i18n";
|
||||
import { signGiroCodeUrl } from "../services/invoice/signedUrl";
|
||||
|
||||
/**
|
||||
* Public endpoint consumed by the checkout / thank-you UI extension to fetch
|
||||
@@ -91,14 +91,12 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||
const amount = orderInfo.outstandingAmount > 0 ? orderInfo.outstandingAmount : orderInfo.totalAmount;
|
||||
const remittance = orderInfo.orderName || orderGid.split("/").pop() || "";
|
||||
|
||||
const giroCodeDataUrl = await buildGiroCodeDataUrl({
|
||||
beneficiaryName: [settings.companyName, settings.legalForm].filter(Boolean).join(" "),
|
||||
iban: settings.iban,
|
||||
bic: settings.bic,
|
||||
amount,
|
||||
currency: orderInfo.currency,
|
||||
remittance,
|
||||
});
|
||||
const giroCodeUrl = (() => {
|
||||
const exp = Math.floor(Date.now() / 1000) + 60 * 60; // 1 hour
|
||||
const origin = new URL(request.url).origin;
|
||||
const qs = signGiroCodeUrl({ shop, orderId: numericId, exp });
|
||||
return `${origin}/api/public/girocode.png?${qs}`;
|
||||
})();
|
||||
|
||||
const dueDate = settings.paymentTermDays > 0
|
||||
? addDays(new Date(), settings.paymentTermDays)
|
||||
@@ -110,7 +108,7 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
||||
payload: {
|
||||
language,
|
||||
heading: t.giroCodeCaption,
|
||||
giroCodeDataUrl,
|
||||
giroCodeUrl,
|
||||
recipient: [settings.companyName, settings.legalForm].filter(Boolean).join(" "),
|
||||
bankName: settings.bankName,
|
||||
iban: settings.iban,
|
||||
|
||||
Reference in New Issue
Block a user