make basic withdrawal and payment work again with new API
This commit is contained in:
parent
0f390477f3
commit
f7299a1aa0
@ -24,13 +24,20 @@
|
|||||||
*/
|
*/
|
||||||
import * as i18n from "../i18n";
|
import * as i18n from "../i18n";
|
||||||
|
|
||||||
|
|
||||||
import { renderAmount, ProgressButton } from "../renderHtml";
|
import { renderAmount, ProgressButton } from "../renderHtml";
|
||||||
import * as wxApi from "../wxApi";
|
import * as wxApi from "../wxApi";
|
||||||
|
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
|
|
||||||
import { Amounts, AmountJson, PreparePayResult, PreparePayResultType, ContractTerms, codecForContractTerms, ConfirmPayResultType } from "taler-wallet-core";
|
import {
|
||||||
|
Amounts,
|
||||||
|
AmountJson,
|
||||||
|
PreparePayResult,
|
||||||
|
PreparePayResultType,
|
||||||
|
ContractTerms,
|
||||||
|
codecForContractTerms,
|
||||||
|
ConfirmPayResultType,
|
||||||
|
} from "taler-wallet-core";
|
||||||
|
|
||||||
function TalerPayDialog({ talerPayUri }: { talerPayUri: string }): JSX.Element {
|
function TalerPayDialog({ talerPayUri }: { talerPayUri: string }): JSX.Element {
|
||||||
const [payStatus, setPayStatus] = useState<PreparePayResult | undefined>();
|
const [payStatus, setPayStatus] = useState<PreparePayResult | undefined>();
|
||||||
@ -60,7 +67,10 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }): JSX.Element {
|
|||||||
amountEffective = Amounts.parseOrThrow(payStatus.amountEffective);
|
amountEffective = Amounts.parseOrThrow(payStatus.amountEffective);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payStatus.status === PreparePayResultType.AlreadyConfirmed && numTries === 0) {
|
if (
|
||||||
|
payStatus.status === PreparePayResultType.AlreadyConfirmed &&
|
||||||
|
numTries === 0
|
||||||
|
) {
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
You have already paid for this article. Click{" "}
|
You have already paid for this article. Click{" "}
|
||||||
|
@ -43,7 +43,6 @@ function WithdrawalDialog(props: { talerWithdrawUri: string }): JSX.Element {
|
|||||||
const talerWithdrawUri = props.talerWithdrawUri;
|
const talerWithdrawUri = props.talerWithdrawUri;
|
||||||
const [cancelled, setCancelled] = useState(false);
|
const [cancelled, setCancelled] = useState(false);
|
||||||
const [selecting, setSelecting] = useState(false);
|
const [selecting, setSelecting] = useState(false);
|
||||||
const [customUrl, setCustomUrl] = useState<string>("");
|
|
||||||
const [errMsg, setErrMsg] = useState<string | undefined>("");
|
const [errMsg, setErrMsg] = useState<string | undefined>("");
|
||||||
const [updateCounter, setUpdateCounter] = useState(1);
|
const [updateCounter, setUpdateCounter] = useState(1);
|
||||||
|
|
||||||
@ -58,6 +57,9 @@ function WithdrawalDialog(props: { talerWithdrawUri: string }): JSX.Element {
|
|||||||
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) {
|
||||||
|
setSelectedExchange(res.defaultExchangeBaseUrl);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
fetchData();
|
fetchData();
|
||||||
}, [selectedExchange, errMsg, selecting, talerWithdrawUri, updateCounter]);
|
}, [selectedExchange, errMsg, selecting, talerWithdrawUri, updateCounter]);
|
||||||
@ -124,10 +126,6 @@ function WithdrawalDialog(props: { talerWithdrawUri: string }): JSX.Element {
|
|||||||
{i18n.str`Cancel withdraw operation`}
|
{i18n.str`Cancel withdraw operation`}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{/* {details.exchangeWithdrawDetails ? (
|
|
||||||
<WithdrawDetailView rci={details.exchangeWithdrawDetails} />
|
|
||||||
) : null} */}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -98,7 +98,7 @@ export function confirmPay(
|
|||||||
proposalId: string,
|
proposalId: string,
|
||||||
sessionId: string | undefined,
|
sessionId: string | undefined,
|
||||||
): Promise<ConfirmPayResult> {
|
): Promise<ConfirmPayResult> {
|
||||||
return callBackend("confirm-pay", { proposalId, sessionId });
|
return callBackend("confirmPay", { proposalId, sessionId });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -184,7 +184,7 @@ export function benchmarkCrypto(repetitions: number): Promise<BenchmarkResult> {
|
|||||||
* Get details about a pay operation.
|
* Get details about a pay operation.
|
||||||
*/
|
*/
|
||||||
export function preparePay(talerPayUri: string): Promise<PreparePayResult> {
|
export function preparePay(talerPayUri: string): Promise<PreparePayResult> {
|
||||||
return callBackend("prepare-pay", { talerPayUri });
|
return callBackend("preparePay", { talerPayUri });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -194,9 +194,9 @@ export function acceptWithdrawal(
|
|||||||
talerWithdrawUri: string,
|
talerWithdrawUri: string,
|
||||||
selectedExchange: string,
|
selectedExchange: string,
|
||||||
): Promise<AcceptWithdrawalResponse> {
|
): Promise<AcceptWithdrawalResponse> {
|
||||||
return callBackend("accept-withdrawal", {
|
return callBackend("acceptBankIntegratedWithdrawal", {
|
||||||
talerWithdrawUri,
|
talerWithdrawUri,
|
||||||
selectedExchange,
|
exchangeBaseUrl: selectedExchange,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user