commit b49fd1d04c1f22b34ee168e52a22968ae09e0b04
parent 95dc27cfe9fedd1e17f68a49137ca4b83f7f996e
Author: Florian Dold <dold@taler.net>
Date: Wed, 25 Nov 2026 20:06:31 +0100
wallet web UI: explain the bank transfer steps for manual withdrawals
Show the amount to send from the selected bank account, where to enter
the mandatory reference, and when the withdrawal will resume.
Issue: https://bugs.taler.net/n/12108
Diffstat:
4 files changed, 144 insertions(+), 60 deletions(-)
diff --git a/packages/wallet-webui/src/routes/withdrawal-model.ts b/packages/wallet-webui/src/routes/withdrawal-model.ts
@@ -28,6 +28,8 @@ export interface WireOptionView {
label: string;
bankLabel?: string;
fields: WireFieldView[];
+ reference?: { value: string; isSwissQr: boolean };
+ transferAmount?: string;
paytoUri?: string;
qrCodes?: QrCodeSpec[];
externalUri?: string;
@@ -167,6 +169,7 @@ export function wireOptions(
: (account.bankLabel ?? i18n.str`Open banking app`),
...(account.bankLabel ? { bankLabel: account.bankLabel } : {}),
fields: [],
+ transferAmount: account.transferAmount,
externalUri: option.uri,
...common,
};
@@ -183,10 +186,11 @@ export function wireOptions(
const holder = Paytos.getAccountHolder(parsed);
const address = joinAddress(params);
const amount = account.transferAmount ?? params["amount"];
- const subject =
+ const qrReference =
option.type === "ch-qr-bill"
? option.qrReferenceNumber
- : params["message"];
+ : params["ch-qrr"];
+ const subject = qrReference || params["message"];
const qrCodes = option.qrCodes.filter((qr) => qr.qrContent);
if (option.type === "ch-qr-bill") {
qrCodes.sort(
@@ -203,9 +207,6 @@ export function wireOptions(
if (address)
fields.push({ label: i18n.str`Address`, value: address });
if (amount) fields.push({ label: i18n.str`Amount`, value: amount });
- if (subject)
- // Translators: Subject or remittance reference for a bank transfer.
- fields.push({ label: i18n.str`Payment reference`, value: subject });
return {
id: `${accountIndex}-${optionIndex}`,
label:
@@ -219,6 +220,10 @@ export function wireOptions(
: Paytos.getTargetLabel(parsed))),
...(account.bankLabel ? { bankLabel: account.bankLabel } : {}),
fields,
+ reference: subject
+ ? { value: subject, isSwissQr: Boolean(qrReference) }
+ : undefined,
+ transferAmount: amount,
paytoUri: option.paytoUri,
qrCodes,
...common,
diff --git a/packages/wallet-webui/src/screens/WireTransferScreen.tsx b/packages/wallet-webui/src/screens/WireTransferScreen.tsx
@@ -1,11 +1,84 @@
import { useEffect, useState } from "preact/hooks";
-import type { WireOptionView } from "../routes/withdrawal-model.js";
+import type {
+ WireFieldView,
+ WireOptionView,
+} from "../routes/withdrawal-model.js";
import { Button } from "../ui/Button.js";
import { Card } from "../ui/Card.js";
import { QrFrame } from "../ui/QrFrame.js";
import { OverflowMenu } from "../ui/OverflowMenu.js";
import { i18n } from "../i18n/runtime.js";
+function WireInstructions(props: {
+ option: WireOptionView;
+ transferAmount: string;
+ isKycAuth: boolean;
+ copiedValue?: string;
+ onCopy: (value: string) => void;
+}) {
+ const { fields, reference } = props.option;
+ const showSteps = !props.isKycAuth && !!reference;
+ function fieldRow({ label, value }: WireFieldView) {
+ return (
+ <div key={label}>
+ <dt class="text-sm text-secondary">{label}</dt>
+ <dd class="mt-1 flex items-start justify-between gap-3">
+ <span class="whitespace-pre-line break-all font-medium">{value}</span>
+ <button
+ type="button"
+ onClick={() => props.onCopy(value)}
+ class="shrink-0 rounded-full px-3 py-1 text-sm font-semibold text-primary hover:bg-primaryContainer"
+ >
+ {props.copiedValue === value ? i18n.str`Copied` : i18n.str`Copy`}
+ </button>
+ </dd>
+ </div>
+ );
+ }
+ return (
+ <div class="space-y-4">
+ <h4 class="text-lg font-semibold">{i18n.str`Wire transfer instructions`}</h4>
+ <p class="text-sm text-secondary">
+ {showSteps
+ ? i18n.str`Step 1. In your banking app or website, select the saved recipient or copy the recipient and account details below. Enter the amount shown.`
+ : i18n.str`Copy these details exactly into your banking app. The payment reference is required.`}
+ </p>
+ {fields.length > 0 && <dl class="space-y-4">{fields.map(fieldRow)}</dl>}
+ {showSteps && (
+ <>
+ <p class="text-sm text-secondary">
+ {reference.isSwissQr
+ ? i18n.str`Step 2. Copy this number into the QR reference field in your banking app or website.`
+ : i18n.str`Step 2. Copy this code into the subject or payment reference field in your banking app or website.`}
+ </p>
+ <p
+ role="note"
+ class="rounded-xl bg-warningContainer p-3 text-sm font-medium text-onWarningContainer"
+ >
+ {i18n.str`The reference is mandatory. Without it, your money will not arrive in this wallet.`}
+ </p>
+ </>
+ )}
+ {reference && (
+ <dl>
+ {fieldRow({
+ label:
+ reference.isSwissQr && !props.isKycAuth
+ ? i18n.str`QR reference`
+ : i18n.str`Payment reference`,
+ value: reference.value,
+ })}
+ </dl>
+ )}
+ {showSteps && (
+ <p class="text-sm text-secondary">{
+ /* Translators: %1$s is the amount to send from the bank account. */ i18n.str`Step 3. Confirm the transfer of ${props.transferAmount} in your banking app or website. The withdrawal will continue automatically. Depending on your bank, this can take from a few minutes to two working days.`
+ }</p>
+ )}
+ </div>
+ );
+}
+
export function WireTransferScreen(props: {
amountRaw: string;
amountEffective: string;
@@ -44,6 +117,7 @@ export function WireTransferScreen(props: {
props.options.findIndex((option) => option.id === selectedOptionId),
);
const activeOption = props.options[activeOptionIndex];
+ const transferAmount = activeOption?.transferAmount ?? props.amountRaw;
const copy = (optionId: string, value: string) => {
props.onCopy(value);
setCopied({ optionId, value });
@@ -91,9 +165,9 @@ export function WireTransferScreen(props: {
</Card>
) : (
<Card class="text-center">
- <p class="text-3xl font-semibold">{props.amountRaw}</p>
- {/* Translators: %1$s is the effective digital-cash amount after fees. */}
- <p class="mt-2 text-secondary">{i18n.str`Transfer this amount to receive ${props.amountEffective} as digital cash.`}</p>
+ <p class="text-3xl font-semibold">{transferAmount}</p>
+ {/* Translators: %1$s is the amount to send by bank transfer, %2$s is the digital cash received after fees. */}
+ <p class="mt-2 text-secondary">{i18n.str`Transfer ${transferAmount} from your regular bank account to the exchange to receive ${props.amountEffective} as digital cash in this wallet.`}</p>
</Card>
)}
{props.options.length === 0 ? (
@@ -287,36 +361,20 @@ export function WireTransferScreen(props: {
})}
</section>
)}
- {!blockedReason && option.fields.length > 0 && (
- <div>
- <h4 class="text-lg font-semibold">{i18n.str`Wire transfer instructions`}</h4>
- {/* Translators: The payment reference identifies this bank transfer to the exchange. */}
- <p class="mt-2 text-sm text-secondary">{i18n.str`Copy these details exactly into your banking app. The payment reference is required.`}</p>
- <dl class="mt-5 space-y-5">
- {option.fields.map((field) => (
- <div key={`${field.label}-${field.value}`}>
- <dt class="text-sm text-secondary">
- {field.label}
- </dt>
- <dd class="mt-1 flex items-start justify-between gap-3">
- <span class="whitespace-pre-line break-all font-medium">
- {field.value}
- </span>
- <button
- type="button"
- onClick={() => copy(option.id, field.value)}
- class="shrink-0 rounded-full px-3 py-1 text-sm font-semibold text-primary hover:bg-primaryContainer"
- >
- {wasCopied(option.id, field.value)
- ? i18n.str`Copied`
- : i18n.str`Copy`}
- </button>
- </dd>
- </div>
- ))}
- </dl>
- </div>
- )}
+ {!blockedReason &&
+ (option.fields.length > 0 || option.reference) && (
+ <WireInstructions
+ option={option}
+ transferAmount={transferAmount}
+ isKycAuth={isKycAuth}
+ copiedValue={
+ copied?.optionId === option.id
+ ? copied.value
+ : undefined
+ }
+ onCopy={(value) => copy(option.id, value)}
+ />
+ )}
</Card>
</div>
);
diff --git a/packages/wallet-webui/test/screens.test.tsx b/packages/wallet-webui/test/screens.test.tsx
@@ -3439,7 +3439,7 @@ test("wire instructions tab between options and copy the mandatory subject and p
};
let copied = "";
const paytoUri =
- "payto://iban/CH680857?amount=CHF%3A11.23&message=RESERVE123";
+ "payto://iban/CH680857?amount=EUR%3A12&message=RESERVE123";
const view = render(
<main>
<WireTransferScreen
@@ -3451,10 +3451,9 @@ test("wire instructions tab between options and copy the mandatory subject and p
id: "bank",
label: "Bank transfer details",
paytoUri,
- fields: [
- { label: "IBAN", value: "CH68 0857" },
- { label: "Payment reference", value: "RESERVE123" },
- ],
+ transferAmount: "EUR:12",
+ fields: [{ label: "IBAN", value: "CH68 0857" }],
+ reference: { value: "RESERVE123", isSwissQr: false },
},
{
id: "app",
@@ -3475,6 +3474,18 @@ test("wire instructions tab between options and copy the mandatory subject and p
document: window.document as unknown as Document,
});
assert(view.getByRole("heading", { name: "Bank transfer details" }));
+ assert(
+ view.getByText(
+ /Transfer EUR:12 from your regular bank account .* receive CHF:10/,
+ ),
+ );
+ assert(view.getByText(/Step 1.*recipient and account/));
+ assert(view.getByText(/Step 2.*subject or payment reference/));
+ assert.match(
+ view.getByRole("note").textContent ?? "",
+ /mandatory.*will not arrive/,
+ );
+ assert(view.getByText(/Step 3.*EUR:12.*automatically.*two working days/));
assert.equal(view.queryByRole("heading", { name: "Banking app" }), null);
assert.equal(view.getAllByRole("tab").length, 2);
await user.click(view.getAllByRole("button", { name: "Copy" })[1]);
@@ -3498,6 +3509,7 @@ test("wire instructions tab between options and copy the mandatory subject and p
null,
);
assert(view.getByRole("button", { name: "Open banking app" }));
+ assert.equal(view.queryByText(/Step 2/), null);
const result = await axe.run(window.document.body as unknown as Element);
assert.deepEqual(result.violations, []);
cleanup();
@@ -3517,7 +3529,8 @@ test("wire instructions become unavailable when their expiry is reached", async
{
id: "bank",
label: "Bank transfer",
- fields: [{ label: "Payment reference", value: "RESERVE123" }],
+ fields: [],
+ reference: { value: "RESERVE123", isSwissQr: false },
paytoUri: "payto://iban/CH680857?message=RESERVE123",
qrCodes: [{ type: "spc", qrContent: "SPC\n0200\n1" }],
externalUri: "https://bank.example/transfer/ABC",
@@ -3555,7 +3568,8 @@ test("wire instructions explain and disable an incompatible source account", asy
{
id: "restricted",
label: "Restricted exchange account",
- fields: [{ label: "Payment reference", value: "KYC123" }],
+ fields: [],
+ reference: { value: "KYC123", isSwissQr: false },
restrictionHints: [
"Only transfers from account CH12 are accepted.",
],
@@ -4230,7 +4244,11 @@ test("all available bank QR codes are shown with their format and only the Swiss
{
id: "swiss",
label: "Swiss QR bill",
- fields: [],
+ fields: [{ label: "IBAN", value: "CH4431999123000889012" }],
+ reference: {
+ value: "210000000003139471430009017",
+ isSwissQr: true,
+ },
qrCodes: [
{ type: "spc", qrContent: "SPC\n0200\n1" },
{ type: "epc-qr", qrContent: "BCD\n002" },
@@ -4257,6 +4275,7 @@ test("all available bank QR codes are shown with their format and only the Swiss
.parentElement?.getAttribute("data-qr-style"),
"epc-payment",
);
+ assert(view.getByText(/Step 2.*QR reference field/));
cleanup();
await window.happyDOM.abort();
});
@@ -4336,6 +4355,10 @@ test("deposit KYC authentication identifies the source and keeps all transfer op
fields: [{ label: "Amount", value: "CHF:0.01" }],
paytoUri: "payto://iban/CH4431999123000889012?amount=CHF%3A0.01",
qrCodes: [{ type: "spc", qrContent: "SPC\n0200\n1" }],
+ reference: {
+ value: "210000000003139471430009017",
+ isSwissQr: true,
+ },
},
{
id: "app",
@@ -4351,6 +4374,8 @@ test("deposit KYC authentication identifies the source and keeps all transfer op
</main>,
);
assert(view.getByRole("heading", { name: "Verify bank account" }));
+ assert.equal(view.queryByText(/Step 3/), null);
+ assert(view.getByText(/Copy these details exactly/));
assert(view.getByText("payto://iban/CH5210395CX7GTDCRC3C4"));
assert.equal(view.getAllByRole("tab").length, 2);
assert.equal(
diff --git a/packages/wallet-webui/test/withdrawal-model.test.ts b/packages/wallet-webui/test/withdrawal-model.test.ts
@@ -51,12 +51,11 @@ test("wire options expose accepted post-reserve transfer details", () => {
(field) => field.label === "IBAN" && field.value.includes("CH68"),
),
);
- assert(
- options[0].fields.some(
- (field) =>
- field.label === "Payment reference" && field.value === "RESERVE123",
- ),
- );
+ assert.deepEqual(options[0].reference, {
+ value: "RESERVE123",
+ isSwissQr: false,
+ });
+ assert.equal(options[0].transferAmount, "CHF:11.23");
assert(
options[0].fields.some(
(field) => field.label === "Amount" && field.value === "CHF:11.23",
@@ -255,13 +254,10 @@ test("Swiss QR bill options keep every supplied code and put the SPC code first"
{ type: "spc", qrContent: "SPC\n0200\n1" },
{ type: "epc-qr", qrContent: "BCD\n002" },
]);
- assert(
- option.fields.some(
- (field) =>
- field.label === "Payment reference" &&
- field.value === "210000000003139471430009017",
- ),
- );
+ assert.deepEqual(option.reference, {
+ value: "210000000003139471430009017",
+ isSwissQr: true,
+ });
});
test("deposit KYC authentication preserves every account transfer method", () => {