Skip to content

Commit 10d8d4c

Browse files
committed
frontend: show bitrefill address in a blocking dialog
So the user can confirm the payment on the device.
1 parent d6737c5 commit 10d8d4c

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

frontends/web/src/routes/market/bitrefill.tsx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,20 @@ import { useState, useEffect, useRef, useCallback } from 'react';
1818
import { useTranslation } from 'react-i18next';
1919
import { Header } from '@/components/layout';
2020
import { Spinner } from '@/components/spinner/Spinner';
21-
import { AccountCode, IAccount, proposeTx, sendTx, TTxInput } from '@/api/account';
21+
import { AccountCode, IAccount, proposeTx, sendTx, TTxInput, TTxProposalResult } from '@/api/account';
2222
import { findAccount, isBitcoinOnly } from '@/routes/account/utils';
2323
import { useDarkmode } from '@/hooks/darkmode';
2424
import { getConfig } from '@/utils/config';
25-
import style from './iframe.module.css';
2625
import { i18n } from '@/i18n/i18n';
2726
import { alertUser } from '@/components/alert/Alert';
2827
import { parseExternalBtcAmount } from '@/api/coins';
2928
import { useLoad } from '@/hooks/api';
3029
import { BitrefillTerms, localeMapping } from '@/components/terms/bitrefill-terms';
3130
import { getBitrefillInfo } from '@/api/market';
3231
import { getURLOrigin } from '@/utils/url';
32+
import { WaitDialog } from '@/components/wait-dialog/wait-dialog';
33+
import { AmountWithUnit } from '@/components/amount/amount-with-unit';
34+
import style from './iframe.module.css';
3335

3436
// Map coins supported by Bitrefill
3537
const coinMapping: Readonly<Record<string, string>> = {
@@ -61,6 +63,8 @@ export const Bitrefill = ({ accounts, code }: TProps) => {
6163
const config = useLoad(getConfig);
6264
const [agreedTerms, setAgreedTerms] = useState(false);
6365

66+
const [verifyPaymentRequest, setVerifyPaymentRequest] = useState<TTxProposalResult & { address: string } | false>();
67+
6468
const hasOnlyBTCAccounts = accounts.every(({ coinCode }) => isBitcoinOnly(coinCode));
6569

6670
useEffect(() => {
@@ -156,7 +160,13 @@ export const Bitrefill = ({ accounts, code }: TProps) => {
156160
name: 'Bitrefill',
157161
orderId: invoiceId,
158162
});
163+
164+
setVerifyPaymentRequest({
165+
address: paymentAddress,
166+
...result
167+
});
159168
const sendResult = await sendTx(code, txNote);
169+
setVerifyPaymentRequest(false);
160170
if (!sendResult.success && !('aborted' in sendResult)) {
161171
alertUser(t('unknownError', { errorMessage: sendResult.errorMessage }));
162172
}
@@ -225,6 +235,26 @@ export const Bitrefill = ({ accounts, code }: TProps) => {
225235
}}
226236
/>
227237
)}
238+
239+
{ verifyPaymentRequest && verifyPaymentRequest.success && (
240+
<WaitDialog title={t('receive.verifyBitBox02')}>
241+
<p>
242+
{t('transaction.details.address')}
243+
<br />
244+
{verifyPaymentRequest.address}
245+
</p>
246+
<p>
247+
{t('transaction.details.amount')}
248+
<br />
249+
<AmountWithUnit amount={verifyPaymentRequest.amount} />
250+
</p>
251+
<p>
252+
{t('transaction.fee')}
253+
<br />
254+
<AmountWithUnit amount={verifyPaymentRequest.fee} />
255+
</p>
256+
</WaitDialog>
257+
)}
228258
</div>
229259
)}
230260
</div>

0 commit comments

Comments
 (0)