commit 7e7395c20506a4e48cdbcf705a4752bf7f26dc88
parent 67a6222a4757c033858f9319262e1970aeebb3c8
Author: Sebastian <sebasjm@gmail.com>
Date: Mon, 14 Apr 2025 12:34:12 -0300
fix #9489
Diffstat:
2 files changed, 42 insertions(+), 58 deletions(-)
diff --git a/packages/taler-wallet-webextension/src/components/Modal.tsx b/packages/taler-wallet-webextension/src/components/Modal.tsx
@@ -52,7 +52,7 @@ const Body = styled.div`
export function Modal({ title, children, onClose }: Props): VNode {
return (
- <div style={{ top: 0, left: 0, position: "fixed", width: "100%", height: "100%" }}>
+ <div style={{ top: 0, left: 0, position: "fixed", width: "100%", height: "100%",zIndex:100 }}>
<FullSize onClick={onClose?.onClick}>
<div
onClick={(e) => e.stopPropagation()}
diff --git a/packages/taler-wallet-webextension/src/components/PaymentButtons.tsx b/packages/taler-wallet-webextension/src/components/PaymentButtons.tsx
@@ -17,6 +17,7 @@
import {
AmountJson,
Amounts,
+ InsufficientBalanceHint,
PaymentInsufficientBalanceDetails,
PreparePayResult,
PreparePayResultType,
@@ -73,44 +74,50 @@ export function PaymentButtons({
}
if (payStatus.status === PreparePayResultType.InsufficientBalance) {
- const reason = getReason(payStatus.balanceDetails);
let BalanceMessage = "";
- switch (reason) {
- case "age-acceptable": {
- BalanceMessage = i18n.str`Balance is not enough because you have ${Amounts.stringifyValue(
- payStatus.balanceDetails.balanceAgeAcceptable,
- )} ${amount.currency} to pay for this contract which is restricted.`;
- break;
- }
- case "available": {
- BalanceMessage = i18n.str`Balance is not enough because you have ${Amounts.stringifyValue(
- payStatus.balanceDetails.balanceAvailable,
- )} ${amount.currency} available.`;
- break;
- }
- case "merchant-acceptable": {
+ switch (payStatus.balanceDetails.causeHint) {
+ case InsufficientBalanceHint.MerchantAcceptInsufficient: {
BalanceMessage = i18n.str`Balance is not enough because merchant will just accept ${Amounts.stringifyValue(
payStatus.balanceDetails.balanceReceiverAcceptable,
- )} ${amount.currency
- } . To know more you can check which exchange and auditors the merchant trust.`;
+ )} ${
+ amount.currency
+ }. To know more you can check which exchange and auditors the merchant trust.`;
break;
}
- case "merchant-depositable": {
+ case InsufficientBalanceHint.MerchantDepositInsufficient: {
BalanceMessage = i18n.str`Balance is not enough because merchant will just accept ${Amounts.stringifyValue(
payStatus.balanceDetails.balanceReceiverDepositable,
- )} ${amount.currency
- } . To know more you can check which wire methods the merchant accepts.`;
+ )} ${
+ amount.currency
+ }. To know more you can check which wire methods the merchant accepts.`;
+ break;
+ }
+ case InsufficientBalanceHint.AgeRestricted: {
+ BalanceMessage = i18n.str`Balance is not enough because you have ${Amounts.stringifyValue(
+ payStatus.balanceDetails.balanceAgeAcceptable,
+ )} ${amount.currency} to pay for this contract which is restricted.`;
break;
}
- case "material": {
+ case InsufficientBalanceHint.WalletBalanceMaterialInsufficient: {
BalanceMessage = i18n.str`Balance is not enough because you have ${Amounts.stringifyValue(
payStatus.balanceDetails.balanceMaterial,
- )} ${amount.currency
- } to spend right know. There are some coins that need to be refreshed.`;
+ )} ${
+ amount.currency
+ } to spend right know. There are some coins that need to be refreshed.`;
+ break;
+ }
+ case InsufficientBalanceHint.WalletBalanceAvailableInsufficient: {
+ BalanceMessage = i18n.str`Balance is not enough because you have ${Amounts.stringifyValue(
+ payStatus.balanceDetails.balanceAvailable,
+ )} ${amount.currency} available.`;
break;
}
- case "fee-gap": {
+ case InsufficientBalanceHint.ExchangeMissingGlobalFees: {
+ BalanceMessage = i18n.str`Provider is missing the global fee configuration, this likely means it is misconfigured.`;
+ break;
+ }
+ case InsufficientBalanceHint.FeesNotCovered: {
BalanceMessage = i18n.str`Balance looks like it should be enough, but doesn't cover all fees requested by the merchant and payment processor. Please ensure there is at least ${Amounts.stringifyValue(
Amounts.stringify(
Amounts.sub(
@@ -118,12 +125,18 @@ export function PaymentButtons({
payStatus.balanceDetails.maxEffectiveSpendAmount,
).amount,
),
- )} ${amount.currency
- } more balance in your wallet or ask your merchant to cover more of the fees.`;
+ )} ${
+ amount.currency
+ } more balance in your wallet or ask your merchant to cover more of the fees.`;
+ break;
+ }
+ case undefined: {
+ // FIXME: explain why the balance is not enough by checking the hint in all exchanges
+ BalanceMessage = i18n.str`Balance is not enough because.`;
break;
}
default:
- assertUnreachable(reason);
+ assertUnreachable(payStatus.balanceDetails.causeHint);
}
return (
@@ -187,7 +200,7 @@ function PayWithMobile({ uri }: { uri: string }): VNode {
}
}
if (!payUri) {
- return <Fragment />
+ return <Fragment />;
}
return (
<section>
@@ -208,32 +221,3 @@ function PayWithMobile({ uri }: { uri: string }): VNode {
</section>
);
}
-
-type NoEnoughBalanceReason =
- | "available"
- | "material"
- | "age-acceptable"
- | "merchant-acceptable"
- | "merchant-depositable"
- | "fee-gap";
-
-function getReason(
- info: PaymentInsufficientBalanceDetails,
-): NoEnoughBalanceReason {
- if (Amounts.cmp(info.amountRequested, info.balanceAvailable) > 0) {
- return "available";
- }
- if (Amounts.cmp(info.amountRequested, info.balanceMaterial) > 0) {
- return "material";
- }
- if (Amounts.cmp(info.amountRequested, info.balanceAgeAcceptable) > 0) {
- return "age-acceptable";
- }
- if (Amounts.cmp(info.amountRequested, info.balanceReceiverAcceptable) > 0) {
- return "merchant-acceptable";
- }
- if (Amounts.cmp(info.amountRequested, info.balanceReceiverDepositable) > 0) {
- return "merchant-depositable";
- }
- return "fee-gap";
-}