commit 73eda74c408a1bd2b34ccf206e91213744836a94
parent 71b113f3632b77b8ccd3215fc211c4fbe0219180
Author: Florian Dold <dold@taler.net>
Date: Thu, 26 Nov 2026 00:19:17 +0100
wallet web UI: keep payment review visible until the redirect
Keep the amount and choices on screen while the pay button shows
progress. If the redirect fails, let the customer open the merchant page
without submitting the payment again.
Issue: https://bugs.taler.net/n/10644
Diffstat:
3 files changed, 187 insertions(+), 39 deletions(-)
diff --git a/packages/wallet-webui/src/routes/App.tsx b/packages/wallet-webui/src/routes/App.tsx
@@ -4428,24 +4428,10 @@ function PaymentRoute({
onReclaim={() => void actions.reclaim()}
/>
);
- if (transaction.txState.major === TransactionMajorState.Dialog && !paymentDone)
- return (
- <PaymentDialog
- view={view}
- contract={contract}
- transactionId={transaction.transactionId}
- actionId={actionId}
- actions={actions}
- error={actionError}
- cancelling={cancelling}
- onCancel={() => void cancelPayment()}
- onBack={completeAndReturn}
- />
- );
const returning =
browserCheckout &&
fulfillmentTarget === "current-tab" &&
- resultState === "paid-elsewhere" &&
+ paymentDone &&
safeWebUrl(fulfillmentUrl) &&
!navigationFailed;
const statusTransaction = repurchaseTransactionId
@@ -4465,6 +4451,27 @@ function PaymentRoute({
!replayPayment
? localError(i18n.str`The payment transaction is unavailable.`)
: undefined;
+ if (
+ (transaction.txState.major === TransactionMajorState.Dialog &&
+ !paymentDone) ||
+ (browserCheckout && resultState === "pending" && !repurchaseError) ||
+ (returning && resultState === "done")
+ )
+ return (
+ <PaymentDialog
+ processing={transaction.txState.major !== TransactionMajorState.Dialog}
+ returning={returning}
+ view={view}
+ contract={contract}
+ transactionId={transaction.transactionId}
+ actionId={actionId}
+ actions={actions}
+ error={actionError}
+ cancelling={cancelling}
+ onCancel={() => void cancelPayment()}
+ onBack={completeAndReturn}
+ />
+ );
const terminalError =
resultState === "error"
? (transactionErrorPresentation(statusTransaction, statusFallback) ??
@@ -4549,6 +4556,8 @@ function PaymentRoute({
}
function PaymentDialog(props: {
+ processing?: boolean;
+ returning?: boolean;
view: TransactionObservationView;
contract: PaymentContractView;
actions: PaymentActions;
@@ -4561,7 +4570,24 @@ function PaymentDialog(props: {
}) {
const { view, contract, actions } = props;
const [, navigate] = useLocation();
- const { review, recovery } = actions;
+ const { recovery } = actions;
+ // The core stops offering choices once coins are committed. Retain the
+ // approved order for display only. Confirmation still uses the live snapshot.
+ const lastReview =
+ useRef<Pick<PaymentActions, "review" | "selectedChoice" | "useDonau">>();
+ if (actions.review && !props.processing) {
+ lastReview.current = {
+ review: actions.review,
+ selectedChoice: actions.selectedChoice,
+ useDonau: actions.useDonau,
+ };
+ }
+ const { review, selectedChoice, useDonau } =
+ (props.processing && lastReview.current) || actions;
+ const transaction =
+ view.snapshot?.type === TransactionType.Payment
+ ? view.snapshot.transaction
+ : undefined;
const loadError = view.error ?? contract.error;
const onRetry = view.canRetry
? view.retry
@@ -4571,25 +4597,30 @@ function PaymentDialog(props: {
return (
<PaymentScreen
state={
- !review
- ? loadError
- ? "error"
- : "loading"
- : actions.confirming
- ? "paying"
- : "ready"
+ props.processing
+ ? "paying"
+ : !review
+ ? loadError
+ ? "error"
+ : "loading"
+ : actions.confirming
+ ? "paying"
+ : "ready"
}
+ processing={props.processing}
+ returning={props.returning}
+ paidAmount={transaction?.amountRaw}
onRetryObservation={onRetry}
confirmDisabled={!actions.canConfirm || props.cancelling}
- merchantName={review?.merchantName}
+ merchantName={review?.merchantName ?? transaction?.info?.merchant.name}
merchantWebsite={review?.merchantWebsite}
merchantAddress={review?.merchantAddress}
merchantLogo={review?.merchantLogo}
- summary={review?.summary}
+ summary={review?.summary ?? transaction?.info?.summary}
order={review?.order}
minimumAge={review?.minimumAge}
choices={review?.choices}
- selectedChoice={actions.selectedChoice}
+ selectedChoice={selectedChoice}
error={
props.error ??
(loadError
@@ -4611,7 +4642,7 @@ function PaymentDialog(props: {
)
: undefined
}
- useDonau={actions.useDonau}
+ useDonau={useDonau}
cancelling={props.cancelling}
unclaiming={actions.unclaiming}
reclaiming={actions.reclaiming}
diff --git a/packages/wallet-webui/src/screens/PaymentScreen.tsx b/packages/wallet-webui/src/screens/PaymentScreen.tsx
@@ -167,6 +167,9 @@ export type PaymentScreenState =
export function PaymentOptions(props: {
state: "ready" | "paying";
+ onBack?: () => void;
+ returning?: boolean;
+ paidAmount?: string;
choices?: PaymentChoiceView[];
selectedChoice?: number;
useDonau?: boolean;
@@ -201,6 +204,7 @@ export function PaymentOptions(props: {
class={`flex cursor-pointer gap-3 rounded-2xl border bg-surface p-4 ${choice.index === props.selectedChoice ? "border-primary ring-2 ring-primary" : "border-outlineVariant"} ${choice.payable ? "" : "opacity-70"}`}
>
<input
+ disabled={props.state === "paying"}
type="radio"
name="payment-choice"
value={choice.index}
@@ -278,6 +282,7 @@ export function PaymentOptions(props: {
{selected.donationReceipt.status === "available" ? (
<label class="mt-3 flex min-h-11 cursor-pointer items-center gap-3">
<input
+ disabled={props.state === "paying"}
type="checkbox"
checked={props.useDonau === true}
onChange={(event) =>
@@ -304,6 +309,7 @@ export function PaymentOptions(props: {
<div class="mt-4">
<Button
tone="secondary"
+ disabled={props.state === "paying"}
onClick={() =>
props.onConfigureDonau!(
selected.donationReceipt!.donauUrls[0],
@@ -317,6 +323,11 @@ export function PaymentOptions(props: {
</Card>
)}
+ {!selected && props.state === "paying" && props.paidAmount && (
+ <Card>
+ <p class="text-2xl font-medium">{props.paidAmount}</p>
+ </Card>
+ )}
{(props.unclaiming || props.reclaiming) && (
<p role="status" class="text-sm text-secondary">
{props.reclaiming
@@ -347,11 +358,17 @@ export function PaymentOptions(props: {
: /* Translators: Release the merchant order so another wallet can claim and pay it; no money is sent between wallets. */ i18n.str`Continue with another wallet`}
</Button>
)}
+ {props.onBack && (
+ <Button
+ tone="secondary"
+ onClick={props.onBack}
+ >{i18n.str`Back to wallet`}</Button>
+ )}
{props.onCancel && (
<Button
tone="secondary"
onClick={props.onCancel}
- disabled={props.cancelling}
+ disabled={props.cancelling || props.state === "paying"}
>
{props.cancelling ? i18n.str`Cancelling…` : i18n.str`Cancel`}
</Button>
@@ -378,12 +395,16 @@ export function PaymentOptions(props: {
props.reclaiming
}
>
- {props.state === "paying"
- ? i18n.str`Paying…`
- : selected
- ? // Translators: Button label; the placeholder is a fully formatted payment amount.
- i18n.str`Pay ${selected.amountRaw}`
- : i18n.str`Pay`}
+ <span aria-live="polite">
+ {props.state === "paying"
+ ? props.returning
+ ? i18n.str`Returning to merchant…`
+ : i18n.str`Paying…`
+ : selected
+ ? // Translators: Button label; the placeholder is a fully formatted payment amount.
+ i18n.str`Pay ${selected.amountRaw}`
+ : i18n.str`Pay`}
+ </span>
</Button>
</div>
</>
@@ -466,7 +487,9 @@ export function PaymentLoading(props: {
export function PaymentScreen(props: {
state: PaymentScreenState;
+ processing?: boolean;
returning?: boolean;
+ paidAmount?: string;
merchantName?: string;
merchantWebsite?: string;
merchantAddress?: string;
@@ -516,11 +539,14 @@ export function PaymentScreen(props: {
return (
<div class="mx-auto max-w-2xl space-y-5">
<div class="flex items-center gap-4">
- {(props.state === "ready" || props.state === "error") && (
+ {(props.state === "ready" ||
+ props.state === "error" ||
+ props.state === "paying") && (
<button
type="button"
onClick={props.onBack}
aria-label={i18n.str`Back to wallet`}
+ disabled={props.state === "paying"}
class="grid h-11 w-11 place-items-center rounded-full text-2xl hover:bg-secondaryContainer"
>
←
@@ -628,6 +654,9 @@ export function PaymentScreen(props: {
}
/>
<PaymentOptions
+ paidAmount={props.paidAmount}
+ returning={props.returning}
+ onBack={props.processing ? props.onBack : undefined}
state={props.state}
confirmDisabled={props.confirmDisabled}
choices={props.choices}
@@ -643,7 +672,7 @@ export function PaymentScreen(props: {
onWithdraw={props.onWithdraw}
recoveryActionLabel={props.recoveryActionLabel}
onRecoveryAction={props.onRecoveryAction}
- onCancel={props.onCancel}
+ onCancel={props.processing ? undefined : props.onCancel}
onKeepHere={props.onKeepHere}
onUnclaim={
props.onUnclaim ? () => setConfirmUnclaim(true) : undefined
diff --git a/packages/wallet-webui/test/transaction-observation-routes.test.tsx b/packages/wallet-webui/test/transaction-observation-routes.test.tsx
@@ -623,6 +623,47 @@ test("checkout waits for external payment and navigates once", async () => {
}
});
+test("a failed merchant redirect exposes a manual retry without resubmitting", async () => {
+ const url = "https://merchant.example/fulfilled";
+ const h = await harness("payment-review", url);
+ try {
+ await h.waitFor(() => assert.equal(h.registrations.length, 1));
+ let fail!: () => void;
+ const gate = new Promise<void>((_, reject) => {
+ fail = () => reject(Error("tab closed"));
+ });
+ let attempts = 0;
+ h.services.platform.openExternal = async (target) => {
+ assert.equal(target, url);
+ if (++attempts === 1) await gate;
+ };
+ const initial = h.readySnapshot;
+ assert.ok(initial.type === TransactionType.Payment);
+ const done = {
+ ...initial,
+ transaction: {
+ ...initial.transaction,
+ txState: { major: TransactionMajorState.Done },
+ },
+ payment: null,
+ };
+ await h.act(async () => h.publish(done));
+ await h.waitFor(() => assert.equal(attempts, 1));
+ assert.equal(h.view.queryByText("Continue to merchant"), null);
+ await h.act(async () => fail());
+ await h.waitFor(() => assert.ok(h.view.getByText("Payment complete")));
+ await h.act(async () => h.publish(done));
+ assert.equal(attempts, 1);
+ await h.act(async () =>
+ h.view.getByRole("button", { name: "Continue to merchant" }).click(),
+ );
+ assert.equal(attempts, 2);
+ assert.equal(h.paymentRequests.length, 0);
+ } finally {
+ await h.close();
+ }
+});
+
test("an equivalent payment in another session cannot redirect this checkout", async () => {
const url = "https://merchant.example/fulfilled";
const h = await harness("payment-review", url);
@@ -661,6 +702,49 @@ test("an equivalent payment in another session cannot redirect this checkout", a
}
});
+test("leaving a pending checkout keeps the merchant from taking the tab later", async () => {
+ const h = await harness(
+ "payment-review",
+ "https://merchant.example/fulfilled",
+ );
+ try {
+ const initial = h.readySnapshot;
+ assert.ok(initial.type === TransactionType.Payment);
+ await h.act(async () => h.releaseDocument());
+ await h.waitFor(() => assert.ok(h.view.getByText("Review payment")));
+ const heading = h.view.getByText("Review payment");
+ const pending: TransactionSnapshot = {
+ ...initial,
+ transaction: {
+ ...initial.transaction,
+ txState: { major: TransactionMajorState.Pending },
+ },
+ payment: null,
+ confirmation: { unavailableReasons: ["not-proposed"] },
+ };
+ await h.act(async () => h.publish(pending));
+ await h.waitFor(() => assert.ok(h.view.getByText("Paying…")));
+ assert.equal(h.view.getByText("Review payment"), heading);
+ assert.equal(h.view.queryByText("Payment submitted"), null);
+ await h.act(async () => h.view.getByText("Back to wallet").click());
+ await h.waitFor(() =>
+ assert.ok(h.view.getByRole("heading", { name: "Balances" })),
+ );
+ await h.act(async () =>
+ h.publish({
+ ...initial,
+ transaction: {
+ ...initial.transaction,
+ txState: { major: TransactionMajorState.Done },
+ },
+ }),
+ );
+ assert.deepEqual(h.navigations, []);
+ } finally {
+ await h.close();
+ }
+});
+
test("a failed claim observation shows retry despite retained claim progress", async () => {
const h = await harness("payment-claim");
try {
@@ -1197,7 +1281,9 @@ for (const route of ["payment-review", "payment-review-details"] as const) {
await h.waitFor(() =>
assert.ok(
h.view.getByText(
- route === "payment-review" ? "Payment complete" : "Completed",
+ route === "payment-review"
+ ? "Returning to merchant…"
+ : "Completed",
),
),
);
@@ -1206,7 +1292,9 @@ for (const route of ["payment-review", "payment-review-details"] as const) {
await h.waitFor(() =>
assert.ok(
h.view.getByText(
- route === "payment-review" ? "Payment complete" : "Completed",
+ route === "payment-review"
+ ? "Returning to merchant…"
+ : "Completed",
),
),
);
@@ -1556,7 +1644,7 @@ test("checkout follows observed suspension and resume without changing status on
},
}),
);
- await h.waitFor(() => assert.ok(h.view.getByText("Payment submitted")));
+ await h.waitFor(() => assert.ok(h.view.getByText("Paying…")));
assert.equal(h.view.queryByText("Payment paused"), null);
assert.deepEqual(h.completions, []);
} finally {