-
+
Scan the QR code or
-
+
click here
@@ -340,50 +344,60 @@ function PayWithMobile({ state }: { state: SupportedStates }): VNode {
);
}
-function ButtonsSection({
- state,
- goToWalletManualWithdraw,
-}: {
- state: SupportedStates;
+interface ButtonSectionProps {
+ payStatus: PreparePayResult;
+ payHandler: ButtonHandler | undefined;
+ balance: AmountJson | undefined;
+ uri: string;
+ amount: AmountJson;
goToWalletManualWithdraw: (currency: string) => Promise
;
-}): VNode {
+}
+
+export function ButtonsSection({
+ payStatus,
+ uri,
+ payHandler,
+ balance,
+ amount,
+ goToWalletManualWithdraw,
+}: ButtonSectionProps): VNode {
const { i18n } = useTranslationContext();
- if (state.status === "ready") {
+ if (payStatus.status === PreparePayResultType.PaymentPossible) {
+ const privateUri = `${uri}&n=${payStatus.noncePriv}`;
+
return (
-
+
);
}
- if (
- state.status === "no-enough-balance" ||
- state.status === "no-balance-for-currency"
- ) {
- // if (state.payStatus.status === PreparePayResultType.InsufficientBalance) {
+
+ if (payStatus.status === PreparePayResultType.InsufficientBalance) {
let BalanceMessage = "";
- if (!state.balance) {
+ if (!balance) {
BalanceMessage = i18n.str`You have no balance for this currency. Withdraw digital cash first.`;
} else {
- const balanceShouldBeEnough =
- Amounts.cmp(state.balance, state.amount) !== -1;
+ const balanceShouldBeEnough = Amounts.cmp(balance, amount) !== -1;
if (balanceShouldBeEnough) {
- BalanceMessage = i18n.str`Could not find enough coins to pay this order. Even if you have enough ${state.balance.currency} some restriction may apply.`;
+ BalanceMessage = i18n.str`Could not find enough coins to pay. Even if you have enough ${balance.currency} some restriction may apply.`;
} else {
- BalanceMessage = i18n.str`Your current balance is not enough for this order.`;
+ BalanceMessage = i18n.str`Your current balance is not enough.`;
}
}
+ const uriPrivate = `${uri}&n=${payStatus.noncePriv}`;
+
return (
@@ -393,51 +407,45 @@ function ButtonsSection({
-
+
);
- // }
}
- if (state.status === "confirmed") {
- if (state.payStatus.status === PreparePayResultType.AlreadyConfirmed) {
- return (
-
-
- {state.payStatus.paid &&
- state.payStatus.contractTerms.fulfillment_message && (
- Merchant message}
- text={state.payStatus.contractTerms.fulfillment_message}
- kind="neutral"
- />
- )}
-
- {!state.payStatus.paid && }
-
- );
- }
+ if (payStatus.status === PreparePayResultType.AlreadyConfirmed) {
+ return (
+
+
+ {payStatus.paid && payStatus.contractTerms.fulfillment_message && (
+ Merchant message}
+ text={payStatus.contractTerms.fulfillment_message}
+ kind="neutral"
+ />
+ )}
+
+ {!payStatus.paid && }
+
+ );
}
- if (state.status === "completed") {
- if (state.payResult.type === ConfirmPayResultType.Pending) {
- return (
-
- );
- }
- }
+ // if (state.status === "completed") {
+ // if (state.payResult.type === ConfirmPayResultType.Pending) {
+ // return (
+ //
+ //
+ //
+ // Processing...
+ //
+ //
+ //
+ // );
+ // }
+ // }
return ;
}
diff --git a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts
index c00d6d7f6..61fe86e3a 100644
--- a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts
+++ b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.test.ts
@@ -20,11 +20,13 @@ import { h, VNode } from "preact";
import { expect } from "chai";
describe("useTalerActionURL hook", () => {
+
it("should be set url to undefined when dismiss", async () => {
const ctx = ({ children }: { children: any }): VNode => {
return h(IoCProviderForTesting, {
value: {
findTalerUriInActiveTab: async () => "asd",
+ findTalerUriInClipboard: async () => "qwe",
},
children,
});
@@ -42,7 +44,10 @@ describe("useTalerActionURL hook", () => {
{
const [url, setDismissed] = getLastResultOrThrow();
- expect(url).equals("asd");
+ expect(url).deep.equals({
+ location: "clipboard",
+ uri: "qwe"
+ });
setDismissed(true);
}
@@ -53,7 +58,6 @@ describe("useTalerActionURL hook", () => {
if (url !== undefined) throw Error("invalid");
expect(url).undefined;
}
-
await assertNoPendingUpdate();
});
});
diff --git a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.ts b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.ts
index 74d7cbbd9..e1b08278b 100644
--- a/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.ts
+++ b/packages/taler-wallet-webextension/src/hooks/useTalerActionURL.ts
@@ -52,7 +52,8 @@ export function useTalerActionURL(): [
}
}
check();
- });
+ }, [setTalerActionUrl]);
+
const url = dismissed ? undefined : talerActionUrl;
return [url, setDismissed];
}