aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/cta/Tip
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/Tip')
-rw-r--r--packages/taler-wallet-webextension/src/cta/Tip/index.ts1
-rw-r--r--packages/taler-wallet-webextension/src/cta/Tip/state.ts7
-rw-r--r--packages/taler-wallet-webextension/src/cta/Tip/test.ts44
3 files changed, 30 insertions, 22 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Tip/index.ts b/packages/taler-wallet-webextension/src/cta/Tip/index.ts
index 4bdad0808..157cf7d4e 100644
--- a/packages/taler-wallet-webextension/src/cta/Tip/index.ts
+++ b/packages/taler-wallet-webextension/src/cta/Tip/index.ts
@@ -32,6 +32,7 @@ import {
export interface Props {
talerTipUri?: string;
onCancel: () => Promise<void>;
+ onSuccess: (tx: string) => Promise<void>;
}
export type State =
diff --git a/packages/taler-wallet-webextension/src/cta/Tip/state.ts b/packages/taler-wallet-webextension/src/cta/Tip/state.ts
index 333337e78..a3adafe53 100644
--- a/packages/taler-wallet-webextension/src/cta/Tip/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/Tip/state.ts
@@ -21,7 +21,7 @@ import * as wxApi from "../../wxApi.js";
import { Props, State } from "./index.js";
export function useComponentState(
- { talerTipUri, onCancel }: Props,
+ { talerTipUri, onCancel, onSuccess }: Props,
api: typeof wxApi,
): State {
const [tipIgnored, setTipIgnored] = useState(false);
@@ -48,8 +48,11 @@ export function useComponentState(
const { tip } = tipInfo.response;
const doAccept = async (): Promise<void> => {
- await api.acceptTip({ walletTipId: tip.walletTipId });
+ const res = await api.acceptTip({ walletTipId: tip.walletTipId });
+
+ //FIX: this may not be seen since we are moving to the success also
tipInfo.retry();
+ onSuccess(res.transactionId)
};
const baseInfo = {
diff --git a/packages/taler-wallet-webextension/src/cta/Tip/test.ts b/packages/taler-wallet-webextension/src/cta/Tip/test.ts
index 4895fcc7f..eeb39c8aa 100644
--- a/packages/taler-wallet-webextension/src/cta/Tip/test.ts
+++ b/packages/taler-wallet-webextension/src/cta/Tip/test.ts
@@ -34,6 +34,7 @@ describe("Tip CTA states", () => {
onCancel: async () => {
null;
},
+ onSuccess: async () => { null; },
},
{
prepareTip: async () => ({}),
@@ -74,16 +75,17 @@ describe("Tip CTA states", () => {
onCancel: async () => {
null;
},
+ onSuccess: async () => { null; },
},
{
prepareTip: async () =>
- ({
- accepted: tipAccepted,
- exchangeBaseUrl: "exchange url",
- merchantBaseUrl: "merchant url",
- tipAmountEffective: "EUR:1",
- walletTipId: "tip_id",
- } as PrepareTipResult as any),
+ ({
+ accepted: tipAccepted,
+ exchangeBaseUrl: "exchange url",
+ merchantBaseUrl: "merchant url",
+ tipAmountEffective: "EUR:1",
+ walletTipId: "tip_id",
+ } as PrepareTipResult as any),
acceptTip: async () => {
tipAccepted = true;
},
@@ -134,15 +136,16 @@ describe("Tip CTA states", () => {
onCancel: async () => {
null;
},
+ onSuccess: async () => { null; },
},
{
prepareTip: async () =>
- ({
- exchangeBaseUrl: "exchange url",
- merchantBaseUrl: "merchant url",
- tipAmountEffective: "EUR:1",
- walletTipId: "tip_id",
- } as PrepareTipResult as any),
+ ({
+ exchangeBaseUrl: "exchange url",
+ merchantBaseUrl: "merchant url",
+ tipAmountEffective: "EUR:1",
+ walletTipId: "tip_id",
+ } as PrepareTipResult as any),
acceptTip: async () => ({}),
} as any,
),
@@ -188,16 +191,17 @@ describe("Tip CTA states", () => {
onCancel: async () => {
null;
},
+ onSuccess: async () => { null; },
},
{
prepareTip: async () =>
- ({
- accepted: true,
- exchangeBaseUrl: "exchange url",
- merchantBaseUrl: "merchant url",
- tipAmountEffective: "EUR:1",
- walletTipId: "tip_id",
- } as PrepareTipResult as any),
+ ({
+ accepted: true,
+ exchangeBaseUrl: "exchange url",
+ merchantBaseUrl: "merchant url",
+ tipAmountEffective: "EUR:1",
+ walletTipId: "tip_id",
+ } as PrepareTipResult as any),
acceptTip: async () => ({}),
} as any,
),