aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-08-31 11:46:39 -0300
committerSebastian <sebasjm@gmail.com>2022-08-31 11:46:39 -0300
commite759684fd0658b4a3ba241744424ceda11bd500b (patch)
tree31e3e8998aada76bf49df1dd9988021fb67bb856 /packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts
parentd84424202dca22fff22cb1d304286f627642187b (diff)
downloadwallet-core-e759684fd0658b4a3ba241744424ceda11bd500b.tar.xz
invoice and transfer details
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts')
-rw-r--r--packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts16
1 files changed, 13 insertions, 3 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts b/packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts
index 53db117f9..27be1e424 100644
--- a/packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts
@@ -14,7 +14,7 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { Amounts, TalerErrorDetail } from "@gnu-taler/taler-util";
+import { AbsoluteTime, Amounts, TalerErrorDetail, TalerProtocolTimestamp } from "@gnu-taler/taler-util";
import { TalerError } from "@gnu-taler/taler-wallet-core";
import { useState } from "preact/hooks";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
@@ -22,7 +22,7 @@ import * as wxApi from "../../wxApi.js";
import { Props, State } from "./index.js";
export function useComponentState(
- { talerPayPullUri }: Props,
+ { talerPayPullUri, onClose }: Props,
api: typeof wxApi,
): State {
const hook = useAsyncAsHook(async () => {
@@ -45,13 +45,18 @@ export function useComponentState(
};
}
- const { amount, peerPullPaymentIncomingId } = hook.response
+ const { amount: purseAmount, contractTerms, peerPullPaymentIncomingId } = hook.response
+
+ const amount: string = contractTerms?.amount
+ const summary: string | undefined = contractTerms?.summary
+ const expiration: TalerProtocolTimestamp | undefined = contractTerms?.purse_expiration
async function accept(): Promise<void> {
try {
const resp = await api.acceptPeerPullPayment({
peerPullPaymentIncomingId
})
+ await onClose()
} catch (e) {
if (e instanceof TalerError) {
setOperationError(e.errorDetail)
@@ -69,6 +74,11 @@ export function useComponentState(
accept: {
onClick: accept
},
+ summary,
+ expiration: expiration ? AbsoluteTime.fromTimestamp(expiration) : undefined,
+ cancel: {
+ onClick: onClose
+ },
operationError
}
}