actually display fees instead of effective amount
This commit is contained in:
parent
9aa9742d0e
commit
b1056b4c20
@ -35,7 +35,6 @@ import {
|
|||||||
PreparePayResult,
|
PreparePayResult,
|
||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
ContractTerms,
|
ContractTerms,
|
||||||
codecForContractTerms,
|
|
||||||
ConfirmPayResultType,
|
ConfirmPayResultType,
|
||||||
ConfirmPayResult,
|
ConfirmPayResult,
|
||||||
getJsonI18n,
|
getJsonI18n,
|
||||||
@ -47,7 +46,7 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }): JSX.Element {
|
|||||||
const [payErrMsg, setPayErrMsg] = useState<string | undefined>("");
|
const [payErrMsg, setPayErrMsg] = useState<string | undefined>("");
|
||||||
const [numTries, setNumTries] = useState(0);
|
const [numTries, setNumTries] = useState(0);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
let amountEffective: AmountJson | undefined = undefined;
|
let totalFees: AmountJson | undefined = undefined;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const doFetch = async (): Promise<void> => {
|
const doFetch = async (): Promise<void> => {
|
||||||
@ -67,7 +66,9 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }): JSX.Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (payStatus.status === PreparePayResultType.PaymentPossible) {
|
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 (
|
if (
|
||||||
@ -161,10 +162,10 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }): JSX.Element {
|
|||||||
<div style={{ textAlign: "center" }}>
|
<div style={{ textAlign: "center" }}>
|
||||||
<strong>{contractTerms.summary}</strong>
|
<strong>{contractTerms.summary}</strong>
|
||||||
</div>
|
</div>
|
||||||
{amountEffective ? (
|
{totalFees ? (
|
||||||
<i18n.Translate wrap="p">
|
<i18n.Translate wrap="p">
|
||||||
The total price is <span>{amount} </span>
|
The total price is <span>{amount} </span>
|
||||||
(plus <span>{renderAmount(amountEffective)}</span> fees).
|
(plus <span>{renderAmount(totalFees)}</span> fees).
|
||||||
</i18n.Translate>
|
</i18n.Translate>
|
||||||
) : (
|
) : (
|
||||||
<i18n.Translate wrap="p">
|
<i18n.Translate wrap="p">
|
||||||
|
@ -34,9 +34,7 @@ import {
|
|||||||
import { WithdrawUriInfoResponse } from "taler-wallet-core";
|
import { WithdrawUriInfoResponse } from "taler-wallet-core";
|
||||||
|
|
||||||
function WithdrawalDialog(props: { talerWithdrawUri: string }): JSX.Element {
|
function WithdrawalDialog(props: { talerWithdrawUri: string }): JSX.Element {
|
||||||
const [details, setDetails] = useState<
|
const [details, setDetails] = useState<WithdrawUriInfoResponse | undefined>();
|
||||||
WithdrawUriInfoResponse | undefined
|
|
||||||
>();
|
|
||||||
const [selectedExchange, setSelectedExchange] = useState<
|
const [selectedExchange, setSelectedExchange] = useState<
|
||||||
string | undefined
|
string | undefined
|
||||||
>();
|
>();
|
||||||
@ -55,7 +53,9 @@ function WithdrawalDialog(props: { talerWithdrawUri: string }): JSX.Element {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchData = async (): Promise<void> => {
|
const fetchData = async (): Promise<void> => {
|
||||||
const res = await getWithdrawalDetailsForUri({talerWithdrawUri: props.talerWithdrawUri});
|
const res = await getWithdrawalDetailsForUri({
|
||||||
|
talerWithdrawUri: props.talerWithdrawUri,
|
||||||
|
});
|
||||||
setDetails(res);
|
setDetails(res);
|
||||||
if (res.defaultExchangeBaseUrl) {
|
if (res.defaultExchangeBaseUrl) {
|
||||||
setSelectedExchange(res.defaultExchangeBaseUrl);
|
setSelectedExchange(res.defaultExchangeBaseUrl);
|
||||||
@ -89,8 +89,8 @@ function WithdrawalDialog(props: { talerWithdrawUri: string }): JSX.Element {
|
|||||||
<h1>Digital Cash Withdrawal</h1>
|
<h1>Digital Cash Withdrawal</h1>
|
||||||
<i18n.Translate wrap="p">
|
<i18n.Translate wrap="p">
|
||||||
You are about to withdraw{" "}
|
You are about to withdraw{" "}
|
||||||
<strong>{renderAmount(details.amount)}</strong> from
|
<strong>{renderAmount(details.amount)}</strong> from your bank account
|
||||||
your bank account into your wallet.
|
into your wallet.
|
||||||
</i18n.Translate>
|
</i18n.Translate>
|
||||||
{selectedExchange ? (
|
{selectedExchange ? (
|
||||||
<p>
|
<p>
|
||||||
|
Loading…
Reference in New Issue
Block a user