commit 317b13baf6842d187061c18843a6cd29e746b982
parent dc88d69fc8324eda41c0a9d6765c0c7576ae10c5
Author: Florian Dold <dold@taler.net>
Date: Thu, 26 Nov 2026 04:15:27 +0100
wallet-webui: explain what to do with peer, refund and contact links
A peer request that hit a network error offered to withdraw funds. Let
the payer retry the lookup, point a refund with no matching purchase
back to the wallet that paid, and explain when a contact link is
unsupported.
Diffstat:
6 files changed, 113 insertions(+), 13 deletions(-)
diff --git a/packages/wallet-webui/src/routes/App.tsx b/packages/wallet-webui/src/routes/App.tsx
@@ -2354,11 +2354,16 @@ function PeerPreparation({ actionId }: { actionId: string }) {
const { controller: progressRequest } = useWalletProgress(connection);
const [prepared, setPrepared] = useState<PreparedPeerPayment>();
const [kind, setKind] = useState<"receive" | "pay">("receive");
+ const [attempt, setAttempt] = useState(0);
+ const [retryable, setRetryable] = useState(false);
const [loading, setLoading] = useState(true);
const [cancelling, setCancelling] = useState(false);
const [error, setError] = useState<ErrorPresentation>();
useEffect(() => {
let active = true;
+ setLoading(true);
+ setError(undefined);
+ setRetryable(false);
void (async () => {
try {
const entry = await platform.actionInbox.get(actionId);
@@ -2376,6 +2381,7 @@ function PeerPreparation({ actionId }: { actionId: string }) {
throw Error(
/* Translators: Peer payments transfer digital cash between people using links. A shared link can offer money to receive or request money to be paid. */ i18n.str`This is not a supported peer payment link.`,
);
+ setRetryable(true);
if (parsed.value.type === TalerUriAction.PayPush) {
setKind("receive");
const result = await progressRequest.callAndInvalidate(
@@ -2418,7 +2424,9 @@ function PeerPreparation({ actionId }: { actionId: string }) {
});
}
} catch (cause) {
- if (active && !isProgressRequestCancelled(cause))
+ if (active && isProgressRequestCancelled(cause)) {
+ setError(localError(i18n.str`Payment lookup cancelled.`));
+ } else if (active)
setError(
errorFromException(
cause,
@@ -2432,7 +2440,7 @@ function PeerPreparation({ actionId }: { actionId: string }) {
return () => {
active = false;
};
- }, [actionId, platform, progressRequest]);
+ }, [actionId, platform, progressRequest, attempt]);
const cancel = async () => {
if (cancelling) return;
if (prepared) {
@@ -2493,6 +2501,15 @@ function PeerPreparation({ actionId }: { actionId: string }) {
working={false}
cancelling={cancelling}
error={error}
+ onRetryPreparation={
+ retryable &&
+ error &&
+ error.detail?.code !==
+ TalerErrorCode.WALLET_PEER_PULL_DEBIT_PURSE_GONE &&
+ error.detail?.code !== TalerErrorCode.WALLET_PEER_PUSH_CREDIT_PURSE_GONE
+ ? () => setAttempt((n) => n + 1)
+ : undefined
+ }
onConfirm={() => {}}
onCancel={shared.onCancel}
onWithdraw={() => navigate("/withdraw")}
@@ -3484,7 +3501,8 @@ function ActionRoute() {
state === "ready" &&
parsed &&
Result.isOk(parsed) &&
- parsed.value.type === TalerUriAction.Restore
+ (parsed.value.type === TalerUriAction.Restore ||
+ parsed.value.type === TalerUriAction.AddContact)
? `error`
: state
}
@@ -3510,7 +3528,9 @@ function ActionRoute() {
? withdrawalTransferResultHint(parsed.value.status)
: parsed.value.type === TalerUriAction.Restore
? restoreActionGateReason()
- : undefined
+ : parsed.value.type === TalerUriAction.AddContact
+ ? i18n.str`This wallet cannot add contacts from a link.`
+ : undefined
: undefined)
}
continueLabel={
diff --git a/packages/wallet-webui/src/routes/RefundActionRoute.tsx b/packages/wallet-webui/src/routes/RefundActionRoute.tsx
@@ -7,6 +7,7 @@
import {
Amounts,
Result,
+ TalerErrorCode,
type GetRefundDetailsForUriResponse,
} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
@@ -122,11 +123,20 @@ export function RefundActionRoute({
}
if (error) {
+ const missingPurchase =
+ error.detail?.code === TalerErrorCode.WALLET_PURCHASE_NOT_FOUND;
return (
<ActionScreen
state="error"
- error={error}
- onRetry={() => setAttempt((n) => n + 1)}
+ error={
+ missingPurchase
+ ? {
+ ...error,
+ message: i18n.str`This wallet has no matching purchase. Open the refund link in the wallet that made the payment.`,
+ }
+ : error
+ }
+ onRetry={missingPurchase ? undefined : () => setAttempt((n) => n + 1)}
onBack={() => navigate("/")}
onDiscard={onCancel}
onCancel={onCancel}
diff --git a/packages/wallet-webui/src/screens/PeerReceiveScreen.tsx b/packages/wallet-webui/src/screens/PeerReceiveScreen.tsx
@@ -17,6 +17,7 @@ export function PeerReceiveScreen(props: {
exchange?: string;
error?: ErrorPresentation;
onRetryObservation?: () => void;
+ onRetryPreparation?: () => void;
confirmDisabled?: boolean;
blockedReason?: string;
blockedActionLabel?: string;
@@ -26,9 +27,9 @@ export function PeerReceiveScreen(props: {
onWithdraw: () => void;
}) {
const receive = props.kind === "receive";
- const requestGone =
+ const insufficientFunds =
props.error?.detail?.code ===
- TalerErrorCode.WALLET_PEER_PULL_DEBIT_PURSE_GONE;
+ TalerErrorCode.WALLET_PEER_PULL_PAYMENT_INSUFFICIENT_BALANCE;
return (
<div class="mx-auto w-full max-w-2xl space-y-6">
<div class="flex items-center gap-4">
@@ -68,7 +69,12 @@ export function PeerReceiveScreen(props: {
onClick={props.onRetryObservation}
>{i18n.str`Retry updates`}</Button>
)}
- {!receive && !requestGone && (
+ {props.onRetryPreparation && (
+ <Button
+ onClick={props.onRetryPreparation}
+ >{i18n.str`Try again`}</Button>
+ )}
+ {!receive && insufficientFunds && (
<div class="mt-4">
<Button
tone="secondary"
diff --git a/packages/wallet-webui/test/payment-entry.test.tsx b/packages/wallet-webui/test/payment-entry.test.tsx
@@ -18,6 +18,13 @@ import assert from "node:assert/strict";
import test from "node:test";
import { register } from "node:module";
import { Window } from "happy-dom";
+import {
+ type CheckDepositResponse,
+ TalerError,
+ TalerErrorCode,
+ Result,
+ TemplateType,
+} from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import {
createDemoServices,
@@ -108,11 +115,12 @@ async function harness(
if (operation === WalletApiOperation.ConfirmPay) confirms++;
return original(operation, request);
};
- const view = render(
+ const wallet = (adapter = platform) => (
<SWRConfig value={{ provider: () => new Map(), shouldRetryOnError: false }}>
- <App {...services} platform={platform} />
- </SWRConfig>,
+ <App {...services} platform={adapter} />
+ </SWRConfig>
);
+ const view = render(wallet());
const waitFor = async (check: () => void) => {
for (let n = 0; ; n++) {
await act(async () => {
@@ -128,6 +136,11 @@ async function harness(
};
return {
view,
+ services,
+ remount: async () => {
+ await act(() => view.rerender(<></>));
+ await act(() => view.rerender(wallet(makePwaPlatform())));
+ },
act,
waitFor,
pasteLink: async (uri: string) => {
@@ -288,3 +301,46 @@ test("leaving payment preparation cannot navigate back to review", async () => {
await h.close();
}
});
+
+test("unsupported contact links explain the limitation when opened", async () => {
+ const h = await harness("paste");
+ try {
+ await h.pasteLink(
+ "taler://add-contact/email/bob@example.com/mailbox.example.com/mb/" +
+ "1".repeat(52),
+ );
+ await h.waitFor(() =>
+ assert.match(
+ h.view.getByRole("alert").textContent ?? "",
+ /cannot add contacts/,
+ ),
+ );
+ assert.equal(h.view.queryByRole("button", { name: "Continue" }), null);
+ } finally {
+ await h.close();
+ }
+});
+
+test("a refund missing its purchase directs the payer to their original wallet", async () => {
+ const h = await harness("paste");
+ const original = h.services.connection.client.call;
+ h.services.connection.client.call = async (op, req) => {
+ if (op === WalletApiOperation.GetRefundDetailsForUri)
+ throw TalerError.fromUncheckedDetail({
+ code: TalerErrorCode.WALLET_PURCHASE_NOT_FOUND,
+ });
+ return original(op, req);
+ };
+ try {
+ await h.pasteLink("taler://refund/shop.example/order/");
+ await h.waitFor(() =>
+ assert.match(
+ h.view.getByRole("alert").textContent ?? "",
+ /wallet that made the payment/,
+ ),
+ );
+ assert.equal(h.view.queryByRole("button", { name: "Retry" }), null);
+ } finally {
+ await h.close();
+ }
+});
diff --git a/packages/wallet-webui/test/peer-credit-observation.test.tsx b/packages/wallet-webui/test/peer-credit-observation.test.tsx
@@ -430,7 +430,7 @@ test("preparation values stay hidden until the first snapshot, and deletion neve
}
});
-test("preparation failure stays in preparation without registering an observer", async () => {
+test("failed preparation can retry before starting observation", async () => {
const h = await harness("paste", "failure");
try {
await h.waitFor(() => assert.equal(h.counts().prepares, 1));
@@ -439,6 +439,13 @@ test("preparation failure stays in preparation without registering an observer",
h.calls.includes(WalletApiOperation.ObserveTransaction),
false,
);
+ await h.act(() =>
+ h.view.getByRole("button", { name: "Try again" }).click(),
+ );
+ await h.waitFor(() =>
+ assert(h.calls.includes(WalletApiOperation.ObserveTransaction)),
+ );
+ assert.deepEqual(h.counts(), { prepares: 2, confirms: 0 });
} finally {
await h.close();
}
diff --git a/packages/wallet-webui/test/screens.test.tsx b/packages/wallet-webui/test/screens.test.tsx
@@ -3025,6 +3025,7 @@ test("peer requests offer withdrawal for insufficient funds and hide it for a go
for (const [code, showWithdraw] of [
[TalerErrorCode.WALLET_PEER_PULL_PAYMENT_INSUFFICIENT_BALANCE, true],
[TalerErrorCode.WALLET_PEER_PULL_DEBIT_PURSE_GONE, false],
+ [TalerErrorCode.WALLET_NETWORK_ERROR, false],
] as const) {
const view = render(
<PeerReceiveScreen