From 71abddec5e3dc9cc407f468feaaa3284ef528aba Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 9 Sep 2020 12:45:49 +0530 Subject: make withdrawal, pay and refunds work in the WebExtension --- .../taler-wallet-webextension/src/pages/refund.tsx | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'packages/taler-wallet-webextension/src/pages') diff --git a/packages/taler-wallet-webextension/src/pages/refund.tsx b/packages/taler-wallet-webextension/src/pages/refund.tsx index 1ace50226..74c33c020 100644 --- a/packages/taler-wallet-webextension/src/pages/refund.tsx +++ b/packages/taler-wallet-webextension/src/pages/refund.tsx @@ -23,22 +23,17 @@ import React, { useEffect, useState } from "react"; import * as wxApi from "../wxApi"; import { AmountView } from "../renderHtml"; -import { PurchaseDetails } from "taler-wallet-core"; +import { PurchaseDetails, ApplyRefundResponse, Amounts } from "taler-wallet-core"; function RefundStatusView(props: { talerRefundUri: string }): JSX.Element { - const [applied, setApplied] = useState(false); - const [purchaseDetails, setPurchaseDetails] = useState< - PurchaseDetails | undefined - >(undefined); + const [applyResult, setApplyResult] = useState(); const [errMsg, setErrMsg] = useState(undefined); useEffect(() => { const doFetch = async (): Promise => { try { const result = await wxApi.applyRefund(props.talerRefundUri); - setApplied(true); - // const r = await wxApi.getPurchaseDetails(result.proposalId); - // setPurchaseDetails(r); + setApplyResult(result); } catch (e) { console.error(e); setErrMsg(e.message); @@ -54,7 +49,7 @@ function RefundStatusView(props: { talerRefundUri: string }): JSX.Element { return Error: {errMsg}; } - if (!applied || !purchaseDetails) { + if (!applyResult) { return Updating refund status; } @@ -62,11 +57,15 @@ function RefundStatusView(props: { talerRefundUri: string }): JSX.Element { <>

Refund Status

- The product {purchaseDetails.contractTerms.summary} has - received a total refund of{" "} - . + The product {applyResult.info.summary} has + received a total effective refund of{" "} + .

-

Note that additional fees from the exchange may apply.

+ {applyResult.pendingAtExchange ?

Refund processing is still in progress.

: null} + {!Amounts.isZero(applyResult.amountRefundGone) ?

+ The refund amount of + could not be applied. +

: null} ); } -- cgit v1.2.3