commit 6d4326029d52d1947d3dca79b0382a5718b8621d
parent fe400a8ea8e6be287cf2654d9c512301770b2f2f
Author: Sebastian <sebasjm@taler-systems.com>
Date: Thu, 4 Jun 2026 14:51:56 -0300
fix breaking change: PreparePayForUri now can return a payment without order info
Diffstat:
7 files changed, 112 insertions(+), 100 deletions(-)
diff --git a/packages/taler-wallet-webextension/src/components/HistoryItem.tsx b/packages/taler-wallet-webextension/src/components/HistoryItem.tsx
@@ -104,8 +104,8 @@ export function HistoryItem(props: { tx: Transaction }): VNode {
href={Pages.balanceTransaction({ tid: tx.transactionId })}
amount={tx.amountEffective}
debitCreditIndicator={"debit"}
- title={tx.info.merchant.name}
- subtitle={tx.info.summary}
+ title={tx.info?.merchant.name ?? i18n.str`...`}
+ subtitle={tx.info?.summary ?? i18n.str`...`}
timestamp={AbsoluteTime.fromPreciseTimestamp(tx.timestamp)}
iconPath={"P"}
currentState={tx.txState.major}
diff --git a/packages/taler-wallet-webextension/src/cta/Refund/index.ts b/packages/taler-wallet-webextension/src/cta/Refund/index.ts
@@ -21,7 +21,7 @@ import { ErrorAlert } from "../../context/alert.js";
import { ButtonHandler } from "../../mui/handlers.js";
import { compose, StateViewMap } from "../../utils/index.js";
import { useComponentState } from "./state.js";
-import { IgnoredView, ReadyView } from "./views.js";
+import { IgnoredView, ReadyView, WaitingView } from "./views.js";
export interface Props {
talerRefundUri?: string;
@@ -31,6 +31,7 @@ export interface Props {
export type State =
| State.Loading
+ | State.Waiting
| State.LoadingUriError
| State.Ready
| State.Ignored;
@@ -54,6 +55,10 @@ export namespace State {
// granted: AmountJson;
}
+ export interface Waiting {
+ status: "waiting";
+ error: undefined;
+ }
export interface Ready extends BaseInfo {
status: "ready";
error: undefined;
@@ -68,17 +73,13 @@ export namespace State {
status: "ignored";
error: undefined;
}
- // export interface InProgress extends BaseInfo {
- // status: "in-progress";
- // error: undefined;
- // }
}
const viewMapping: StateViewMap<State> = {
loading: Loading,
error: ErrorAlertView,
- // "in-progress": InProgressView,
ignored: IgnoredView,
+ waiting: WaitingView,
ready: ReadyView,
};
diff --git a/packages/taler-wallet-webextension/src/cta/Refund/state.ts b/packages/taler-wallet-webextension/src/cta/Refund/state.ts
@@ -77,15 +77,13 @@ export function useComponentState({
),
};
}
- // if (info.hasError) {
- // return {
- // status: "loading-uri",
- // error: info,
- // };
- // }
const { refund, purchase, uri } = info.response;
+ if (!purchase.info) {
+ return { status: "waiting", error: undefined };
+ }
+
const doAccept = async (): Promise<void> => {
const res = await api.wallet.call(
WalletApiOperation.StartRefundQueryForUri,
diff --git a/packages/taler-wallet-webextension/src/cta/Refund/views.tsx b/packages/taler-wallet-webextension/src/cta/Refund/views.tsx
@@ -20,7 +20,6 @@ import { Amount } from "../../components/Amount.js";
import { Part } from "../../components/Part.js";
import { Button } from "../../mui/Button.js";
import { State } from "./index.js";
-import { TermsOfService } from "../../components/TermsOfService/index.js";
export function IgnoredView(state: State.Ignored): VNode {
const { i18n } = useTranslationContext();
@@ -35,38 +34,20 @@ export function IgnoredView(state: State.Ignored): VNode {
</Fragment>
);
}
-// export function InProgressView(state: State.InProgress): VNode {
-// const { i18n } = useTranslationContext();
+export function WaitingView(state: State.Waiting): VNode {
+ const { i18n } = useTranslationContext();
+
+ return (
+ <Fragment>
+ <section>
+ <p>
+ <i18n.Translate>Waiting information of the merchant and the purchase.</i18n.Translate>
+ </p>
+ </section>
+ </Fragment>
+ );
+}
-// return (
-// <Fragment>
-// <section>
-// <p>
-// <i18n.Translate>The refund is in progress.</i18n.Translate>
-// </p>
-// </section>
-// <section>
-// <Part
-// big
-// title={i18n.str`Total to refund`}
-// text={<Amount value={state.awaitingAmount} />}
-// kind="negative"
-// />
-// <Part
-// big
-// title={i18n.str`Refunded`}
-// text={<Amount value={state.amount} />}
-// kind="negative"
-// />
-// </section>
-// {state.products && state.products.length ? (
-// <section>
-// <ProductList products={state.products} />
-// </section>
-// ) : undefined}
-// </Fragment>
-// );
-// }
export function ReadyView(state: State.Ready): VNode {
const { i18n } = useTranslationContext();
return (
diff --git a/packages/taler-wallet-webextension/src/wallet/History.stories.tsx b/packages/taler-wallet-webextension/src/wallet/History.stories.tsx
@@ -284,11 +284,13 @@ export const SomeTransactions = tests.createExample(TestedComponent, {
exampleData.payment,
{
...exampleData.payment,
- info: {
- ...exampleData.payment.info,
- summary:
- "this is a long summary that may be cropped because its too long",
- },
+ info: !exampleData.payment.info
+ ? undefined
+ : {
+ ...exampleData.payment.info,
+ summary:
+ "this is a long summary that may be cropped because its too long",
+ },
},
exampleData.refund,
exampleData.deposit,
@@ -344,47 +346,57 @@ export const SomeTransactionsInDifferentStates = tests.createExample(
},
{
...exampleData.payment,
- info: {
- ...exampleData.payment.info,
- summary: "normal payment",
- },
+ info: !exampleData.payment.info
+ ? undefined
+ : {
+ ...exampleData.payment.info,
+ summary: "normal payment",
+ },
},
{
...exampleData.payment,
- info: {
- ...exampleData.payment.info,
- summary: "aborting in progress",
- },
+ info: !exampleData.payment.info
+ ? undefined
+ : {
+ ...exampleData.payment.info,
+ summary: "aborting in progress",
+ },
txState: {
major: TransactionMajorState.Aborting,
},
},
{
...exampleData.payment,
- info: {
- ...exampleData.payment.info,
- summary: "aborted payment",
- },
+ info: !exampleData.payment.info
+ ? undefined
+ : {
+ ...exampleData.payment.info,
+ summary: "aborted payment",
+ },
txState: {
major: TransactionMajorState.Aborted,
},
},
{
...exampleData.payment,
- info: {
- ...exampleData.payment.info,
- summary: "pending payment",
- },
+ info: !exampleData.payment.info
+ ? undefined
+ : {
+ ...exampleData.payment.info,
+ summary: "pending payment",
+ },
txState: {
major: TransactionMajorState.Pending,
},
},
{
...exampleData.payment,
- info: {
- ...exampleData.payment.info,
- summary: "failed payment",
- },
+ info: !exampleData.payment.info
+ ? undefined
+ : {
+ ...exampleData.payment.info,
+ summary: "failed payment",
+ },
txState: {
major: TransactionMajorState.Failed,
},
diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx
@@ -383,12 +383,14 @@ export const PaymentWithDeliveryDate = tests.createExample(TestedComponent, {
transaction: {
...exampleData.payment,
amountRaw: "KUDOS:12" as AmountString,
- info: {
- ...exampleData.payment.info,
- // delivery_date: {
- // t_s: new Date().getTime() / 1000,
- // },
- },
+ info: !exampleData.payment.info
+ ? undefined
+ : {
+ ...exampleData.payment.info,
+ // delivery_date: {
+ // t_s: new Date().getTime() / 1000,
+ // },
+ },
},
});
@@ -396,15 +398,17 @@ export const PaymentWithDeliveryAddr = tests.createExample(TestedComponent, {
transaction: {
...exampleData.payment,
amountRaw: "KUDOS:12" as AmountString,
- info: {
- ...exampleData.payment.info,
- // delivery_location: {
- // country: "Argentina",
- // street: "Elm Street",
- // district: "CABA",
- // post_code: "1101",
- // },
- },
+ info: !exampleData.payment.info
+ ? undefined
+ : {
+ ...exampleData.payment.info,
+ // delivery_location: {
+ // country: "Argentina",
+ // street: "Elm Street",
+ // district: "CABA",
+ // post_code: "1101",
+ // },
+ },
},
});
@@ -412,18 +416,20 @@ export const PaymentWithDeliveryFull = tests.createExample(TestedComponent, {
transaction: {
...exampleData.payment,
amountRaw: "KUDOS:12" as AmountString,
- info: {
- ...exampleData.payment.info,
- // delivery_date: {
- // t_s: new Date().getTime() / 1000,
- // },
- // delivery_location: {
- // country: "Argentina",
- // street: "Elm Street",
- // district: "CABA",
- // post_code: "1101",
- // },
- },
+ info: !exampleData.payment.info
+ ? undefined
+ : {
+ ...exampleData.payment.info,
+ // delivery_date: {
+ // t_s: new Date().getTime() / 1000,
+ // },
+ // delivery_location: {
+ // country: "Argentina",
+ // street: "Elm Street",
+ // district: "CABA",
+ // post_code: "1101",
+ // },
+ },
},
});
diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
@@ -53,13 +53,11 @@ import { useEffect, useState } from "preact/hooks";
import { Amount } from "../components/Amount.js";
import { BankDetailsByPaytoType } from "../components/BankDetailsByPaytoType.js";
import { AlertView, ErrorAlertView } from "../components/CurrentAlerts.js";
-import { EnabledBySettings } from "../components/EnabledBySettings.js";
import { Loading } from "../components/Loading.js";
import { Kind, Part, PartPayto } from "../components/Part.js";
import { ShowFullContractTermPopup } from "../components/ShowFullContractTermPopup.js";
import {
CenteredDialog,
- ErrorBox,
InfoBox,
Link,
Overlay,
@@ -609,6 +607,22 @@ export function TransactionView({
transaction.totalRefundEffective,
);
+ if (!transaction.info) {
+ return (
+ <TransactionTemplate
+ transaction={transaction}
+ onDelete={onDelete}
+ onAbort={onAbort}
+ onResume={onResume}
+ onSuspend={onSuspend}
+ onRetry={onRetry}
+ onCancel={onCancel}
+ >
+ <i18n.Translate>loading...</i18n.Translate>
+ </TransactionTemplate>
+ );
+ }
+
return (
<TransactionTemplate
transaction={transaction}