@tuwaio/nova-payments 0.0.0-stage → 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +116 -2
- package/dist/chunk-2GRM2VF3.cjs +1 -0
- package/dist/chunk-4TPU7WSP.cjs +1 -0
- package/dist/chunk-BK3GAYTJ.js +1 -0
- package/dist/chunk-XAUJNVKC.js +1 -0
- package/dist/evm/index.cjs +1 -0
- package/dist/evm/index.d.cts +33 -0
- package/dist/evm/index.d.ts +33 -0
- package/dist/evm/index.js +1 -0
- package/dist/i18n/index.cjs +1 -0
- package/dist/i18n/index.d.cts +29 -0
- package/dist/i18n/index.d.ts +29 -0
- package/dist/i18n/index.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.css +910 -0
- package/dist/index.d.cts +1296 -0
- package/dist/index.d.ts +1296 -0
- package/dist/index.js +1 -0
- package/dist/locales-DtReb4Tp.d.cts +588 -0
- package/dist/locales-DtReb4Tp.d.ts +588 -0
- package/dist/solana/index.cjs +1 -0
- package/dist/solana/index.d.cts +38 -0
- package/dist/solana/index.d.ts +38 -0
- package/dist/solana/index.js +1 -0
- package/dist/types-Bmj8ctqc.d.cts +241 -0
- package/dist/types-Bmj8ctqc.d.ts +241 -0
- package/package.json +152 -4
- package/socket.json +17 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1296 @@
|
|
|
1
|
+
import { P as PaymentsAdapter, C as CheckoutWallet, a as PaymentFamily } from './types-Bmj8ctqc.js';
|
|
2
|
+
export { N as NativeFee, b as PulsarTransactionParams, c as canPayWithQr, d as connectedWallet, m as methodFamily, e as methodToken, n as networkName, p as payerFor, f as priceAdjustment, w as walletLabel } from './types-Bmj8ctqc.js';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { CheckoutMethod, CheckoutPhase, CheckoutView, CheckoutQuote, PaymentInstructions, CheckoutError, CheckoutStore, CheckoutState, CheckoutApi, EventSourceConstructor, AutoChargeOffer, CheckoutMerchant } from '@tuwaio/quasar-sdk/checkout';
|
|
6
|
+
import { N as NovaPaymentsLabels, a as CheckoutLocale, b as NovaPaymentsLabelOverrides } from './locales-DtReb4Tp.js';
|
|
7
|
+
import { Transaction } from '@tuwaio/pulsar-core';
|
|
8
|
+
import { Buyer } from '@tuwaio/quasar-sdk';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The automatic payments offer of a subscription, after a paid period: the limit the seller may take each period, the
|
|
12
|
+
* period, the paying wallet and the account that takes the charges, until when, and how to turn it off. "Allow" asks
|
|
13
|
+
* the wallet for the ERC-7715 permission and hands it to Quasar (then the paid outcome says automatic payments are
|
|
14
|
+
* on); "Not now" keeps paying each invoice.
|
|
15
|
+
*
|
|
16
|
+
* Side effects: a wallet prompt; `POST permission` of the checkout.
|
|
17
|
+
*
|
|
18
|
+
* @returns The automatic payments step.
|
|
19
|
+
*/
|
|
20
|
+
declare function AutoPayScreen(): react.JSX.Element | null;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The buyer details step, shown when the merchant's settings ask for the buyer and the invoice was issued without
|
|
24
|
+
* them: the email, or the full details, and a company invoice on request (name, address, country and tax ID). The
|
|
25
|
+
* fields carry `autocomplete` tokens (WCAG 1.3.5), errors are tied to their fields and announced, and the invoice
|
|
26
|
+
* document is issued once the details are taken.
|
|
27
|
+
*
|
|
28
|
+
* @returns The buyer details step.
|
|
29
|
+
*/
|
|
30
|
+
declare function BuyerScreen(): react.JSX.Element | null;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @file What the checkout shows for the state of a checkout store: the screen, the steps, the payment methods by
|
|
34
|
+
* token, and when to warn about time.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A screen of the checkout: the steps of a payment (`buyer`, `method`, `pay` or `qr`, `confirm`, `autoPay`) or its
|
|
39
|
+
* outcome.
|
|
40
|
+
*/
|
|
41
|
+
type CheckoutScreen = 'loading' | 'error' | 'buyer' | 'method' | 'pay' | 'qr' | 'confirm' | 'paid' | 'autoPay' | 'underpaid' | 'held' | 'refunded' | 'expired' | 'cancelled' | 'replaced' | 'blocked';
|
|
42
|
+
/** Choices of the buyer that the checkout store does not hold. */
|
|
43
|
+
interface CheckoutScreenChoices {
|
|
44
|
+
/** Pay from a wallet in this browser (default) or scan a QR code with a phone. */
|
|
45
|
+
payWith?: 'wallet' | 'qr';
|
|
46
|
+
/** The buyer opened the automatic payments offer after paying the first period of a subscription. */
|
|
47
|
+
autoPay?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The buyer continues on a phone: with `payWith` `qr`, the QR code of the payment page shows before any price is
|
|
50
|
+
* locked (an EVM method, paid from the phone's wallet on that page).
|
|
51
|
+
*/
|
|
52
|
+
handoff?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The screen for the state of a checkout store.
|
|
56
|
+
*
|
|
57
|
+
* @param state - The `phase`, `checkout` and `quote` of the store.
|
|
58
|
+
* @param state.phase - Where the payment stands.
|
|
59
|
+
* @param state.checkout - What the checkout token opens; `null` until loaded.
|
|
60
|
+
* @param state.quote - The locked price; while the first one is being locked the method screen stays, with its button
|
|
61
|
+
* busy, so a refused payer or a failed request is shown where the buyer chose.
|
|
62
|
+
* @param choices - What the buyer chose on the page.
|
|
63
|
+
* @returns The screen: `qr` instead of `pay` when the buyer pays with a QR code (or the price was locked without a
|
|
64
|
+
* payer), `replaced` for an invoice the seller
|
|
65
|
+
* corrected, `autoPay` after a paid subscription period while the automatic payments offer is open.
|
|
66
|
+
*/
|
|
67
|
+
declare function checkoutScreen(state: {
|
|
68
|
+
phase: CheckoutPhase;
|
|
69
|
+
checkout: CheckoutView | null;
|
|
70
|
+
quote?: CheckoutQuote | null;
|
|
71
|
+
}, choices?: CheckoutScreenChoices): CheckoutScreen;
|
|
72
|
+
/** A step of the stepper in the checkout header. */
|
|
73
|
+
interface CheckoutStep {
|
|
74
|
+
/** `details` (buyer details), `method`, `pay`, `confirm`, `autoPay` (automatic payments of a subscription). */
|
|
75
|
+
key: 'details' | 'method' | 'pay' | 'confirm' | 'autoPay';
|
|
76
|
+
/** Before, at or after the current step. */
|
|
77
|
+
state: 'done' | 'current' | 'upcoming';
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The steps of the stepper for a screen.
|
|
81
|
+
*
|
|
82
|
+
* @param screen - The current screen.
|
|
83
|
+
* @param options - Steps that apply to this invoice.
|
|
84
|
+
* @param options.withDetails - The checkout asked for the buyer details first.
|
|
85
|
+
* @returns The steps, or `null` on an outcome screen, whose header shows its title instead.
|
|
86
|
+
*/
|
|
87
|
+
declare function checkoutSteps(screen: CheckoutScreen, options?: {
|
|
88
|
+
withDetails?: boolean;
|
|
89
|
+
}): CheckoutStep[] | null;
|
|
90
|
+
/** The methods of one token, as the method step shows it: the token first, then its network. */
|
|
91
|
+
interface CheckoutTokenGroup {
|
|
92
|
+
/** Token symbol. */
|
|
93
|
+
symbol: string;
|
|
94
|
+
/** Its methods, one per network: the connected wallet's network first, then the Popular ones. */
|
|
95
|
+
methods: CheckoutMethod[];
|
|
96
|
+
/** The merchant marks one of its methods Popular. */
|
|
97
|
+
featured: boolean;
|
|
98
|
+
/** One of its methods is on the network of the connected wallet. */
|
|
99
|
+
inWallet: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Groups payment methods by token: the token picked first, then its network (decision of 2026-10-10). Groups with a
|
|
103
|
+
* method on the connected wallet's network come first, then those the merchant marks Popular; otherwise the
|
|
104
|
+
* merchant's order stays.
|
|
105
|
+
*
|
|
106
|
+
* @param methods - The methods of the checkout, in the merchant's order.
|
|
107
|
+
* @param walletChainId - CAIP-2 chain of the connected wallet, if any.
|
|
108
|
+
* @returns The groups.
|
|
109
|
+
*/
|
|
110
|
+
declare function groupMethodsByToken(methods: CheckoutMethod[], walletChainId?: string | null): CheckoutTokenGroup[];
|
|
111
|
+
/** Minutes before the invoice deadline at which screen readers hear how much time is left. */
|
|
112
|
+
declare const DEADLINE_ANNOUNCEMENTS: readonly [10, 5, 1];
|
|
113
|
+
/**
|
|
114
|
+
* Whether a tick of the invoice countdown crossed one of {@link DEADLINE_ANNOUNCEMENTS}: the checkout announces the
|
|
115
|
+
* time left then (WCAG 2.2.1), not every second.
|
|
116
|
+
*
|
|
117
|
+
* @param previousMs - Time left at the previous tick; `null` on the first one.
|
|
118
|
+
* @param ms - Time left now.
|
|
119
|
+
* @returns The minutes to announce (the nearest when several were crossed at once), or `null`.
|
|
120
|
+
*/
|
|
121
|
+
declare function deadlineAnnouncement(previousMs: number | null, ms: number): number | null;
|
|
122
|
+
/** How long before a locked price ends the checkout offers to keep it (WCAG 2.2.1: 20 seconds at least). */
|
|
123
|
+
declare const QUOTE_WARNING_MS = 60000;
|
|
124
|
+
/**
|
|
125
|
+
* Whether a locked price is in its last minute, when the checkout offers to keep it.
|
|
126
|
+
*
|
|
127
|
+
* @param ms - Time left of the price lock.
|
|
128
|
+
* @returns `true` from {@link QUOTE_WARNING_MS} down to the end.
|
|
129
|
+
*/
|
|
130
|
+
declare function isQuoteEnding(ms: number): boolean;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @file Handing a payment the wallet sent over to the app's Pulsar store when the checkout closes before Quasar
|
|
134
|
+
* settled it: Pulsar keeps tracking it, and Nova Transactions shows its toast.
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
/** A payment the wallet sent, as the checkout remembers it until Quasar settles it. */
|
|
138
|
+
interface SentPayment {
|
|
139
|
+
/** The transaction hash (EVM) or signature (Solana). */
|
|
140
|
+
txKey: string;
|
|
141
|
+
/** What the wallet sent. */
|
|
142
|
+
instructions: PaymentInstructions;
|
|
143
|
+
/** The sender. */
|
|
144
|
+
account: string;
|
|
145
|
+
/** The connector of the wallet. */
|
|
146
|
+
connectorType: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The part of the app's Pulsar store (`createPulsarStore` of `@tuwaio/pulsar-core`) the checkout uses: pass
|
|
150
|
+
* `injectExternalPendingTxs` of the store, as `pulsar` of `NovaPaymentsProvider`.
|
|
151
|
+
*/
|
|
152
|
+
interface PaymentsPulsar {
|
|
153
|
+
/**
|
|
154
|
+
* Adds pending transactions to the pool and tracks them.
|
|
155
|
+
*
|
|
156
|
+
* @param transactions - The pending transactions.
|
|
157
|
+
* @returns Resolves when their trackers started.
|
|
158
|
+
*/
|
|
159
|
+
injectExternalPendingTxs(transactions: Transaction[]): Promise<void>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Whether a sent payment still needs tracking when the checkout closes: Quasar has not settled it, and it did not
|
|
163
|
+
* fail on-chain.
|
|
164
|
+
*
|
|
165
|
+
* @param state - The `phase` and `error` of the checkout store.
|
|
166
|
+
* @param state.phase - Where the payment stands.
|
|
167
|
+
* @param state.error - The last failure; `payment_failed` means the transaction failed on-chain.
|
|
168
|
+
* @returns `true` to hand it over.
|
|
169
|
+
*/
|
|
170
|
+
declare function shouldHandOver(state: {
|
|
171
|
+
phase: CheckoutPhase;
|
|
172
|
+
error: CheckoutError | null;
|
|
173
|
+
}): boolean;
|
|
174
|
+
/** What {@link handOverPayment} needs. */
|
|
175
|
+
interface HandOverParams {
|
|
176
|
+
/** The adapter of the payment's chain family. */
|
|
177
|
+
adapter: PaymentsAdapter | undefined;
|
|
178
|
+
/** The app's Pulsar store, if any. */
|
|
179
|
+
pulsar: PaymentsPulsar | undefined;
|
|
180
|
+
/** The sent payment. */
|
|
181
|
+
payment: SentPayment;
|
|
182
|
+
/** The labels of the checkout language. */
|
|
183
|
+
labels: NovaPaymentsLabels;
|
|
184
|
+
/** The seller's name. */
|
|
185
|
+
merchant: string;
|
|
186
|
+
/** The invoice: its ID and number (`null` before its document is issued). */
|
|
187
|
+
invoice: {
|
|
188
|
+
id: string;
|
|
189
|
+
number: string | null;
|
|
190
|
+
};
|
|
191
|
+
/** The amount sent, with its symbol. */
|
|
192
|
+
amount: string;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Hands a sent payment over to the app's Pulsar store as a pending transaction: Pulsar tracks it and keeps it in the
|
|
196
|
+
* history, and Nova Transactions shows its toast. Without a Pulsar store, or an adapter that describes its
|
|
197
|
+
* transactions, nothing happens.
|
|
198
|
+
*
|
|
199
|
+
* Side effects: writes the transaction to the Pulsar store (persisted to `localStorage` by `createPulsarStore`) and
|
|
200
|
+
* starts its tracker (network reads).
|
|
201
|
+
*
|
|
202
|
+
* @param params - See {@link HandOverParams}.
|
|
203
|
+
* @returns Whether the payment was handed over.
|
|
204
|
+
*/
|
|
205
|
+
declare function handOverPayment({ adapter, pulsar, payment, labels, merchant, invoice, amount, }: HandOverParams): Promise<boolean>;
|
|
206
|
+
|
|
207
|
+
/** What the parts of a checkout share: its store and state, the screen, the language and its labels. */
|
|
208
|
+
interface CheckoutContextValue {
|
|
209
|
+
/** The checkout store of the invoice. */
|
|
210
|
+
store: CheckoutStore;
|
|
211
|
+
/** The state of the store. */
|
|
212
|
+
state: CheckoutState;
|
|
213
|
+
/** The checkout, once loaded. */
|
|
214
|
+
checkout: CheckoutView | null;
|
|
215
|
+
/** The screen shown. */
|
|
216
|
+
screen: CheckoutScreen;
|
|
217
|
+
/** The language of the checkout (a BCP 47 tag). */
|
|
218
|
+
locale: string;
|
|
219
|
+
/** The labels of that language. */
|
|
220
|
+
labels: NovaPaymentsLabels;
|
|
221
|
+
/** `Date.now()` of the latest second tick. */
|
|
222
|
+
now: number;
|
|
223
|
+
/** Closes the checkout; `undefined` when it cannot be closed (inline without `onClose`). */
|
|
224
|
+
close?: () => void;
|
|
225
|
+
/** The wallet connected through Satellite Connect, if any. */
|
|
226
|
+
wallet: CheckoutWallet | null;
|
|
227
|
+
/** How the buyer pays: from a wallet in this browser, or with a QR code on a phone. */
|
|
228
|
+
payWith: 'wallet' | 'qr';
|
|
229
|
+
/**
|
|
230
|
+
* Sets how the buyer pays.
|
|
231
|
+
*
|
|
232
|
+
* @param payWith - `wallet` or `qr`.
|
|
233
|
+
*/
|
|
234
|
+
setPayWith: (payWith: 'wallet' | 'qr') => void;
|
|
235
|
+
/** The payment page of the invoice (its `payUrl`), for the QR code of an EVM method. */
|
|
236
|
+
payUrl?: string;
|
|
237
|
+
/**
|
|
238
|
+
* Asks the buyer to connect a wallet of the method's chain family; the price is locked for it once connected.
|
|
239
|
+
*
|
|
240
|
+
* @param method - The chosen method.
|
|
241
|
+
* @returns Whether the page can connect a wallet (Nova Connect or the app's handler).
|
|
242
|
+
*/
|
|
243
|
+
connectWallet: (method: CheckoutMethod) => boolean;
|
|
244
|
+
/**
|
|
245
|
+
* The adapter that pays a chain family from the connected wallet.
|
|
246
|
+
*
|
|
247
|
+
* @param family - The family.
|
|
248
|
+
* @returns The adapter of `NovaPaymentsProvider`, if any.
|
|
249
|
+
*/
|
|
250
|
+
adapterFor: (family: PaymentFamily) => PaymentsAdapter | undefined;
|
|
251
|
+
/** The buyer continues on a phone: the QR code of the payment page shows before any price. */
|
|
252
|
+
handoff: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Shows or hides the QR code of the payment page.
|
|
255
|
+
*
|
|
256
|
+
* @param handoff - Whether it shows.
|
|
257
|
+
*/
|
|
258
|
+
setHandoff: (handoff: boolean) => void;
|
|
259
|
+
/** Goes back to the method step: forgets the locked price and the phone hand-off. */
|
|
260
|
+
backToMethods: () => void;
|
|
261
|
+
/**
|
|
262
|
+
* Remembers the payment the wallet sent: the checkout tracks it while open, and hands it over to the app's Pulsar
|
|
263
|
+
* store when it closes before Quasar settled it.
|
|
264
|
+
*
|
|
265
|
+
* @param payment - The transaction and what it pays.
|
|
266
|
+
*/
|
|
267
|
+
onPaymentSent: (payment: SentPayment) => void;
|
|
268
|
+
/** The buyer opened the automatic payments offer after paying a subscription period. */
|
|
269
|
+
autoPay: boolean;
|
|
270
|
+
/**
|
|
271
|
+
* Opens or closes the automatic payments offer.
|
|
272
|
+
*
|
|
273
|
+
* @param autoPay - Whether it shows.
|
|
274
|
+
*/
|
|
275
|
+
setAutoPay: (autoPay: boolean) => void;
|
|
276
|
+
/**
|
|
277
|
+
* Opens another invoice in this checkout: the one that replaced a corrected invoice.
|
|
278
|
+
*
|
|
279
|
+
* @param token - Its checkout token.
|
|
280
|
+
*/
|
|
281
|
+
openInvoice: (token: string) => void;
|
|
282
|
+
/** Replaces the link of "Contact <seller>", when the app handles it. */
|
|
283
|
+
onContact?: () => void;
|
|
284
|
+
/** Seconds before the paid outcome sends the buyer back to the seller; `0` for no automatic return. */
|
|
285
|
+
autoReturnSeconds: number;
|
|
286
|
+
}
|
|
287
|
+
declare const CheckoutContext: react.Context<CheckoutContextValue | null>;
|
|
288
|
+
/** Gives the parts of a checkout what they share. @internal */
|
|
289
|
+
declare const CheckoutContextProvider: react.Provider<CheckoutContextValue | null>;
|
|
290
|
+
|
|
291
|
+
/** Props of {@link CheckoutHeader}. */
|
|
292
|
+
interface CheckoutHeaderProps {
|
|
293
|
+
/** The heading of an outcome screen, shown instead of the steps. */
|
|
294
|
+
title?: ReactNode;
|
|
295
|
+
/** The checkout asked for the buyer details first: the steps start with them. */
|
|
296
|
+
withDetails?: boolean;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* The header of the checkout: the steps (or the heading of an outcome), then the language menu and the close button,
|
|
300
|
+
* which stay in the top right corner on every screen and on a phone. On a phone the steps move under the order and
|
|
301
|
+
* the header shows the merchant.
|
|
302
|
+
*
|
|
303
|
+
* @param props - See {@link CheckoutHeaderProps}.
|
|
304
|
+
* @returns The header.
|
|
305
|
+
*/
|
|
306
|
+
declare function CheckoutHeader({ title, withDetails }: CheckoutHeaderProps): react.JSX.Element;
|
|
307
|
+
/** The steps on a phone, under the order. @internal */
|
|
308
|
+
declare function MobileSteps({ withDetails }: {
|
|
309
|
+
withDetails?: boolean;
|
|
310
|
+
}): react.JSX.Element | null;
|
|
311
|
+
|
|
312
|
+
/** Props of {@link CheckoutStepper}. */
|
|
313
|
+
interface CheckoutStepperProps {
|
|
314
|
+
/** The steps, from `checkoutSteps`. */
|
|
315
|
+
steps: CheckoutStep[];
|
|
316
|
+
/** The labels of the checkout language. */
|
|
317
|
+
labels: NovaPaymentsLabels;
|
|
318
|
+
/** Classes added to the list. */
|
|
319
|
+
className?: string;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* The steps of the payment, as an ordered list: done steps show a check, the current one is marked
|
|
323
|
+
* `aria-current="step"` and named "Step 2 of 3: Pay" to screen readers (WCAG 1.3.1).
|
|
324
|
+
*
|
|
325
|
+
* @param props - See {@link CheckoutStepperProps}.
|
|
326
|
+
* @returns The stepper.
|
|
327
|
+
*/
|
|
328
|
+
declare function CheckoutStepper({ steps, labels, className }: CheckoutStepperProps): react.JSX.Element;
|
|
329
|
+
|
|
330
|
+
/** The merchant's logo (or the first letter of its name), name and website, and the test badge. @internal */
|
|
331
|
+
declare function MerchantBadge({ compact }: {
|
|
332
|
+
compact?: boolean;
|
|
333
|
+
}): react.JSX.Element | null;
|
|
334
|
+
/** The seller as the invoice document names them, the merchant's policies and what Quasar is. @internal */
|
|
335
|
+
declare function SellerDetailsContent({ checkout, labels }: {
|
|
336
|
+
checkout: CheckoutView;
|
|
337
|
+
labels: NovaPaymentsLabels;
|
|
338
|
+
}): react.JSX.Element;
|
|
339
|
+
/** The countdown to the invoice deadline, while the invoice can be paid. @internal */
|
|
340
|
+
declare function DeadlineTimer(): react.JSX.Element | null;
|
|
341
|
+
/** The lines, subtotal and tax of the invoice. @internal */
|
|
342
|
+
declare function OrderLines(): react.JSX.Element | null;
|
|
343
|
+
/** The total of the invoice, which stays in place while the lines scroll. @internal */
|
|
344
|
+
declare function OrderTotal(): react.JSX.Element | null;
|
|
345
|
+
/** "Secured by Quasar" and the seller's support email, at the same place on every step (WCAG 3.2.6). @internal */
|
|
346
|
+
declare function SummaryFooter(): react.JSX.Element;
|
|
347
|
+
/**
|
|
348
|
+
* The order panel on the left of the checkout (from 640 px): the merchant, the seller details (unfolded in place, the
|
|
349
|
+
* lines scroll while the deadline and the total stay), the countdown, the lines and the total, and the help.
|
|
350
|
+
*
|
|
351
|
+
* @returns The order panel.
|
|
352
|
+
*/
|
|
353
|
+
declare function CheckoutSummary(): react.JSX.Element | null;
|
|
354
|
+
/**
|
|
355
|
+
* The order on a phone, above the steps: the total and the countdown, with the lines and the seller details behind a
|
|
356
|
+
* "Details" button.
|
|
357
|
+
*
|
|
358
|
+
* @returns The compact order.
|
|
359
|
+
*/
|
|
360
|
+
declare function CompactSummary(): react.JSX.Element | null;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* The confirm step: the transaction is on its way and Quasar follows it until it is final. It reuses the status and
|
|
364
|
+
* progress of Nova Transactions (Sent → Confirming → Paid, in the language of the checkout) and shows the network, the
|
|
365
|
+
* amount, the transaction with its explorer link and the sender. The buyer may close the window: the payment keeps
|
|
366
|
+
* going.
|
|
367
|
+
*
|
|
368
|
+
* @returns The confirm step.
|
|
369
|
+
*/
|
|
370
|
+
declare function ConfirmScreen(): react.JSX.Element;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* The question when the buyer closes the checkout before anything is sent: the invoice stays open until its deadline,
|
|
374
|
+
* reopened from the email or the seller's site, and the locked price is released. "Stay and pay" keeps the checkout,
|
|
375
|
+
* "Leave" closes it. The heading takes the focus.
|
|
376
|
+
*
|
|
377
|
+
* @param props - The answers.
|
|
378
|
+
* @param props.onStay - Keeps the checkout open.
|
|
379
|
+
* @param props.onLeave - Closes it.
|
|
380
|
+
* @returns The question, over the checkout.
|
|
381
|
+
*/
|
|
382
|
+
declare function LeaveDialog({ onStay, onLeave }: {
|
|
383
|
+
onStay: () => void;
|
|
384
|
+
onLeave: () => void;
|
|
385
|
+
}): react.JSX.Element;
|
|
386
|
+
|
|
387
|
+
/** Props of {@link LocaleSwitcher}. */
|
|
388
|
+
interface LocaleSwitcherProps {
|
|
389
|
+
/** The language of the checkout. */
|
|
390
|
+
locale: string;
|
|
391
|
+
/** The labels of that language. */
|
|
392
|
+
labels: NovaPaymentsLabels;
|
|
393
|
+
/** Whether the receipt is issued: then the language changes the page only. */
|
|
394
|
+
receiptIssued?: boolean;
|
|
395
|
+
/**
|
|
396
|
+
* Called with the language the buyer picks.
|
|
397
|
+
*
|
|
398
|
+
* @param locale - The picked language.
|
|
399
|
+
*/
|
|
400
|
+
onSelect: (locale: CheckoutLocale) => void;
|
|
401
|
+
/** Classes added to the wrapper. */
|
|
402
|
+
className?: string;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* The language menu of the checkout: a button with a globe and the language code, always next to the close button,
|
|
406
|
+
* that opens the six languages under their own names (each with its `lang`). Arrow keys move, Enter or Space picks,
|
|
407
|
+
* Escape closes and gives the focus back to the button; a click outside closes it. Before payment the note says the
|
|
408
|
+
* documents follow the language.
|
|
409
|
+
*
|
|
410
|
+
* Side effect: while open, a `pointerdown` listener on the document closes it on a click outside.
|
|
411
|
+
*
|
|
412
|
+
* @param props - See {@link LocaleSwitcherProps}.
|
|
413
|
+
* @returns The language menu.
|
|
414
|
+
*/
|
|
415
|
+
declare function LocaleSwitcher({ locale, labels, receiptIssued, onSelect, className }: LocaleSwitcherProps): react.JSX.Element;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* The method step: the token first, then its network (left out when the token has one), then how to pay — from a
|
|
419
|
+
* wallet in this browser or with a QR code on a phone. The connected wallet's network comes first and is marked, the
|
|
420
|
+
* merchant's Popular methods next; a discount or markup of a method shows on it. Paying from a wallet needs the chain
|
|
421
|
+
* adapter of the method's family (`adapters` of `NovaPaymentsProvider`). "Continue" locks the price for the connected
|
|
422
|
+
* wallet (or connects one first), locks it without a payer for a Solana Pay QR code, or shows the QR code of the
|
|
423
|
+
* payment page for an EVM method paid on a phone.
|
|
424
|
+
*
|
|
425
|
+
* @returns The method step.
|
|
426
|
+
*/
|
|
427
|
+
declare function MethodScreen(): react.JSX.Element | null;
|
|
428
|
+
|
|
429
|
+
/** The outcomes this screen shows. */
|
|
430
|
+
type OutcomeKind = Extract<CheckoutScreen, 'underpaid' | 'held' | 'refunded' | 'expired' | 'cancelled' | 'replaced' | 'blocked'>;
|
|
431
|
+
/**
|
|
432
|
+
* An outcome other than paid: an underpaid invoice ("Pay the rest"), a payment the seller reviews (screening, late,
|
|
433
|
+
* overpaid), a refunded, expired or cancelled invoice, a corrected one ("Open <new invoice>" opens it here) and a payer
|
|
434
|
+
* the wallet check refused ("Use another wallet"). Each offers to contact the seller.
|
|
435
|
+
*
|
|
436
|
+
* @param props - The outcome.
|
|
437
|
+
* @param props.kind - Which outcome.
|
|
438
|
+
* @returns The outcome step.
|
|
439
|
+
*/
|
|
440
|
+
declare function OutcomeScreen({ kind }: {
|
|
441
|
+
kind: OutcomeKind;
|
|
442
|
+
}): react.JSX.Element | null;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* The paid outcome: the amount, network, time and transaction, the steps done, a refund made later, the receipt to
|
|
446
|
+
* download, the automatic payments offer of a subscription, and the way back to the seller (`successUrl`) with a
|
|
447
|
+
* visible countdown and "Stay here" (WCAG 2.2.1).
|
|
448
|
+
*
|
|
449
|
+
* Side effects: navigates to the seller's `successUrl` when the countdown ends.
|
|
450
|
+
*
|
|
451
|
+
* @returns The paid outcome.
|
|
452
|
+
*/
|
|
453
|
+
declare function PaidScreen(): react.JSX.Element | null;
|
|
454
|
+
|
|
455
|
+
/** Where the checkout is shown. */
|
|
456
|
+
type PaymentCheckoutDisplay = 'modal' | 'inline' | 'page';
|
|
457
|
+
/** Props of {@link PaymentCheckout}. */
|
|
458
|
+
interface PaymentCheckoutProps {
|
|
459
|
+
/** The checkout token of the invoice (its `checkoutToken`, or the end of its `payUrl`). */
|
|
460
|
+
token: string;
|
|
461
|
+
/**
|
|
462
|
+
* `modal` (default): a dialog over the page, a sheet from the bottom under 640 px; `inline`: a block in the page;
|
|
463
|
+
* `page`: the block centered on its own page, as the Quasar payment page shows it.
|
|
464
|
+
*/
|
|
465
|
+
display?: PaymentCheckoutDisplay;
|
|
466
|
+
/** Whether the modal is open (`display="modal"`; default `true`). */
|
|
467
|
+
open?: boolean;
|
|
468
|
+
/**
|
|
469
|
+
* Called when the modal opens or closes.
|
|
470
|
+
*
|
|
471
|
+
* @param open - The new state.
|
|
472
|
+
*/
|
|
473
|
+
onOpenChange?: (open: boolean) => void;
|
|
474
|
+
/** Called when the buyer closes the checkout; without it an inline checkout has no close button. */
|
|
475
|
+
onClose?: () => void;
|
|
476
|
+
/** The Quasar API; overrides `baseUrl` of `NovaPaymentsProvider`. */
|
|
477
|
+
baseUrl?: string;
|
|
478
|
+
/** Calls to make instead of the HTTP ones, for tests and simulations (`CheckoutApi` of `@tuwaio/quasar-sdk/checkout`). */
|
|
479
|
+
api?: CheckoutApi;
|
|
480
|
+
/** The `EventSource` to follow the invoice with; `null` reads it every `pollMs` (default: the browser's). */
|
|
481
|
+
EventSource?: EventSourceConstructor | null;
|
|
482
|
+
/** How often to read the invoice without an event stream, in milliseconds (default `5000`). */
|
|
483
|
+
pollMs?: number;
|
|
484
|
+
/**
|
|
485
|
+
* The payment page of the invoice (its `payUrl` from the Quasar API): with it, an EVM method can also be paid by
|
|
486
|
+
* scanning a QR code that opens the page on a phone.
|
|
487
|
+
*/
|
|
488
|
+
payUrl?: string;
|
|
489
|
+
/**
|
|
490
|
+
* Connects a wallet of a chain family, for apps without Nova Connect. Inside `NovaConnectProvider` the checkout opens
|
|
491
|
+
* its connect modal instead.
|
|
492
|
+
*
|
|
493
|
+
* @param family - The family of the chosen method.
|
|
494
|
+
*/
|
|
495
|
+
onConnectWallet?: (family: PaymentFamily) => void;
|
|
496
|
+
/**
|
|
497
|
+
* Called once when the invoice is paid (Quasar confirmed the payment). Fulfil orders from the `invoice.paid` webhook
|
|
498
|
+
* on your server: this callback is for the page only.
|
|
499
|
+
*
|
|
500
|
+
* @param invoice - The paid invoice.
|
|
501
|
+
*/
|
|
502
|
+
onPaid?: (invoice: CheckoutView['invoice']) => void;
|
|
503
|
+
/**
|
|
504
|
+
* Seconds before the paid outcome sends the buyer back to the invoice's `successUrl`, with a visible countdown and
|
|
505
|
+
* "Stay here" (default `5`; `0` for no automatic return).
|
|
506
|
+
*/
|
|
507
|
+
autoReturnSeconds?: number;
|
|
508
|
+
/** Replaces the link of "Contact <seller>" (the seller's support email, else site) with the app's own handler. */
|
|
509
|
+
onContact?: () => void;
|
|
510
|
+
/** Classes added to the checkout block. */
|
|
511
|
+
className?: string;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* The checkout of a Quasar Payments invoice, opened by its checkout token: the order, the steps of the payment and
|
|
515
|
+
* its outcome, in the language of the invoice. It reads the invoice with `createCheckoutStore` of
|
|
516
|
+
* `@tuwaio/quasar-sdk/checkout` and follows it until it is final; no secret key reaches the browser.
|
|
517
|
+
*
|
|
518
|
+
* Side effects: requests to the checkout routes of the Quasar API (`baseUrl`) and an `EventSource` on the invoice
|
|
519
|
+
* events while the invoice can change; changing the language saves it on the invoice (`POST locale`).
|
|
520
|
+
*
|
|
521
|
+
* @param props - See {@link PaymentCheckoutProps}.
|
|
522
|
+
* @returns The checkout.
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
* ```tsx
|
|
526
|
+
* import { PaymentCheckout } from '@tuwaio/nova-payments';
|
|
527
|
+
* import { useState } from 'react';
|
|
528
|
+
*
|
|
529
|
+
* export function PayButton({ token }: { token: string }) {
|
|
530
|
+
* const [open, setOpen] = useState(false);
|
|
531
|
+
* return (
|
|
532
|
+
* <>
|
|
533
|
+
* <button onClick={() => setOpen(true)}>Pay</button>
|
|
534
|
+
* <PaymentCheckout token={token} open={open} onOpenChange={setOpen} />
|
|
535
|
+
* </>
|
|
536
|
+
* );
|
|
537
|
+
* }
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
declare function PaymentCheckout({ token, display, open, onOpenChange, onClose, baseUrl, api, EventSource, pollMs, payUrl, onConnectWallet, onPaid, autoReturnSeconds, onContact, className, }: PaymentCheckoutProps): react.JSX.Element;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* The pay step: the connected wallet (with "Change"), the exact amount to send with its network and invoice value,
|
|
544
|
+
* the price lock with "Keep this price" in its last minute, the rate, the network fee (the merchant's or an estimate),
|
|
545
|
+
* the recipient, and the main action — "Sign to pay" when the merchant pays the gas, "Pay" otherwise, "Switch to …"
|
|
546
|
+
* on the wrong network. Before the prompt it reads the wallet's balance and, when it is short, offers the methods
|
|
547
|
+
* the wallet can pay and the seller's top-up link.
|
|
548
|
+
*
|
|
549
|
+
* Side effects: balance, fee and wallet capability reads from the network through the chain adapter (no request to
|
|
550
|
+
* Quasar); wallet prompts; checkout requests to Quasar.
|
|
551
|
+
*
|
|
552
|
+
* @returns The pay step.
|
|
553
|
+
*/
|
|
554
|
+
declare function PayScreen(): react.JSX.Element | null;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* The QR code step. For Solana, a Solana Pay transfer request a phone wallet scans (or opens with "Open in wallet
|
|
558
|
+
* app"), with the exact amount, the recipient, the price lock and a warning against paying from an exchange; the page
|
|
559
|
+
* waits for the payment, which Quasar finds by the reference key. For an EVM method, the QR code of the payment page
|
|
560
|
+
* opens this checkout on the phone, before any price.
|
|
561
|
+
*
|
|
562
|
+
* @returns The QR code step.
|
|
563
|
+
*/
|
|
564
|
+
declare function QrScreen(): react.JSX.Element | null;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* What the wallet asks for: a gasless signature, a transaction, a network switch, the permission of automatic
|
|
568
|
+
* payments, or Quasar takes the payment.
|
|
569
|
+
*/
|
|
570
|
+
type WalletPromptKind = 'sign' | 'confirm' | 'switch' | 'permission' | 'submitting';
|
|
571
|
+
/** Props of {@link WalletPrompt}. */
|
|
572
|
+
interface WalletPromptProps {
|
|
573
|
+
/** What the wallet asks for. */
|
|
574
|
+
kind: WalletPromptKind;
|
|
575
|
+
/** The wallet's name. */
|
|
576
|
+
walletName: string;
|
|
577
|
+
/** The wallet's id, for its icon. */
|
|
578
|
+
walletId: string;
|
|
579
|
+
/** The amount with its symbol. */
|
|
580
|
+
amount: string;
|
|
581
|
+
/** The seller. */
|
|
582
|
+
merchant: string;
|
|
583
|
+
/** The network of the payment. */
|
|
584
|
+
network: string;
|
|
585
|
+
/** The recipient, shortened (not copyable: it is checked, never typed). */
|
|
586
|
+
to: string;
|
|
587
|
+
/** The countdown of the price lock; `null` once it ended. */
|
|
588
|
+
priceTime: string | null;
|
|
589
|
+
/** Asks the wallet again; only where a second request cannot pay twice (a signature). */
|
|
590
|
+
onRetry?: () => void;
|
|
591
|
+
/** Closes the window. */
|
|
592
|
+
onCancel: () => void;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* The window over the pay step while the wallet asks the buyer: what to sign or confirm, and what to check in the
|
|
596
|
+
* wallet before — the amount, the recipient, the network and the time left of the price (WCAG 3.3.4). The heading
|
|
597
|
+
* takes the focus, so screen readers say what happens. "Try again" re-asks only for a signature; for a transaction
|
|
598
|
+
* the buyer is sent to the wallet, where the request still waits, so it cannot be paid twice.
|
|
599
|
+
*
|
|
600
|
+
* @param props - See {@link WalletPromptProps}.
|
|
601
|
+
* @returns The window.
|
|
602
|
+
*/
|
|
603
|
+
declare function WalletPrompt({ kind, walletName, walletId, amount, merchant, network, to, priceTime, onRetry, onCancel, }: WalletPromptProps): react.JSX.Element;
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Reads a value once per key: again when the key changes, never for a `null` key. An answer for an old key is
|
|
607
|
+
* dropped. Used for the balances and fee estimates the pay step reads from the network.
|
|
608
|
+
*
|
|
609
|
+
* @param key - What the value depends on, as a string; `null` to read nothing.
|
|
610
|
+
* @param load - Reads the value for the current key.
|
|
611
|
+
* @returns The value; `undefined` while it is read (or without a key); `null` when the read failed.
|
|
612
|
+
*/
|
|
613
|
+
declare function useAsyncValue<T>(key: string | null, load: () => Promise<T> | T): T | null | undefined;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* What the parts of the surrounding `PaymentCheckout` share, for components that replace its parts.
|
|
617
|
+
*
|
|
618
|
+
* @returns The checkout context.
|
|
619
|
+
* @throws When called outside a `PaymentCheckout`.
|
|
620
|
+
*/
|
|
621
|
+
declare function useCheckoutContext(): CheckoutContextValue;
|
|
622
|
+
|
|
623
|
+
/** What {@link useCheckoutStore} takes. */
|
|
624
|
+
interface UseCheckoutStoreOptions {
|
|
625
|
+
/** The checkout token of the invoice. */
|
|
626
|
+
token: string;
|
|
627
|
+
/** The Quasar API. */
|
|
628
|
+
baseUrl?: string;
|
|
629
|
+
/** Calls to make instead of the HTTP ones, for tests and simulations; read when the store is created. */
|
|
630
|
+
api?: CheckoutApi;
|
|
631
|
+
/** The `EventSource` to follow the invoice with (`null`: read it every `pollMs`); read when the store is created. */
|
|
632
|
+
EventSource?: EventSourceConstructor | null;
|
|
633
|
+
/** How often to read the invoice without an event stream, in milliseconds. */
|
|
634
|
+
pollMs?: number;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* The checkout store of an invoice (`createCheckoutStore` from `@tuwaio/quasar-sdk/checkout`): created and loaded
|
|
638
|
+
* after mount, destroyed on unmount or when `token` or `baseUrl` change. Until then it is a store in the `loading`
|
|
639
|
+
* phase that makes no requests.
|
|
640
|
+
*
|
|
641
|
+
* Side effects: the store reads the checkout and follows the invoice (an `EventSource` on its `events` route, or a
|
|
642
|
+
* request every `pollMs`) until the invoice is final.
|
|
643
|
+
*
|
|
644
|
+
* @param options - See {@link UseCheckoutStoreOptions}.
|
|
645
|
+
* @returns The store.
|
|
646
|
+
*/
|
|
647
|
+
declare function useCheckoutStore(options: UseCheckoutStoreOptions): CheckoutStore;
|
|
648
|
+
/**
|
|
649
|
+
* Reads a checkout store and re-renders when the selected part changes (`useStore` of `zustand`).
|
|
650
|
+
*
|
|
651
|
+
* @param store - The store, from {@link useCheckoutStore}.
|
|
652
|
+
* @param selector - What to read.
|
|
653
|
+
* @returns The selected part of the state.
|
|
654
|
+
*/
|
|
655
|
+
declare function useCheckoutState<T>(store: CheckoutStore, selector: (state: CheckoutState) => T): T;
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* The wallet connected through Satellite Connect (the active connection of `SatelliteConnectProvider` from
|
|
659
|
+
* `@tuwaio/satellite-react`), in CAIP identifiers; `null` without a connection or without the provider, in which case
|
|
660
|
+
* the checkout offers the QR code and the wallet connection only.
|
|
661
|
+
*
|
|
662
|
+
* @returns The wallet, or `null`.
|
|
663
|
+
*/
|
|
664
|
+
declare function useConnectedWallet(): CheckoutWallet | null;
|
|
665
|
+
|
|
666
|
+
/** What the labels customization of {@link NovaPaymentsProvider} gets with the labels it transforms. */
|
|
667
|
+
interface NovaPaymentsLabelsContext {
|
|
668
|
+
/** The language of the checkout. */
|
|
669
|
+
locale: CheckoutLocale | string;
|
|
670
|
+
}
|
|
671
|
+
/** Customization of {@link NovaPaymentsProvider}. */
|
|
672
|
+
type NovaPaymentsProviderCustomization = {
|
|
673
|
+
/** Labels. */
|
|
674
|
+
labels?: {
|
|
675
|
+
/**
|
|
676
|
+
* Changes the labels of a language after the built-in ones and `labels` are applied, for example to translate a
|
|
677
|
+
* language the package does not have.
|
|
678
|
+
*
|
|
679
|
+
* @param labels - The labels of the language with `labels` applied.
|
|
680
|
+
* @param context - The language.
|
|
681
|
+
* @returns The labels to use.
|
|
682
|
+
*/
|
|
683
|
+
transform?: (labels: NovaPaymentsLabels, context: NovaPaymentsLabelsContext) => NovaPaymentsLabels;
|
|
684
|
+
};
|
|
685
|
+
};
|
|
686
|
+
/** Props of {@link NovaPaymentsProvider}. */
|
|
687
|
+
interface NovaPaymentsProviderProps {
|
|
688
|
+
/** The Quasar API (Quasar Cloud by default, the address of your node for the Community Edition). */
|
|
689
|
+
baseUrl?: string;
|
|
690
|
+
/** Texts to replace in every language. */
|
|
691
|
+
labels?: NovaPaymentsLabelOverrides;
|
|
692
|
+
/** Customization of the labels. */
|
|
693
|
+
customization?: NovaPaymentsProviderCustomization;
|
|
694
|
+
/**
|
|
695
|
+
* The chain families the checkouts pay from a connected wallet on: `paymentsEVMAdapter` of
|
|
696
|
+
* `@tuwaio/nova-payments/evm`, `paymentsSolanaAdapter` of `@tuwaio/nova-payments/solana`. Without the adapter of a
|
|
697
|
+
* method's family, the buyer pays that method with a QR code.
|
|
698
|
+
*/
|
|
699
|
+
adapters?: PaymentsAdapter[];
|
|
700
|
+
/**
|
|
701
|
+
* The app's Pulsar store (`injectExternalPendingTxs` of `createPulsarStore` from `@tuwaio/pulsar-core`). While a
|
|
702
|
+
* checkout is open it tracks the payment itself; when it closes before Quasar settled a payment the wallet sent, the
|
|
703
|
+
* payment goes to this store, which tracks it and keeps it in the history, and Nova Transactions shows its toast.
|
|
704
|
+
*/
|
|
705
|
+
pulsar?: PaymentsPulsar;
|
|
706
|
+
/** The app. */
|
|
707
|
+
children: ReactNode;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Gives the checkouts below it the Quasar API, the labels and the chain adapters. A checkout works without it, with
|
|
711
|
+
* Quasar Cloud, the built-in labels and QR payments only.
|
|
712
|
+
*
|
|
713
|
+
* @param props - See {@link NovaPaymentsProviderProps}.
|
|
714
|
+
* @returns The provider.
|
|
715
|
+
*
|
|
716
|
+
* @example
|
|
717
|
+
* ```tsx
|
|
718
|
+
* import { NovaPaymentsProvider, PaymentCheckout } from '@tuwaio/nova-payments';
|
|
719
|
+
*
|
|
720
|
+
* export function Checkout({ token }: { token: string }) {
|
|
721
|
+
* return (
|
|
722
|
+
* <NovaPaymentsProvider baseUrl="https://quasar.example.com" labels={{ steps: { pay: 'Payment' } }}>
|
|
723
|
+
* <PaymentCheckout token={token} display="inline" />
|
|
724
|
+
* </NovaPaymentsProvider>
|
|
725
|
+
* );
|
|
726
|
+
* }
|
|
727
|
+
* ```
|
|
728
|
+
*/
|
|
729
|
+
declare function NovaPaymentsProvider({ baseUrl, labels, customization, adapters, pulsar, children, }: NovaPaymentsProviderProps): react.JSX.Element;
|
|
730
|
+
|
|
731
|
+
/** The settings `NovaPaymentsProvider` gives the checkouts below it. */
|
|
732
|
+
interface NovaPaymentsSettings {
|
|
733
|
+
/** The Quasar API, if set. */
|
|
734
|
+
baseUrl?: string;
|
|
735
|
+
/** Texts to replace in every language. */
|
|
736
|
+
labels?: NovaPaymentsLabelOverrides;
|
|
737
|
+
/** Customization of the labels. */
|
|
738
|
+
customization?: NovaPaymentsProviderCustomization;
|
|
739
|
+
/** The chain families the checkouts pay from a connected wallet on. */
|
|
740
|
+
adapters?: PaymentsAdapter[];
|
|
741
|
+
/** The app's Pulsar store, which takes over the payments a checkout closed on. */
|
|
742
|
+
pulsar?: PaymentsPulsar;
|
|
743
|
+
}
|
|
744
|
+
/** The context of `NovaPaymentsProvider`. @internal */
|
|
745
|
+
declare const NovaPaymentsContext: react.Context<NovaPaymentsSettings>;
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* The settings of the nearest `NovaPaymentsProvider`; empty without one.
|
|
749
|
+
*
|
|
750
|
+
* @returns The settings.
|
|
751
|
+
*/
|
|
752
|
+
declare function useNovaPayments(): NovaPaymentsSettings;
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* The current time, updated every `intervalMs` while `active`.
|
|
756
|
+
*
|
|
757
|
+
* Side effect: an interval timer while active.
|
|
758
|
+
*
|
|
759
|
+
* @param intervalMs - How often to update, in milliseconds.
|
|
760
|
+
* @param active - Whether to update (stop on a final state to save renders).
|
|
761
|
+
* @returns `Date.now()` of the latest update.
|
|
762
|
+
*/
|
|
763
|
+
declare function useNow(intervalMs: number, active?: boolean): number;
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Tells the app once that the invoice is paid, when the checkout reaches the paid outcome.
|
|
767
|
+
*
|
|
768
|
+
* @param phase - Where the payment stands.
|
|
769
|
+
* @param invoice - The invoice of the checkout.
|
|
770
|
+
* @param onPaid - The app's callback, if any.
|
|
771
|
+
*/
|
|
772
|
+
declare function usePaidCallback(phase: CheckoutPhase, invoice: CheckoutView['invoice'] | undefined, onPaid: ((invoice: CheckoutView['invoice']) => void) | undefined): void;
|
|
773
|
+
/** What {@link useAutoReturn} needs. */
|
|
774
|
+
interface UseAutoReturnParams {
|
|
775
|
+
/** Where to send the buyer (the invoice's `successUrl`); `null` for no return. */
|
|
776
|
+
url: string | null;
|
|
777
|
+
/** Seconds before the return; `0` for no automatic return. */
|
|
778
|
+
seconds: number;
|
|
779
|
+
/** `Date.now()` of the latest second tick of the checkout. */
|
|
780
|
+
now: number;
|
|
781
|
+
/**
|
|
782
|
+
* Sends the buyer to the link (default: `window.location.assign`).
|
|
783
|
+
*
|
|
784
|
+
* @param url - The link.
|
|
785
|
+
*/
|
|
786
|
+
navigate?: (url: string) => void;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* The visible countdown before the paid outcome sends the buyer back to the seller, with "Stay here" (WCAG 2.2.1).
|
|
790
|
+
*
|
|
791
|
+
* Side effects: navigates the page when the countdown ends.
|
|
792
|
+
*
|
|
793
|
+
* @param params - See {@link UseAutoReturnParams}.
|
|
794
|
+
* @returns `left`: seconds before the return (`null` when there is none); `stay`: stops it.
|
|
795
|
+
*/
|
|
796
|
+
declare function useAutoReturn({ url, seconds, now, navigate, }: UseAutoReturnParams): {
|
|
797
|
+
left: number | null;
|
|
798
|
+
stay: () => void;
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* @file The payment of a locked price: how the wallet pays it, what the buyer sends and the merchant receives, the
|
|
803
|
+
* market rate behind it, and what a wallet lacks to pay it.
|
|
804
|
+
*/
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* How the wallet pays a quote: `relay` signs an EIP-3009 authorization that Quasar sends (the merchant pays the gas),
|
|
808
|
+
* `paymaster` sends the quoted calls with the checkout's ERC-7677 paymaster (a smart wallet; the merchant pays the
|
|
809
|
+
* gas), `transfer` sends the transfer and pays the gas.
|
|
810
|
+
*/
|
|
811
|
+
type PayPath = 'relay' | 'paymaster' | 'transfer';
|
|
812
|
+
/**
|
|
813
|
+
* How the wallet pays a quote. A smart wallet that takes a paymaster sends sponsored calls; any other wallet signs the
|
|
814
|
+
* authorization; the buyer may choose to pay the gas instead.
|
|
815
|
+
*
|
|
816
|
+
* @param quote - The locked quote.
|
|
817
|
+
* @param options - What the buyer and the wallet allow.
|
|
818
|
+
* @param options.withGas - The buyer chose "Pay with gas instead".
|
|
819
|
+
* @param options.canSponsorCalls - The wallet sends `wallet_sendCalls` with the `paymasterService` capability.
|
|
820
|
+
* @returns The path.
|
|
821
|
+
*/
|
|
822
|
+
declare function payPath(quote: CheckoutQuote, options: {
|
|
823
|
+
withGas: boolean;
|
|
824
|
+
canSponsorCalls: boolean;
|
|
825
|
+
}): PayPath;
|
|
826
|
+
/** What a quote moves, in base units of its token. */
|
|
827
|
+
interface QuoteAmounts {
|
|
828
|
+
/** What the buyer sends. */
|
|
829
|
+
send: string;
|
|
830
|
+
/** What the merchant receives. */
|
|
831
|
+
receives: string;
|
|
832
|
+
/** The token's transfer fee on top, with its percent; `null` when the token keeps none. */
|
|
833
|
+
fee: {
|
|
834
|
+
amount: string;
|
|
835
|
+
percent: string;
|
|
836
|
+
} | null;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* What the buyer sends and the merchant receives: the same amount, unless the token keeps a fee on every transfer.
|
|
840
|
+
*
|
|
841
|
+
* @param quote - The locked quote.
|
|
842
|
+
* @returns The amounts.
|
|
843
|
+
*/
|
|
844
|
+
declare function quoteAmounts(quote: CheckoutQuote): QuoteAmounts;
|
|
845
|
+
/**
|
|
846
|
+
* The market price of one token in the invoice currency behind a quote. Quasar asks for
|
|
847
|
+
* `total × (1 + markup) × (1 − discount) / price` tokens, so the price is recovered without the method's markup or
|
|
848
|
+
* discount, which the checkout shows apart. For display only: amounts are never derived from it.
|
|
849
|
+
*
|
|
850
|
+
* @param quote - The locked quote.
|
|
851
|
+
* @param totalMinor - The invoice total in minor units (cents) the quote pays.
|
|
852
|
+
* @returns The price, or `null` without a total or a token amount.
|
|
853
|
+
*/
|
|
854
|
+
declare function quoteRate(quote: CheckoutQuote, totalMinor: string | null): number | null;
|
|
855
|
+
/** What a wallet lacks for a payment, in base units. */
|
|
856
|
+
interface BalanceShortfall {
|
|
857
|
+
/** What the wallet has. */
|
|
858
|
+
have: string;
|
|
859
|
+
/** What the payment needs. */
|
|
860
|
+
need: string;
|
|
861
|
+
/** The difference. */
|
|
862
|
+
short: string;
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* What a wallet lacks to pay a quote.
|
|
866
|
+
*
|
|
867
|
+
* @param balance - The wallet's balance of the quoted token, in base units.
|
|
868
|
+
* @param quote - The locked quote.
|
|
869
|
+
* @param fee - The network fee, when it is paid in the quoted token (the native coin); counted in what is needed.
|
|
870
|
+
* @returns The shortfall, or `null` when the balance is enough.
|
|
871
|
+
*/
|
|
872
|
+
declare function balanceShortfall(balance: bigint, quote: CheckoutQuote, fee?: bigint): BalanceShortfall | null;
|
|
873
|
+
/**
|
|
874
|
+
* The CAIP-2 chain a quote is paid on.
|
|
875
|
+
*
|
|
876
|
+
* @param instructions - What the wallet sends.
|
|
877
|
+
* @returns For example `eip155:8453` or `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`.
|
|
878
|
+
*/
|
|
879
|
+
declare function instructionsChainId(instructions: PaymentInstructions): string;
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* @file Paying a locked price from the connected wallet, without React: the wallet prompt, then the hand-over to
|
|
883
|
+
* Quasar.
|
|
884
|
+
*/
|
|
885
|
+
|
|
886
|
+
/** What {@link payInvoice} needs. */
|
|
887
|
+
interface PayInvoiceParams {
|
|
888
|
+
/** The adapter of the quote's chain family. */
|
|
889
|
+
adapter: PaymentsAdapter;
|
|
890
|
+
/** The checkout store (only `submit` and `relay` are used). */
|
|
891
|
+
store: {
|
|
892
|
+
getState: () => Pick<CheckoutState, 'submit' | 'relay'>;
|
|
893
|
+
};
|
|
894
|
+
/** The locked quote. */
|
|
895
|
+
quote: CheckoutQuote;
|
|
896
|
+
/** The wallet the quote is locked to. */
|
|
897
|
+
wallet: CheckoutWallet;
|
|
898
|
+
/** How the wallet pays, from `payPath`. */
|
|
899
|
+
path: PayPath;
|
|
900
|
+
/** The checkout's ERC-7677 paymaster URL, for the `paymaster` path. */
|
|
901
|
+
paymasterUrl: string | null;
|
|
902
|
+
/** Called when the wallet answered, before the payment is handed to Quasar. */
|
|
903
|
+
onWalletDone?: () => void;
|
|
904
|
+
/**
|
|
905
|
+
* Called with the transaction the wallet sent (its hash), before Quasar takes it; not for a gasless signature, whose
|
|
906
|
+
* transaction Quasar sends.
|
|
907
|
+
*
|
|
908
|
+
* @param txKey - The transaction hash (EVM) or signature (Solana).
|
|
909
|
+
*/
|
|
910
|
+
onSent?: (txKey: string) => void;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Pays a locked quote: `transfer` sends the transfer and hands its key to Quasar (`submit`), `relay` signs the
|
|
914
|
+
* authorization for Quasar to send (`relay`), `paymaster` sends the sponsored calls and hands their transaction hash
|
|
915
|
+
* to Quasar. A transaction the wallet sent is always handed over, whatever the page shows meanwhile.
|
|
916
|
+
*
|
|
917
|
+
* Side effects: a wallet prompt; requests to the checkout routes of Quasar.
|
|
918
|
+
*
|
|
919
|
+
* @param params - See {@link PayInvoiceParams}.
|
|
920
|
+
* @returns Whether Quasar took the payment (the store's `error` says why not).
|
|
921
|
+
* @throws {@link PaymentWalletError} `unsupported` when the adapter or the quote cannot take the path; the wallet's
|
|
922
|
+
* error when it refuses or fails.
|
|
923
|
+
*/
|
|
924
|
+
declare function payInvoice({ adapter, store, quote, wallet, path, paymasterUrl, onWalletDone, onSent, }: PayInvoiceParams): Promise<boolean>;
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* @file Why a wallet did not pay: the buyer declined, the wallet cannot do it, or it failed.
|
|
928
|
+
*/
|
|
929
|
+
/** Why a wallet request did not go through. */
|
|
930
|
+
type PaymentWalletErrorKind = 'declined' | 'unsupported' | 'failed';
|
|
931
|
+
/** The error a payments adapter throws when it knows why the wallet did not pay. */
|
|
932
|
+
declare class PaymentWalletError extends Error {
|
|
933
|
+
readonly kind: PaymentWalletErrorKind;
|
|
934
|
+
/**
|
|
935
|
+
* @param kind - Why: `declined` by the buyer, `unsupported` by the wallet, or `failed`.
|
|
936
|
+
* @param message - What to log.
|
|
937
|
+
* @param options - The original error as `cause`.
|
|
938
|
+
*/
|
|
939
|
+
constructor(kind: PaymentWalletErrorKind, message: string, options?: {
|
|
940
|
+
cause?: unknown;
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Why a wallet request failed, from the error the wallet library threw: EIP-1193 code `4001` and viem's
|
|
945
|
+
* `UserRejectedRequestError` (also as a `cause`), and the "user rejected" messages of Wallet Standard wallets, are
|
|
946
|
+
* `declined`.
|
|
947
|
+
*
|
|
948
|
+
* @param error - What the wallet library threw.
|
|
949
|
+
* @returns `declined`, `unsupported` or `failed`.
|
|
950
|
+
*/
|
|
951
|
+
declare function walletErrorKind(error: unknown): PaymentWalletErrorKind;
|
|
952
|
+
|
|
953
|
+
/** Where a payment from the wallet stands: `wallet` while the wallet asks the buyer, `submitting` while Quasar takes it. */
|
|
954
|
+
type PaymentStatus = 'idle' | 'switching' | 'wallet' | 'submitting';
|
|
955
|
+
/** What {@link usePayment} needs. */
|
|
956
|
+
interface UsePaymentParams {
|
|
957
|
+
/** The adapter of the quote's chain family; without it the wallet cannot pay. */
|
|
958
|
+
adapter: PaymentsAdapter | undefined;
|
|
959
|
+
/** The checkout store. */
|
|
960
|
+
store: PayInvoiceParams['store'];
|
|
961
|
+
/** The locked quote. */
|
|
962
|
+
quote: CheckoutQuote | null;
|
|
963
|
+
/** The wallet the quote is locked to. */
|
|
964
|
+
wallet: CheckoutWallet | null;
|
|
965
|
+
/** How the wallet pays. */
|
|
966
|
+
path: PayPath;
|
|
967
|
+
/** The checkout's ERC-7677 paymaster URL. */
|
|
968
|
+
paymasterUrl: string | null;
|
|
969
|
+
/**
|
|
970
|
+
* Called with the payment the wallet sent (not a gasless signature, whose transaction Quasar sends).
|
|
971
|
+
*
|
|
972
|
+
* @param payment - The transaction and what it pays.
|
|
973
|
+
*/
|
|
974
|
+
onSent?: (payment: SentPayment) => void;
|
|
975
|
+
}
|
|
976
|
+
/** What {@link usePayment} returns. */
|
|
977
|
+
interface Payment {
|
|
978
|
+
/** Where the payment stands. */
|
|
979
|
+
status: PaymentStatus;
|
|
980
|
+
/** Why the wallet did not pay or switch, until the next try. */
|
|
981
|
+
problem: PaymentWalletErrorKind | null;
|
|
982
|
+
/** Pays the quote from the wallet; resolves when Quasar took it or the wallet refused. */
|
|
983
|
+
pay: () => Promise<void>;
|
|
984
|
+
/** Asks the wallet to switch to the quote's chain. */
|
|
985
|
+
switchNetwork: () => Promise<void>;
|
|
986
|
+
/**
|
|
987
|
+
* Closes the wallet window. A request the wallet still shows stays open there: a transaction it sends later is
|
|
988
|
+
* still handed to Quasar, a refusal is not shown.
|
|
989
|
+
*/
|
|
990
|
+
dismiss: () => void;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Pays a locked quote from the connected wallet and says where it stands, for the pay step.
|
|
994
|
+
*
|
|
995
|
+
* Side effects: wallet prompts; requests to the checkout routes of Quasar.
|
|
996
|
+
*
|
|
997
|
+
* @param params - See {@link UsePaymentParams}.
|
|
998
|
+
* @returns See {@link Payment}.
|
|
999
|
+
*/
|
|
1000
|
+
declare function usePayment({ adapter, store, quote, wallet, path, paymasterUrl, onSent }: UsePaymentParams): Payment;
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* What the confirm and paid steps show of the payment: its network and amount (from the locked quote), the
|
|
1004
|
+
* transaction (Quasar's hash, else the submitted key) with its explorer link from the chain adapter, and the sender.
|
|
1005
|
+
*
|
|
1006
|
+
* @returns The facts; each is `null` (or `undefined` for the link) when unknown.
|
|
1007
|
+
*/
|
|
1008
|
+
declare function usePaymentFacts(): {
|
|
1009
|
+
network: string | null;
|
|
1010
|
+
amount: string | null;
|
|
1011
|
+
txKey: string | null;
|
|
1012
|
+
explorerUrl: string | undefined;
|
|
1013
|
+
from: string | null;
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
/** What {@link usePaymentHandOver} needs. */
|
|
1017
|
+
interface UsePaymentHandOverParams {
|
|
1018
|
+
/** The checkout store (its state is read when the payment is handed over). */
|
|
1019
|
+
store: {
|
|
1020
|
+
getState: () => Pick<CheckoutState, 'phase' | 'error' | 'checkout'>;
|
|
1021
|
+
};
|
|
1022
|
+
/** Whether the checkout is open (a modal); an inline checkout stays open while it is shown. */
|
|
1023
|
+
open: boolean;
|
|
1024
|
+
/**
|
|
1025
|
+
* The adapter of a chain family.
|
|
1026
|
+
*
|
|
1027
|
+
* @param family - The family.
|
|
1028
|
+
* @returns The adapter, if any.
|
|
1029
|
+
*/
|
|
1030
|
+
adapterFor: (family: PaymentFamily) => PaymentsAdapter | undefined;
|
|
1031
|
+
/** The app's Pulsar store, if any. */
|
|
1032
|
+
pulsar: PaymentsPulsar | undefined;
|
|
1033
|
+
/** The labels of the checkout language. */
|
|
1034
|
+
labels: NovaPaymentsLabels;
|
|
1035
|
+
/** The checkout language (a BCP 47 tag). */
|
|
1036
|
+
locale: string;
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Follows the payment the wallet sent until the checkout closes: while it is open the checkout tracks the payment
|
|
1040
|
+
* itself; when it closes (or goes away) before Quasar settled the payment, the payment is handed over to the app's
|
|
1041
|
+
* Pulsar store, where Nova Transactions shows its toast. A wallet that sends after the checkout closed hands its
|
|
1042
|
+
* payment over at once.
|
|
1043
|
+
*
|
|
1044
|
+
* Side effects: on hand-over, a pending transaction in the Pulsar store and its tracker.
|
|
1045
|
+
*
|
|
1046
|
+
* @param params - See {@link UsePaymentHandOverParams}.
|
|
1047
|
+
* @returns The function to call with the payment the wallet sent.
|
|
1048
|
+
*/
|
|
1049
|
+
declare function usePaymentHandOver({ store, open, adapterFor, pulsar, labels, locale, }: UsePaymentHandOverParams): (payment: SentPayment) => void;
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* The labels of a language: the built-in ones (English for a language without its own), then `labels` of
|
|
1053
|
+
* `NovaPaymentsProvider`, then its `customization.labels.transform`.
|
|
1054
|
+
*
|
|
1055
|
+
* @param locale - The language of the checkout.
|
|
1056
|
+
* @returns The labels.
|
|
1057
|
+
*/
|
|
1058
|
+
declare function usePaymentsLabels(locale: string): NovaPaymentsLabels;
|
|
1059
|
+
|
|
1060
|
+
/** What {@link useWalletConnection} returns. */
|
|
1061
|
+
interface WalletConnection {
|
|
1062
|
+
/** Whether the page can connect a wallet: Nova Connect is set up, or the app handles it. */
|
|
1063
|
+
canConnect: boolean;
|
|
1064
|
+
/** Whether the connect modal of Nova Connect is open. */
|
|
1065
|
+
connecting: boolean;
|
|
1066
|
+
/**
|
|
1067
|
+
* Asks the buyer to connect a wallet of a chain family.
|
|
1068
|
+
*
|
|
1069
|
+
* @param family - The family of the chosen method.
|
|
1070
|
+
* @returns Whether the request went anywhere.
|
|
1071
|
+
*/
|
|
1072
|
+
connect: (family: PaymentFamily) => boolean;
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* Connects a wallet for a payment: opens the connect modal of Nova Connect on the wallets of the method's chain family
|
|
1076
|
+
* when the checkout is inside `NovaConnectProvider` of `@tuwaio/nova-connect`, else calls the app's handler.
|
|
1077
|
+
*
|
|
1078
|
+
* @param onConnectWallet - The app's handler, for apps that connect wallets without Nova Connect.
|
|
1079
|
+
* @returns See {@link WalletConnection}.
|
|
1080
|
+
*/
|
|
1081
|
+
declare function useWalletConnection(onConnectWallet?: (family: PaymentFamily) => void): WalletConnection;
|
|
1082
|
+
|
|
1083
|
+
/**
|
|
1084
|
+
* @file The buyer details the checkout collects when the merchant's settings ask for them (plan 12 §6.8): which
|
|
1085
|
+
* fields, what is missing, and the countries to pick from.
|
|
1086
|
+
*/
|
|
1087
|
+
|
|
1088
|
+
/** A field of the buyer details form. */
|
|
1089
|
+
interface BuyerField {
|
|
1090
|
+
/** The field of `Buyer`. */
|
|
1091
|
+
name: keyof Buyer;
|
|
1092
|
+
/** Whether the invoice needs it. */
|
|
1093
|
+
required: boolean;
|
|
1094
|
+
/** The `autocomplete` token, so browsers fill it in (WCAG 1.3.5). */
|
|
1095
|
+
autoComplete: string;
|
|
1096
|
+
/** The input type. */
|
|
1097
|
+
type: 'email' | 'text' | 'country';
|
|
1098
|
+
}
|
|
1099
|
+
/** Why a field is refused: missing, not an email, not a country code. */
|
|
1100
|
+
type BuyerIssue = 'required' | 'email' | 'country';
|
|
1101
|
+
/** What the checkout collects: `email` or `full` details (the checkout view's `buyer.collect`). */
|
|
1102
|
+
type BuyerCollect = 'email' | 'full';
|
|
1103
|
+
/**
|
|
1104
|
+
* The fields of the form, in order.
|
|
1105
|
+
*
|
|
1106
|
+
* @param collect - What the checkout collects.
|
|
1107
|
+
* @param company - The buyer wants an invoice for a company: name, address line, country and tax ID are needed.
|
|
1108
|
+
* @returns The fields.
|
|
1109
|
+
*/
|
|
1110
|
+
declare function buyerFields(collect: BuyerCollect, company: boolean): BuyerField[];
|
|
1111
|
+
/**
|
|
1112
|
+
* What is missing or invalid in the details, field by field.
|
|
1113
|
+
*
|
|
1114
|
+
* @param buyer - The details as typed.
|
|
1115
|
+
* @param collect - What the checkout collects.
|
|
1116
|
+
* @param company - Whether the buyer wants a company invoice.
|
|
1117
|
+
* @returns The issue of each refused field; empty when the details can be sent.
|
|
1118
|
+
*/
|
|
1119
|
+
declare function buyerIssues(buyer: Partial<Record<keyof Buyer, string>>, collect: BuyerCollect, company: boolean): Partial<Record<keyof Buyer, BuyerIssue>>;
|
|
1120
|
+
/**
|
|
1121
|
+
* The details to send: trimmed, empty ones left out, the country in capitals.
|
|
1122
|
+
*
|
|
1123
|
+
* @param buyer - The details as typed.
|
|
1124
|
+
* @returns The `Buyer` for `setBuyer` of the checkout store.
|
|
1125
|
+
*/
|
|
1126
|
+
declare function cleanBuyer(buyer: Partial<Record<keyof Buyer, string>>): Buyer;
|
|
1127
|
+
/**
|
|
1128
|
+
* The countries to pick from, named in the language of the page (`Intl.DisplayNames`) and sorted by name.
|
|
1129
|
+
*
|
|
1130
|
+
* @param locale - BCP 47 language of the page.
|
|
1131
|
+
* @returns The country codes and names.
|
|
1132
|
+
*/
|
|
1133
|
+
declare function countryOptions(locale: string): {
|
|
1134
|
+
code: string;
|
|
1135
|
+
name: string;
|
|
1136
|
+
}[];
|
|
1137
|
+
|
|
1138
|
+
/**
|
|
1139
|
+
* @file Numbers, amounts, addresses and countdowns as the checkout shows them, in the language of the page.
|
|
1140
|
+
*/
|
|
1141
|
+
/**
|
|
1142
|
+
* A decimal string from an integer amount of minor units (cents), without floating point.
|
|
1143
|
+
*
|
|
1144
|
+
* @param minor - Minor units, as a decimal integer string (may be negative).
|
|
1145
|
+
* @param digits - Minor digits of the currency (default `2`).
|
|
1146
|
+
* @returns The decimal, for example `89.54` for `8954`.
|
|
1147
|
+
*/
|
|
1148
|
+
declare function minorToDecimal(minor: string, digits?: number): string;
|
|
1149
|
+
/**
|
|
1150
|
+
* A fiat amount with two decimals and the grouping of the language, without the currency (the checkout shows its
|
|
1151
|
+
* code next to it).
|
|
1152
|
+
*
|
|
1153
|
+
* @param amount - A decimal string or a number.
|
|
1154
|
+
* @param locale - BCP 47 language of the page.
|
|
1155
|
+
* @returns The formatted amount, for example `1,234.50` in English and `1 234,50` in Russian.
|
|
1156
|
+
*/
|
|
1157
|
+
declare function formatFiat(amount: string | number, locale: string): string;
|
|
1158
|
+
/**
|
|
1159
|
+
* A token amount from base units, exact: every decimal the amount has (at least two), never rounded, with the
|
|
1160
|
+
* grouping of the language. What the buyer sends must match the wallet to the last digit.
|
|
1161
|
+
*
|
|
1162
|
+
* @param baseUnits - Base units, as a decimal integer string.
|
|
1163
|
+
* @param decimals - Decimals of the token.
|
|
1164
|
+
* @param locale - BCP 47 language of the page.
|
|
1165
|
+
* @returns The formatted amount, for example `89.54` for `89540000` with 6 decimals.
|
|
1166
|
+
*/
|
|
1167
|
+
declare function formatTokenAmount(baseUnits: string, decimals: number, locale: string): string;
|
|
1168
|
+
/**
|
|
1169
|
+
* A token amount as a wallet takes it when pasted: exact, with a dot, without grouping or trailing zeros.
|
|
1170
|
+
*
|
|
1171
|
+
* @param baseUnits - Base units, as a decimal integer string (not negative).
|
|
1172
|
+
* @param decimals - Decimals of the token.
|
|
1173
|
+
* @returns For example `89.54` for `89540000` with 6 decimals, `5` for `5000000`.
|
|
1174
|
+
*/
|
|
1175
|
+
declare function baseUnitsToDecimal(baseUnits: string, decimals: number): string;
|
|
1176
|
+
/**
|
|
1177
|
+
* An address shortened to its start and end, as wallets show it.
|
|
1178
|
+
*
|
|
1179
|
+
* @param address - The address (`0x…` or base58).
|
|
1180
|
+
* @param head - Characters kept at the start; `0x` counts toward it (default `6` for `0x`, `4` otherwise).
|
|
1181
|
+
* @param tail - Characters kept at the end (default `4`).
|
|
1182
|
+
* @returns For example `0x1111…2222`; a short address unchanged.
|
|
1183
|
+
*/
|
|
1184
|
+
declare function shortAddress(address: string, head?: number, tail?: number): string;
|
|
1185
|
+
/**
|
|
1186
|
+
* Time left as a countdown: `mm:ss` under an hour, `hh:mm:ss` under a day, `Nd hh:mm:ss` beyond.
|
|
1187
|
+
*
|
|
1188
|
+
* @param ms - Milliseconds left; a negative value counts as zero.
|
|
1189
|
+
* @returns The countdown.
|
|
1190
|
+
*/
|
|
1191
|
+
declare function formatCountdown(ms: number): string;
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* @file What the outcome steps show: how to reach the seller, when to ask before leaving, what a refusal means, the
|
|
1195
|
+
* terms of automatic payments, and what an underpaid invoice still needs.
|
|
1196
|
+
*/
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* Where "Contact <seller>" leads: an email to the seller's support address about the invoice, else the seller's site.
|
|
1200
|
+
*
|
|
1201
|
+
* @param merchant - The seller's support email and site.
|
|
1202
|
+
* @param merchant.supportEmail - The support email, if any.
|
|
1203
|
+
* @param merchant.website - The site (http(s) only), if any.
|
|
1204
|
+
* @param subject - The subject of the email, for example `Invoice INV-2026-42`.
|
|
1205
|
+
* @returns The link, or `null` when the seller gave neither.
|
|
1206
|
+
*/
|
|
1207
|
+
declare function contactHref(merchant: Pick<CheckoutMerchant, 'supportEmail' | 'website'>, subject: string): string | null;
|
|
1208
|
+
/**
|
|
1209
|
+
* Whether closing the checkout asks first: only while nothing has been sent. Once a transaction is on its way, or the
|
|
1210
|
+
* invoice is settled, the checkout closes without a question.
|
|
1211
|
+
*
|
|
1212
|
+
* @param phase - Where the payment stands.
|
|
1213
|
+
* @returns `true` to ask.
|
|
1214
|
+
*/
|
|
1215
|
+
declare function needsLeaveConfirm(phase: CheckoutPhase): boolean;
|
|
1216
|
+
/**
|
|
1217
|
+
* The text of a refusal on the method step, with what to do.
|
|
1218
|
+
*
|
|
1219
|
+
* @param error - The store's error.
|
|
1220
|
+
* @param labels - The labels of the checkout language.
|
|
1221
|
+
* @returns The text.
|
|
1222
|
+
*/
|
|
1223
|
+
declare function methodErrorText(error: CheckoutError, labels: NovaPaymentsLabels): string;
|
|
1224
|
+
/** The terms of an automatic payments offer, as the checkout shows them. */
|
|
1225
|
+
interface AutoPayTerms {
|
|
1226
|
+
/** The CAIP-2 chain of the charges. */
|
|
1227
|
+
chainId: string;
|
|
1228
|
+
/** The account that takes the payments (the merchant's collector). */
|
|
1229
|
+
to: string;
|
|
1230
|
+
/** The most it takes in a period, in base units of the token. */
|
|
1231
|
+
limit: string;
|
|
1232
|
+
/** Decimals of the token. */
|
|
1233
|
+
decimals: number;
|
|
1234
|
+
/** Symbol of the token. */
|
|
1235
|
+
symbol: string;
|
|
1236
|
+
/** The length of a period, in seconds. */
|
|
1237
|
+
periodSeconds: number;
|
|
1238
|
+
/** When the permission ends, in milliseconds; `null` without an expiry rule. */
|
|
1239
|
+
expiresAt: number | null;
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* The terms of an ERC-7715 automatic payments offer: the periodic limit in the token of the method, the period, the
|
|
1243
|
+
* expiry and the accounts.
|
|
1244
|
+
*
|
|
1245
|
+
* @param offer - The view's `autoCharge`.
|
|
1246
|
+
* @param methods - The view's methods (for the token of the offer).
|
|
1247
|
+
* @returns The terms, or `null` when the offer is not available or its method is unknown.
|
|
1248
|
+
*/
|
|
1249
|
+
declare function autoPayTerms(offer: AutoChargeOffer | null, methods: CheckoutMethod[]): AutoPayTerms | null;
|
|
1250
|
+
/**
|
|
1251
|
+
* A period as words of the language: whole days in days, otherwise in hours.
|
|
1252
|
+
*
|
|
1253
|
+
* @param seconds - The period.
|
|
1254
|
+
* @param locale - BCP 47 language of the page.
|
|
1255
|
+
* @returns For example `30 days`, `2 hours`, `30 днів`.
|
|
1256
|
+
*/
|
|
1257
|
+
declare function formatPeriod(seconds: number, locale: string): string;
|
|
1258
|
+
/**
|
|
1259
|
+
* What an underpaid invoice still needs, in base units of the locked token.
|
|
1260
|
+
*
|
|
1261
|
+
* @param quote - The locked quote the payment was for.
|
|
1262
|
+
* @param amountPaid - What arrived, in base units of that token.
|
|
1263
|
+
* @returns The rest, or `null` when it is unknown or nothing is left.
|
|
1264
|
+
*/
|
|
1265
|
+
declare function underpaidRest(quote: Pick<CheckoutQuote, 'cryptoAmountExpected'> | null, amountPaid: string | null): string | null;
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* @file A QR code as one SVG path, so the checkout draws it in its own colors.
|
|
1269
|
+
*/
|
|
1270
|
+
/**
|
|
1271
|
+
* A QR code as an SVG path: one 1×1 square per dark module, inside a quiet zone of four modules. Error correction `M`
|
|
1272
|
+
* (15 %) keeps payment links short enough to scan from a screen.
|
|
1273
|
+
*
|
|
1274
|
+
* @param text - What the code holds (a Solana Pay URL, a payment page).
|
|
1275
|
+
* @returns The size of the square view box in modules and the path.
|
|
1276
|
+
*/
|
|
1277
|
+
declare function qrPath(text: string): {
|
|
1278
|
+
size: number;
|
|
1279
|
+
path: string;
|
|
1280
|
+
};
|
|
1281
|
+
|
|
1282
|
+
/**
|
|
1283
|
+
* Subtotal and tax of the invoice from its lines: the lines carry net amounts, the total includes tax. The tax row
|
|
1284
|
+
* shows the rate when all taxed lines share one.
|
|
1285
|
+
*
|
|
1286
|
+
* @param invoice - The invoice of the checkout.
|
|
1287
|
+
* @returns The subtotal, the tax (`null` without tax), its rate (`null` with several) and the total, as decimals.
|
|
1288
|
+
*/
|
|
1289
|
+
declare function invoiceTotals(invoice: CheckoutView['invoice']): {
|
|
1290
|
+
subtotal: string;
|
|
1291
|
+
tax: string | null;
|
|
1292
|
+
rate: string | null;
|
|
1293
|
+
total: string;
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1296
|
+
export { AutoPayScreen, type AutoPayTerms, type BalanceShortfall, type BuyerCollect, type BuyerField, type BuyerIssue, BuyerScreen, CheckoutContext, CheckoutContextProvider, type CheckoutContextValue, CheckoutHeader, type CheckoutHeaderProps, type CheckoutScreen, type CheckoutScreenChoices, type CheckoutStep, CheckoutStepper, type CheckoutStepperProps, CheckoutSummary, type CheckoutTokenGroup, CheckoutWallet, CompactSummary, ConfirmScreen, DEADLINE_ANNOUNCEMENTS, DeadlineTimer, type HandOverParams, LeaveDialog, LocaleSwitcher, type LocaleSwitcherProps, MerchantBadge, MethodScreen, MobileSteps, NovaPaymentsContext, type NovaPaymentsLabelsContext, NovaPaymentsProvider, type NovaPaymentsProviderCustomization, type NovaPaymentsProviderProps, type NovaPaymentsSettings, OrderLines, OrderTotal, type OutcomeKind, OutcomeScreen, PaidScreen, type PayInvoiceParams, type PayPath, PayScreen, type Payment, PaymentCheckout, type PaymentCheckoutDisplay, type PaymentCheckoutProps, PaymentFamily, type PaymentStatus, PaymentWalletError, type PaymentWalletErrorKind, PaymentsAdapter, type PaymentsPulsar, QUOTE_WARNING_MS, QrScreen, type QuoteAmounts, SellerDetailsContent, type SentPayment, SummaryFooter, type UseAutoReturnParams, type UseCheckoutStoreOptions, type UsePaymentHandOverParams, type UsePaymentParams, type WalletConnection, WalletPrompt, type WalletPromptKind, type WalletPromptProps, autoPayTerms, balanceShortfall, baseUnitsToDecimal, buyerFields, buyerIssues, checkoutScreen, checkoutSteps, cleanBuyer, contactHref, countryOptions, deadlineAnnouncement, formatCountdown, formatFiat, formatPeriod, formatTokenAmount, groupMethodsByToken, handOverPayment, instructionsChainId, invoiceTotals, isQuoteEnding, methodErrorText, minorToDecimal, needsLeaveConfirm, payInvoice, payPath, qrPath, quoteAmounts, quoteRate, shortAddress, shouldHandOver, underpaidRest, useAsyncValue, useAutoReturn, useCheckoutContext, useCheckoutState, useCheckoutStore, useConnectedWallet, useNovaPayments, useNow, usePaidCallback, usePayment, usePaymentFacts, usePaymentHandOver, usePaymentsLabels, useWalletConnection, walletErrorKind };
|