From c62ba4986fbfcb8637a3befadf3d3eddbd5348ca Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 17 Jan 2018 03:49:54 +0100 Subject: implement new mobile-compatible payment logic --- src/webex/pages/confirm-contract.tsx | 83 ++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 27 deletions(-) (limited to 'src/webex/pages/confirm-contract.tsx') diff --git a/src/webex/pages/confirm-contract.tsx b/src/webex/pages/confirm-contract.tsx index 83de738b9..090737475 100644 --- a/src/webex/pages/confirm-contract.tsx +++ b/src/webex/pages/confirm-contract.tsx @@ -27,7 +27,7 @@ import * as i18n from "../../i18n"; import { ExchangeRecord, - ProposalRecord, + ProposalDownloadRecord, } from "../../dbTypes"; import { ContractTerms } from "../../talerTypes"; import { @@ -102,12 +102,15 @@ class Details extends React.Component { } interface ContractPromptProps { - proposalId: number; + proposalId?: number; + contractUrl?: string; + sessionId?: string; } interface ContractPromptState { - proposal: ProposalRecord|null; - error: string|null; + proposalId: number | undefined; + proposal: ProposalDownloadRecord | null; + error: string | null; payDisabled: boolean; alreadyPaid: boolean; exchanges: null|ExchangeRecord[]; @@ -130,6 +133,7 @@ class ContractPrompt extends React.Component e.master_pub); const ex = this.state.exchanges.find((e) => acceptedExchangePubs.indexOf(e.masterPublicKey) >= 0); if (ex) { - this.setState({error: msgInsufficient}); + this.setState({ error: msgInsufficient }); } else { - this.setState({error: msgNoMatch}); + this.setState({ error: msgNoMatch }); } } else { - this.setState({error: msgInsufficient}); + this.setState({ error: msgInsufficient }); } - this.setState({payDisabled: true}); + this.setState({ payDisabled: true }); } else if (payStatus.status === "paid") { - this.setState({alreadyPaid: true, payDisabled: false, error: null, payStatus}); + this.setState({ alreadyPaid: true, payDisabled: false, error: null, payStatus }); } else { - this.setState({payDisabled: false, error: null, payStatus}); + this.setState({ payDisabled: false, error: null, payStatus }); } } @@ -184,21 +200,24 @@ class ContractPrompt extends React.ComponentError: either contractUrl or proposalId must be given; + } + if (this.state.proposalId === undefined) { + return Downloading contract terms; + } if (!this.state.proposal) { return ...; } @@ -255,8 +274,18 @@ class ContractPrompt extends React.Component { const url = new URI(document.location.href); const query: any = URI.parseQuery(url.query()); - const proposalId = JSON.parse(query.proposalId); - ReactDOM.render(, document.getElementById( - "contract")!); + let proposalId; + try { + proposalId = JSON.parse(query.proposalId); + } catch { + // ignore error + } + + const sessionId = query.sessionId; + const contractUrl = query.contractUrl; + + ReactDOM.render( + , + document.getElementById("contract")!); }); -- cgit v1.2.3