From b1056b4c20bca2cddfcb50fa93eeef0b183b38ea Mon Sep 17 00:00:00 2001
From: Florian Dold <florian@dold.me>
Date: Sun, 17 Jan 2021 18:33:25 +0100
Subject: actually display fees instead of effective amount

---
 packages/taler-wallet-webextension/src/pages/pay.tsx | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

(limited to 'packages/taler-wallet-webextension/src/pages/pay.tsx')

diff --git a/packages/taler-wallet-webextension/src/pages/pay.tsx b/packages/taler-wallet-webextension/src/pages/pay.tsx
index fcf50cf37..ce3a59674 100644
--- a/packages/taler-wallet-webextension/src/pages/pay.tsx
+++ b/packages/taler-wallet-webextension/src/pages/pay.tsx
@@ -35,7 +35,6 @@ import {
   PreparePayResult,
   PreparePayResultType,
   ContractTerms,
-  codecForContractTerms,
   ConfirmPayResultType,
   ConfirmPayResult,
   getJsonI18n,
@@ -47,7 +46,7 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }): JSX.Element {
   const [payErrMsg, setPayErrMsg] = useState<string | undefined>("");
   const [numTries, setNumTries] = useState(0);
   const [loading, setLoading] = useState(false);
-  let amountEffective: AmountJson | undefined = undefined;
+  let totalFees: AmountJson | undefined = undefined;
 
   useEffect(() => {
     const doFetch = async (): Promise<void> => {
@@ -67,7 +66,9 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }): JSX.Element {
   }
 
   if (payStatus.status === PreparePayResultType.PaymentPossible) {
-    amountEffective = Amounts.parseOrThrow(payStatus.amountEffective);
+    let amountRaw = Amounts.parseOrThrow(payStatus.amountRaw);
+    let amountEffective: AmountJson = Amounts.parseOrThrow(payStatus.amountEffective);
+    totalFees = Amounts.sub(amountEffective, amountRaw).amount;
   }
 
   if (
@@ -161,10 +162,10 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }): JSX.Element {
         <div style={{ textAlign: "center" }}>
           <strong>{contractTerms.summary}</strong>
         </div>
-        {amountEffective ? (
+        {totalFees ? (
           <i18n.Translate wrap="p">
             The total price is <span>{amount} </span>
-            (plus <span>{renderAmount(amountEffective)}</span> fees).
+            (plus <span>{renderAmount(totalFees)}</span> fees).
           </i18n.Translate>
         ) : (
           <i18n.Translate wrap="p">
-- 
cgit v1.2.3

