tf-checkout-react 2.0.0-beta.23 → 2.0.0-beta.24
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/README.md +831 -279
- package/docs/API.md +540 -0
- package/package.json +3 -2
package/docs/API.md
ADDED
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
# React checkout API reference
|
|
2
|
+
|
|
3
|
+
This reference describes the public surface of `tf-checkout-react` version
|
|
4
|
+
`2.0.0-beta.24`. It supplements the package's npm README with examples and an
|
|
5
|
+
inventory of the shared facade and hooks. The package's installed
|
|
6
|
+
`dist/index.d.ts` is the exact versioned source for complete signatures and
|
|
7
|
+
DTO fields. A named export or a typed payment method does not establish that
|
|
8
|
+
the matching backend feature, account permission or payment provider is enabled.
|
|
9
|
+
|
|
10
|
+
All examples assume `configureCheckout` has run, and React Query examples are
|
|
11
|
+
under a host `QueryClientProvider`. Use a registered public SDK client ID and
|
|
12
|
+
an empty `clientSecret` in a browser. Never ship a confidential client secret.
|
|
13
|
+
|
|
14
|
+
## Configure and persist sessions
|
|
15
|
+
|
|
16
|
+
The following adapter keeps values in memory for the life of this JavaScript
|
|
17
|
+
module. Use it for a test or a deliberately non-persistent browser session;
|
|
18
|
+
refresh loses the session. Production persistence and security are the host's
|
|
19
|
+
choice. For an async backing store, the required synchronous methods operate on
|
|
20
|
+
a loaded mirror and optional `flush()` waits for pending writes; initialize the
|
|
21
|
+
mirror before configuring and await relevant writes before claiming success.
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { configureCheckout, type StorageAdapter } from 'tf-checkout-react'
|
|
25
|
+
|
|
26
|
+
const values = new Map<string, string>()
|
|
27
|
+
const storage: StorageAdapter = {
|
|
28
|
+
getItem(key) { return values.get(key) ?? null },
|
|
29
|
+
setItem(key, value) { values.set(key, value) },
|
|
30
|
+
removeItem(key) { values.delete(key) },
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
configureCheckout({
|
|
34
|
+
env: 'STAG',
|
|
35
|
+
clientId: 'PUBLIC_SDK_CLIENT_ID',
|
|
36
|
+
clientSecret: '',
|
|
37
|
+
cookieAuth: true,
|
|
38
|
+
storage,
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The default web adapter uses `localStorage`. `createMemoryStorage()` supplies a
|
|
43
|
+
ready-made in-memory adapter. `getConfig()` reads the active resolved config,
|
|
44
|
+
and `isConfigured()` reports whether configuration has occurred. Do not expose
|
|
45
|
+
credentials by logging that config. `configureCheckout` is global and should
|
|
46
|
+
run before mounting; a second configuration replaces the first. In an SSR app,
|
|
47
|
+
initialize the SDK in a client entry, and never share a module-level buyer
|
|
48
|
+
session between server requests. `auth` is a per-request header function whose
|
|
49
|
+
result normally merges after SDK headers. Protected requests enforce session
|
|
50
|
+
isolation: guest bootstrap strips sensitive buyer/session headers after the
|
|
51
|
+
merge. Do not attach privileged server credentials in browser code.
|
|
52
|
+
|
|
53
|
+
A checkout buyer identity has event-scoped authority. `hooks.useAuthSession()`
|
|
54
|
+
observes session state, but a UI flag, local token or checkout buyer profile does
|
|
55
|
+
not itself authorize private account data. Coordinate logout, buyer changes,
|
|
56
|
+
query-cache use and cart ownership with the host. `clearSession()` and
|
|
57
|
+
`clearCheckoutGuestSession()` are lower-level session operations; use the
|
|
58
|
+
appropriate authorized logout flow where a backend session must also end.
|
|
59
|
+
|
|
60
|
+
## Compose navigation
|
|
61
|
+
|
|
62
|
+
`Tickets` and `SeatMap` report when a cart is ready; the host owns navigation
|
|
63
|
+
when composing individual sections. This skeleton connects seated selection to
|
|
64
|
+
its view. It is not a standalone app: configure and mount it under
|
|
65
|
+
`QueryClientProvider`.
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
import { useState } from 'react'
|
|
69
|
+
import {
|
|
70
|
+
AddOns, BillingInfo, CheckoutProvider, Payment, SeatMap, Tickets, WaiverSigning,
|
|
71
|
+
} from 'tf-checkout-react'
|
|
72
|
+
|
|
73
|
+
export function CheckoutLayout({ eventId }: { eventId: string }) {
|
|
74
|
+
const [view, setView] = useState<'tickets' | 'seats' | 'checkout'>('tickets')
|
|
75
|
+
const [notice, setNotice] = useState('')
|
|
76
|
+
return (
|
|
77
|
+
<CheckoutProvider>
|
|
78
|
+
{view === 'tickets' && (
|
|
79
|
+
<Tickets
|
|
80
|
+
eventId={eventId}
|
|
81
|
+
onSelectSeats={() => setView('seats')}
|
|
82
|
+
onContinue={() => setView('checkout')}
|
|
83
|
+
/>
|
|
84
|
+
)}
|
|
85
|
+
{view === 'seats' && (
|
|
86
|
+
<SeatMap eventId={eventId} onContinue={() => setView('checkout')} />
|
|
87
|
+
)}
|
|
88
|
+
{view === 'checkout' && (
|
|
89
|
+
<>
|
|
90
|
+
<AddOns eventId={eventId} />
|
|
91
|
+
<BillingInfo eventId={eventId} />
|
|
92
|
+
<WaiverSigning eventId={eventId} />
|
|
93
|
+
<Payment eventId={eventId} onComplete={(order) => {
|
|
94
|
+
setNotice(order.pending ? 'Payment pending' : 'Order submitted')
|
|
95
|
+
}} />
|
|
96
|
+
<p role="status">{notice}</p>
|
|
97
|
+
</>
|
|
98
|
+
)}
|
|
99
|
+
</CheckoutProvider>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Real navigation must also handle expiry, payment in flight, retained orders and
|
|
105
|
+
buyer/session changes. Do not unconditionally discard or replace a cart on
|
|
106
|
+
Back during a payment. Use the embedded flow when its navigation fits; when
|
|
107
|
+
building your own, preserve validation and server reservation behavior. The
|
|
108
|
+
host can use `useCheckoutContext()` inside the provider to read the shared
|
|
109
|
+
checkout and `useCheckoutValidation()` to coordinate section validation.
|
|
110
|
+
|
|
111
|
+
The provider's `value?: UseCheckout` accepts a checkout created by the host's
|
|
112
|
+
`useCheckout`; pass the same instance to all sections of that flow. Omit it to
|
|
113
|
+
let the provider create one and wire the default installment picker. Checkout
|
|
114
|
+
state is app-wide by default; two hook calls do not create isolated carts.
|
|
115
|
+
`useCheckout` takes `{ ports?, options? }` once at first render. A custom
|
|
116
|
+
`ports` object is merged over browser defaults and may provide `providerPage`,
|
|
117
|
+
`openUrl`, `onInstallmentOffers` or other payment capabilities, but its type
|
|
118
|
+
omits `confirmer` and cannot replace the web hook's `webConfirmer`. Use the
|
|
119
|
+
lower-level `createEngine` configuration for a custom confirmer. `options` includes
|
|
120
|
+
`stripePublishableKey`, `merchantIdentifier`, `merchantCountryCode`,
|
|
121
|
+
`merchantName`, `googlePayTestEnv`, `redirectReturnUrl` and `urlScheme`.
|
|
122
|
+
Only set options appropriate to your host and payment provider.
|
|
123
|
+
|
|
124
|
+
## Data and action contracts
|
|
125
|
+
|
|
126
|
+
### Catalog and reservation
|
|
127
|
+
|
|
128
|
+
`hooks.useTicketsWithMeta(eventId)` loads current ticket types along with promo,
|
|
129
|
+
waiting-list and bundle metadata. `useTicketCatalog` manages the catalog and
|
|
130
|
+
selection state used by the standard ticket picker. The following renders a
|
|
131
|
+
read-only status; use the actual catalog row to construct `TicketSelection` and
|
|
132
|
+
reserve with `setTickets` after the buyer chooses a quantity.
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
import { hooks } from 'tf-checkout-react'
|
|
136
|
+
|
|
137
|
+
export function EventAvailability({ eventId }: { eventId: string }) {
|
|
138
|
+
const query = hooks.useTicketsWithMeta(eventId)
|
|
139
|
+
if (query.isPending) return <p role="status">Loading availability…</p>
|
|
140
|
+
if (query.isError) return <button onClick={() => void query.refetch()}>Retry</button>
|
|
141
|
+
const { tickets, waitingList } = query.data
|
|
142
|
+
return <p>{tickets.length} ticket types; waiting list: {waitingList?.state ?? 'unavailable'}</p>
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`TicketSelection = { id, name, optionName, price, quantity, currency }`. `id`
|
|
147
|
+
is the current opaque encrypted ID from the catalog. A stable optional API
|
|
148
|
+
`selectionKey` can preserve the buyer's selected quantity across ID rotation;
|
|
149
|
+
the latest encrypted ID is still used on cart requests. For time-slot events,
|
|
150
|
+
pass the actual available date to `useTimeSlotTickets(eventId, date)` and
|
|
151
|
+
respect the backend's dated context. `useEventAddons(eventId)` loads add-ons;
|
|
152
|
+
`ttf.events.filterAddonsForTickets(list, checkout.ticketTypeIds)` filters for
|
|
153
|
+
the primed ticket types. Call `setAddons({ [addonId]: quantity })` to reprice.
|
|
154
|
+
|
|
155
|
+
`setSeats(eventId, SeatLine[])` uses reserved seat IDs and the corresponding
|
|
156
|
+
tier/ticket relation, option and price. The seat-map reservation has a server
|
|
157
|
+
expiry. `setSeatsIo(eventId, SeatsIoSelection)` is the separate seats.io path.
|
|
158
|
+
Neither method makes stale availability authoritative. Use `resumeCart(eventId,
|
|
159
|
+
{ isFromResale? })` only after the preceding flow has created the server cart
|
|
160
|
+
in the matching session.
|
|
161
|
+
|
|
162
|
+
### Billing and captures
|
|
163
|
+
|
|
164
|
+
The following code illustrates the setter shapes; the inputs must come from
|
|
165
|
+
actual buyer entry and the event's current configuration. It does not attempt
|
|
166
|
+
payment or assert that these fields alone satisfy a particular event.
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
import { useCheckout, type CheckoutBilling, type CheckoutHolder } from 'tf-checkout-react'
|
|
170
|
+
|
|
171
|
+
export function SaveBuyer({ billing, holders }: {
|
|
172
|
+
billing: CheckoutBilling
|
|
173
|
+
holders: CheckoutHolder[]
|
|
174
|
+
}) {
|
|
175
|
+
const checkout = useCheckout()
|
|
176
|
+
function save() {
|
|
177
|
+
checkout.setBilling(billing)
|
|
178
|
+
checkout.setHolders(holders)
|
|
179
|
+
}
|
|
180
|
+
return <button disabled={checkout.orderFixed} onClick={save}>Save details</button>
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
`CheckoutBilling` requires `firstName`, `lastName` and `email`, with optional
|
|
185
|
+
`confirmEmail`, `phone`, `phoneVerificationToken`, `phoneFirstUseKnownEmail`,
|
|
186
|
+
`streetAddress`, `city`, `zip`, `countryId`, `stateId`, `countryCode`,
|
|
187
|
+
`stateCode`, `stateRequired`, `dobDay`, `dobMonth`, `dobYear`, `nationality`,
|
|
188
|
+
`gender`, `instagramHandle` and `dataCapture`. Backend country/state IDs are
|
|
189
|
+
not ISO codes; use `ttf.geo.countries()` and `ttf.geo.states(...)` or their
|
|
190
|
+
hooks. `confirmEmail` is a UI check and is not sent as an independent buyer
|
|
191
|
+
email. A phone verification token must be the server-issued proof for the
|
|
192
|
+
matching event and phone.
|
|
193
|
+
|
|
194
|
+
`CheckoutHolder` requires `firstName`, `lastName`, `email`, and optionally has
|
|
195
|
+
`phone`, numeric backend `ticketTypeId` expressed as a string, and
|
|
196
|
+
`ticketDataCapture`. Holder requirements can be stricter than the type's
|
|
197
|
+
optional fields. `CheckoutConsent` has `ttfOptIn` and `brandOptIn` booleans;
|
|
198
|
+
`EventCondition` acceptance is recorded separately. In stock `BillingInfo`,
|
|
199
|
+
however, supplying `privacyPolicy` replaces the Ticket Fairy marketing control
|
|
200
|
+
with a required privacy checkbox that writes the **same** `consent.ttfOptIn`
|
|
201
|
+
value, submitted as `ttf_opt_in`. This path does not independently capture
|
|
202
|
+
privacy and Ticket Fairy marketing choices. `brandOptIn` is separate. Hosts
|
|
203
|
+
requiring independent choices need an alternative whose UI, payload and backend
|
|
204
|
+
behavior have been verified; do not rely on the stock `privacyPolicy` prop for
|
|
205
|
+
that requirement.
|
|
206
|
+
|
|
207
|
+
For a host condition provide `{ id, name, content, isRequired }` and record
|
|
208
|
+
acceptance with `acceptCondition(id, true)` or `setAcceptedConditions(map)`.
|
|
209
|
+
These are client gates, not a replacement for server validation. `Payment`
|
|
210
|
+
renders `content` (or `name` as a fallback) as HTML; supply trusted or sanitized
|
|
211
|
+
content and verify how server-provided conditions are handled as well.
|
|
212
|
+
|
|
213
|
+
Do not combine required stock `privacyPolicy` with
|
|
214
|
+
`skipBillingWhenProfileComplete` / `skipWhenProfileComplete`: an eligible skip
|
|
215
|
+
can hide the privacy and marketing controls while `Payment` still requires
|
|
216
|
+
the privacy value. Keep billing visible and test both guest and signed-in flows.
|
|
217
|
+
|
|
218
|
+
`checkBuyerEmail(email)` starts a request; it does not debounce it. The stock
|
|
219
|
+
`BillingInfo` delays calls, but headless hosts should debounce and coordinate
|
|
220
|
+
in-flight checks. A late response for an older email in the same cart can
|
|
221
|
+
overwrite the snapshot. Compare `existingAccountEmail` to the current trimmed
|
|
222
|
+
input before showing a match and recheck the current value if needed.
|
|
223
|
+
|
|
224
|
+
`customFields` is an array of `EventCustomFieldGroup` with order, ticket or
|
|
225
|
+
add-on scope; `CustomFieldValues` maps field names to strings or string arrays.
|
|
226
|
+
Order answers belong in `billing.dataCapture`, ticket answers in each holder's
|
|
227
|
+
`ticketDataCapture`, and add-on answers in `setAddonDataCapture` keyed by
|
|
228
|
+
add-on ID. Apply ticket-scoped questions only to matching ticket types. Image
|
|
229
|
+
capture has format and size constraints and needs the SDK's image handling;
|
|
230
|
+
validate on the deployed server too. In this beta the backend owns conditional
|
|
231
|
+
requiredness and hosted-checkout conditional visibility is not fully reproduced.
|
|
232
|
+
Test the actual event's branches before release.
|
|
233
|
+
|
|
234
|
+
If `unavailableDetails` includes `'waiver'`, the read failed without establishing
|
|
235
|
+
whether a waiver exists. `reloadCheckoutDetails()` retries it. For a custom
|
|
236
|
+
waiver UI, `holdWaiverSigning(index)` returns a hold or `null`; complete or
|
|
237
|
+
cancel the upload, attach via `setWaiverSignature(index, signature, hold)` only
|
|
238
|
+
while the binding remains current, and release the hold. The standard
|
|
239
|
+
`WaiverSigning` component performs this coordination. Edits made when
|
|
240
|
+
`orderFixed` is true are not a way to amend an already placed order.
|
|
241
|
+
|
|
242
|
+
### Placement and recovery
|
|
243
|
+
|
|
244
|
+
`placeOrder(method?, options?)` returns `Promise<PlaceOrderResult>`; options
|
|
245
|
+
include `autoRunIdVerification`, `idVerification` and `claimCard`. The default
|
|
246
|
+
method is card. Supply the method appropriate to the event and the active
|
|
247
|
+
payment field. Inspect `pending`, `pendingVoucherUrl` and
|
|
248
|
+
`needIdVerification`; `orderHash` is an order reference, not a universal proof
|
|
249
|
+
of settlement. Provider and server reconciliation controls fulfilment.
|
|
250
|
+
For zero-total orders, this SDK ignores the free-registration response body and
|
|
251
|
+
reports `needIdVerification: false`. Verification or approval may still be
|
|
252
|
+
required; `free: true` is not proof of ticket issuance. The default inline
|
|
253
|
+
`EmbeddedCheckout` can nevertheless show confirmed or ticket-available copy
|
|
254
|
+
while approval or verification is still outstanding. Use
|
|
255
|
+
`confirmationMode="redirect"` with host-owned authoritative order and
|
|
256
|
+
verification status, or a custom composed confirmation gated on that status.
|
|
257
|
+
If status is unavailable, contact support. Do not retry payment for a free order.
|
|
258
|
+
`OrderConfirmation` does not check payment status before rendering its default
|
|
259
|
+
confirmed/ticket-availability copy. Gate it on authoritative appropriate status;
|
|
260
|
+
when the result is pending, show pending UI and any voucher instead. The
|
|
261
|
+
in-flow `Confirmation` component reads the current result's pending state.
|
|
262
|
+
|
|
263
|
+
For a custom Stripe card step, the following demonstrates the boundary between
|
|
264
|
+
host-collected data and SDK placement. Render it only after reserving a cart and
|
|
265
|
+
confirming that Stripe card is offered. `canSubmit` must reflect the actual
|
|
266
|
+
event's required answers, add-ons, consent and waivers; it is not a substitute
|
|
267
|
+
for server validation. This example stops further attempts after an error until
|
|
268
|
+
the host has reconciled the outcome.
|
|
269
|
+
|
|
270
|
+
```tsx
|
|
271
|
+
import { useState } from 'react'
|
|
272
|
+
import {
|
|
273
|
+
CardInput, useCheckout, type CheckoutBilling, type CheckoutConsent,
|
|
274
|
+
type CheckoutHolder,
|
|
275
|
+
} from 'tf-checkout-react'
|
|
276
|
+
|
|
277
|
+
export function StripeCardStep(props: {
|
|
278
|
+
billing: CheckoutBilling
|
|
279
|
+
holders: CheckoutHolder[]
|
|
280
|
+
consent: CheckoutConsent
|
|
281
|
+
acceptedConditions: Record<string, boolean>
|
|
282
|
+
canSubmit: boolean
|
|
283
|
+
}) {
|
|
284
|
+
const checkout = useCheckout()
|
|
285
|
+
const [notice, setNotice] = useState('')
|
|
286
|
+
const [needsReview, setNeedsReview] = useState(false)
|
|
287
|
+
async function pay() {
|
|
288
|
+
checkout.setBilling(props.billing)
|
|
289
|
+
checkout.setHolders(props.holders)
|
|
290
|
+
checkout.setConsent(props.consent)
|
|
291
|
+
checkout.setAcceptedConditions(props.acceptedConditions)
|
|
292
|
+
try {
|
|
293
|
+
const order = await checkout.placeOrder('card')
|
|
294
|
+
setNotice(order.pending ? 'Payment pending' : `Order reference: ${order.orderHash}`)
|
|
295
|
+
} catch {
|
|
296
|
+
setNeedsReview(true)
|
|
297
|
+
setNotice('The payment outcome needs review. Please contact support.')
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return <div>
|
|
301
|
+
<CardInput />
|
|
302
|
+
<button disabled={!props.canSubmit || checkout.isBusy || needsReview || checkout.status !== 'ready'}
|
|
303
|
+
onClick={() => void pay()}>Pay</button>
|
|
304
|
+
<p role="status">{notice}</p>
|
|
305
|
+
</div>
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
The host should display `needIdVerification` and any pending voucher as
|
|
310
|
+
appropriate, check the authoritative result, and provide a recovery path. A
|
|
311
|
+
production UI also needs field labels, accessible errors and a way to recover
|
|
312
|
+
after a confirmed decline; do not automatically repeat the charge in a catch.
|
|
313
|
+
|
|
314
|
+
`Confirmation` defaults its share URL to `window.location.href` and shows
|
|
315
|
+
generic referral copy for non-pending orders without checking organizer
|
|
316
|
+
eligibility. That URL may contain unrelated query parameters or lack a
|
|
317
|
+
buyer-specific referral. `EmbeddedCheckout` does not expose a `shareUrl` prop.
|
|
318
|
+
In a composed flow pass a verified eligible buyer-specific `shareUrl`, or pass
|
|
319
|
+
`shareUrl=""` to suppress sharing. Server-backed `OrderConfirmation` and
|
|
320
|
+
`Rewards` can use response data where the backend supplies it; first gate
|
|
321
|
+
`OrderConfirmation` on an authoritative appropriate payment status.
|
|
322
|
+
|
|
323
|
+
```tsx
|
|
324
|
+
import { useState } from 'react'
|
|
325
|
+
import { useCheckout } from 'tf-checkout-react'
|
|
326
|
+
|
|
327
|
+
export function StartOver() {
|
|
328
|
+
const checkout = useCheckout()
|
|
329
|
+
const [notice, setNotice] = useState('')
|
|
330
|
+
async function startOver() {
|
|
331
|
+
if (checkout.status === 'placing') setNotice('Finishing your payment…')
|
|
332
|
+
const reset = await checkout.resetWhenSettled()
|
|
333
|
+
setNotice(reset ? 'Choose tickets to start again.' : 'Unable to start over. Check your order or contact support.')
|
|
334
|
+
}
|
|
335
|
+
return <div>
|
|
336
|
+
<button onClick={() => void startOver()}>Start over</button>
|
|
337
|
+
<p role="status">{notice}</p>
|
|
338
|
+
</div>
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
A retained order can represent an unknown payment outcome. Never infer a safe
|
|
343
|
+
new charge from an error, closed window or network timeout. `resetWhenSettled`
|
|
344
|
+
can also return `false` for a retired checkout, so check current session/context
|
|
345
|
+
before choosing recovery. The exported `PAID_ORDER_PENDING_MESSAGE` tells the
|
|
346
|
+
buyer to press Pay again; a `false` result alone is not enough to use that
|
|
347
|
+
instruction or establish a safe retry. For custom provider ports, return a settled dismissal
|
|
348
|
+
on closure/unmount; custom confirmer errors should classify only proven
|
|
349
|
+
no-charge outcomes as `declined`, `cancelled` or `notStarted`, with `unknown`
|
|
350
|
+
for uncertainty. `UNSUPPORTED_GATEWAY` indicates the necessary platform
|
|
351
|
+
capability is not available, not that every provider failure is safe to retry.
|
|
352
|
+
|
|
353
|
+
## Auth component contracts
|
|
354
|
+
|
|
355
|
+
`AuthModal` owns a complete modal flow. Supply `open`, `onClose` and, for
|
|
356
|
+
public checkout sign-in, `checkoutEventId`. Optional fields are `initialView`,
|
|
357
|
+
`initialEmail`, `message`, `allowRegistration`, `allowPasswordReset`,
|
|
358
|
+
`requireRegistrationAddress`, `registrationFields`, `logoUrl`, `className`,
|
|
359
|
+
`onCheckoutAuthenticated` and `onAuthenticated`. The callbacks correspond to
|
|
360
|
+
checkout-buyer and full-account profiles respectively; they are not
|
|
361
|
+
interchangeable authority. The registered backend journey decides which path is
|
|
362
|
+
available. The web checkout popup uses browser cryptography, a state value and
|
|
363
|
+
PKCE, checks the message origin and window, and can be blocked, closed or time
|
|
364
|
+
out. Never treat popup closure as successful authentication.
|
|
365
|
+
|
|
366
|
+
The exported controlled forms can be combined with `hooks.useAuthFlow`; they
|
|
367
|
+
are not an authentication backend on their own:
|
|
368
|
+
|
|
369
|
+
| Form | Required props | Optional props |
|
|
370
|
+
| --- | --- | --- |
|
|
371
|
+
| `LoginForm` | `onSubmit(input)` | `initialEmail`, `errors`, `error`, `loading`, `allowPasswordReset`, `onForgotPassword(email)`, `onFieldChange(field)`. |
|
|
372
|
+
| `RegisterForm` | `onSubmit(input, options)` | `initialEmail`, `errors`, `error`, `loading`, `requireAddress`, `requireTerms`, `completionRefresh`, `onFieldChange(field)`. `completionRefresh` supplies `retryAfter`, `onRequest()` and `onVerify(code)`. |
|
|
373
|
+
| `ForgotPasswordForm` | `onSubmit(email)`, `onBackToLogin(email)` | `initialEmail`, `errors`, `error`, `successMessage`, `loading`, `onFieldChange`. |
|
|
374
|
+
| `ResetPasswordForm` | `token` | `onSuccess`, `onBackToLogin`. |
|
|
375
|
+
| `TwoFactorForm` | `loading`, `error`, `successMessage`, `smsAvailable`, `smsRetryAfter`, `onSubmit(code)`, `onSendSms()`, `onCancel()` | None. |
|
|
376
|
+
| `EmailCodeForm` | `initialEmail`, `sent`, `target`, `retryAfter`, `loading`, `error`, `successMessage`, `onRequest(email)`, `onVerify(code)`, `onBack()` | None. |
|
|
377
|
+
| `PhoneAuthView` | `flow: PhoneAuthenticationFlow` | `allowCreation`, `allowPasswordReset`, `termsUrl`, `privacyUrl`. |
|
|
378
|
+
|
|
379
|
+
Use the exported `AuthLoginInput`, `AuthRegistrationInput`, `AuthFieldErrors`,
|
|
380
|
+
`AuthFieldName`, `AuthFlowView` and form `*Props` types for exact values.
|
|
381
|
+
Phone checkout requires `sdkCheckoutPhoneAuth` and a matching deployed journey;
|
|
382
|
+
do not enable it just because the view exists. Complete any two-factor or
|
|
383
|
+
email/phone challenge before treating a buyer as authenticated. The built-in
|
|
384
|
+
modal's default `allowRegistration`, `allowPasswordReset` and
|
|
385
|
+
`requireRegistrationAddress` are all `true`. Public checkout registration and
|
|
386
|
+
account completion force address collection even when the option is `false`.
|
|
387
|
+
|
|
388
|
+
## Payment input contracts
|
|
389
|
+
|
|
390
|
+
`CardInput` accepts `className?`, Stripe card-element `style?`, `owner?`
|
|
391
|
+
(default `'checkout'`) and `visible?` (default `true`). `StripePaymentElement`
|
|
392
|
+
accepts `className?`, `elementsConfig?`, `wallets?` (`applePay?`, `googlePay?`),
|
|
393
|
+
Stripe `options?` and `owner?`. `XenditCardInput` accepts `className?`,
|
|
394
|
+
`inputClassName?`, and `onValidationChange?(message: string | null)`; the
|
|
395
|
+
consumer renders that message. Standard `Payment` mounts the applicable field.
|
|
396
|
+
|
|
397
|
+
A separate bundle and ticket checkout can compete for the same payment SDK.
|
|
398
|
+
The web hook's default claim uses the `checkout` owner's registered Payment
|
|
399
|
+
Element if present, otherwise its `CardInput`, and refuses if neither is
|
|
400
|
+
available. For a custom owner, `claimCardField(owner)` claims only `CardInput`.
|
|
401
|
+
For a `StripePaymentElement`, use `cardClaimStep('webPaymentElement', () =>
|
|
402
|
+
webConfirmer.claimPaymentElement(owner))` as the `placeOrder` `claimCard` step;
|
|
403
|
+
for `CardInput`, use a `webCard` claim step that calls
|
|
404
|
+
`webConfirmer.releasePaymentElement()` before `claimCardField(owner)`. The
|
|
405
|
+
standard `Payment` component handles the claims and key changes. Don't assume
|
|
406
|
+
the most recently mounted field is the one belonging to an order. For a custom
|
|
407
|
+
owner, these helpers produce the appropriate step to pass as
|
|
408
|
+
`placeOrder('card', { claimCard })`:
|
|
409
|
+
|
|
410
|
+
```ts
|
|
411
|
+
import { cardClaimStep, claimCardField, webConfirmer, type CardClaimStep } from 'tf-checkout-react'
|
|
412
|
+
|
|
413
|
+
export function claimCustomCard(owner: string): CardClaimStep {
|
|
414
|
+
return cardClaimStep('webCard', () => {
|
|
415
|
+
webConfirmer.releasePaymentElement()
|
|
416
|
+
return claimCardField(owner)
|
|
417
|
+
})
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export function claimCustomPaymentElement(owner: string): CardClaimStep {
|
|
421
|
+
return cardClaimStep('webPaymentElement', () => webConfirmer.claimPaymentElement(owner))
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
`webConfirmer`, `webPorts` and
|
|
426
|
+
`webXenditTokenizer` are shared platform instances; factories are available for
|
|
427
|
+
advanced platform work. The generic `createEngine({ ports, options?, store? })`
|
|
428
|
+
requires a payment confirmer and applicable optional ports. A custom integration
|
|
429
|
+
must preserve the same ownership, redirect, pending and error guarantees.
|
|
430
|
+
|
|
431
|
+
## Hooks inventory
|
|
432
|
+
|
|
433
|
+
Import these from the `hooks` namespace. Function signatures and returned flow
|
|
434
|
+
state are in the declarations; React Query hooks require a query client. Many
|
|
435
|
+
accept optional query/mutation options. Names being exported do not imply that
|
|
436
|
+
every feature is deployed for your integration.
|
|
437
|
+
|
|
438
|
+
| Domain | Hook names |
|
|
439
|
+
| --- | --- |
|
|
440
|
+
| Event/catalog | `useEvent`, `useTickets`, `useTicketsWithMeta`, `useTimeSlotTickets`, `useEventAddons`, `useEventBundles`, `useTicketCatalog`, `useFeaturedEvents`. |
|
|
441
|
+
| Geo | `useCountries`, `useStates`. |
|
|
442
|
+
| Checkout | `useCheckout` (shared lower-level binding), `useAppCheckoutSession`, `useCheckoutBuyerProfile`, `useCheckoutPhoneIdentity`, `useCheckoutImageField`, `useCheckoutPaymentMethods`, `useAddOnSelection`, `useSeatSelection`, `useSeatsIoSelection`, `useAccommodationSelection`, `useWaiverSigning`. Use the top-level web `useCheckout` for pre-wired web ports. |
|
|
443
|
+
| Codes and engagement | `useWaitingListForm`, `useJoinWaitingList`, `useAttributeReferrer`, `useValidatePhone`, `useSendRsvp`. |
|
|
444
|
+
| Auth/session | `useAuthSession`, `useSessionAction`, `useAuthFlow`, `useLogin`, `useRegister`, `useRegisterAccount`, `useRestorePassword`, `useRestorePasswordRn`, `useResetPassword`, `useLogout`, `useCheckEmailExists`, `useVerifyTwoFactor`, `useSendTwoFactorSms`, `useRequestAccountEmailCode`, `useVerifyAccountEmailCode`, `useCompleteAccount`, `usePhoneAuthentication`. |
|
|
445
|
+
| Buyer/profile | `useProfile`, `useUpdateAccount`, `useUpdateProfile`, `useSavePhone`, `useSendPhoneCode`, `useVerifyPhoneCode`, `useProfileGender`, `useLinkedAccounts`, `useAccountEmailEnrichment`. |
|
|
446
|
+
| Orders/tickets | `useOrders`, `useOrder`, `useTicketChangeOptions`, `useTicketChange`, `useTicketRefund`, `useTicketGift`, `useTicketResale`, `useCustomerPasses`, `useAccountInformation`, `useAccountPlanManagement`. |
|
|
447
|
+
| Bundles/gateway | `useBundlePurchase`, `useBundleFlow`, `useConfirmerHolder`, `useTicketGatewayWait`, `useBundleStarting`, `useTicketCardForm`, `useTicketCardOwner`. |
|
|
448
|
+
| Rewards | `useOrderRewards`, `useAccountRewards`, `useSubmitPrizeDetails`, `useCreatePack`, `useJoinPack`, `useLeavePack`, `useRegenerateShareCard`, `useAccountRewardsSummary`, `useReceiptRewards`. |
|
|
449
|
+
| Account/community | `useAccountPreferences`, `useInterestSelection`, `useNotificationPreferences`, `useAccountDeletion`, `useFriends`, `useProfileSettings`, `useFriendProfile`, `useSavedEvents`, `useSavedEvent`, `useEventComments`, `useEventCommentImage`, `useEventDiscussion`, `useWordPostReaction`. |
|
|
450
|
+
| Travel | `useTrips`, `useTrip`, `useDiscoveryTravel`. |
|
|
451
|
+
| Coordination | `useLiveScope`, `useLockBusy`, `useHeldScopes`, `useScopedState`, `useOnOrderReleased`, `useOnEventChange`. These are lower-level lifecycle/ownership helpers. |
|
|
452
|
+
|
|
453
|
+
For account order history, `useOrders(query?, options?)` takes pagination and
|
|
454
|
+
filters; `useOrder(orderId, options?)` takes a numeric order ID string. A public
|
|
455
|
+
order hash is used for `OrderConfirmation`, `OrderIDVerification`, and rewards,
|
|
456
|
+
not as a numeric account order ID. Check the declarations for each shape and
|
|
457
|
+
make the appropriate authorized request.
|
|
458
|
+
|
|
459
|
+
## `ttf` facade inventory
|
|
460
|
+
|
|
461
|
+
These functions are grouped under the configured `ttf` export. They are
|
|
462
|
+
low-level calls; the engine and components perform additional sequencing,
|
|
463
|
+
preflight, state and payment coordination. Raw functions are also exported in
|
|
464
|
+
the `api` namespace. Calling a low-level endpoint directly does not grant a
|
|
465
|
+
buyer permission or guarantee a safe payment retry.
|
|
466
|
+
|
|
467
|
+
| Namespace | Methods |
|
|
468
|
+
| --- | --- |
|
|
469
|
+
| `ttf.events` | `featured`, `details`, `tickets`, `ticketsWithMeta`, `bundles`, `startBundlePurchase`, `info`, `conditions`, `timeSlotTickets`, `customFields`, `requiredCustomFieldLabels`, `addons`, `filterAddonsForTickets`, `submitPromoCode`, `setCurrency`, `authenticate`, `track`, `updateOrderDataCapture`, `updateTicketDataCapture`. |
|
|
470
|
+
| `ttf.cart` | `add`, `addSeats`, `get`, `checkoutConfigs`, `price`, `priceBreakdown`, `paymentConfig`, `preOrderMethods`, `checkBuyerEmail`. |
|
|
471
|
+
| `ttf.order` | `create`, `review`, `mapProfileToBilling`, `completeFreeRegistration`, `confirmSuccess`, `idVerificationStatus`, `verifyCustomer`. |
|
|
472
|
+
| `ttf.payment` | `startAdyen`, `adyenPage`, `changeMethodType`, `confirmRedirect`, `prepareOxxo`, `xenditEWalletCharge`, `xenditCardCharge`, `installmentOffers`, `confirmInstallments`, `createPaymentPlan`, `chargeSavedCardPlan`, `changeMethod`, `paypalForm`. |
|
|
473
|
+
| `ttf.seatmap` | `startSession`, `data`, `statuses`, `reserve`, `removeReserved`, `refreshReservation`. |
|
|
474
|
+
| `ttf.engagement` | `attributeReferrer`, `joinWaitingList`, `sendRsvp`, `validatePhone`. |
|
|
475
|
+
| `ttf.geo` | `countries`, `states`. |
|
|
476
|
+
| `ttf.confirmation` | `get`. |
|
|
477
|
+
| `ttf.orders` | `list`, `get`, `myTickets`, `updateOrderCustomFields`, `updateTicketHolderCustomFields`, `updateAddOnCustomFields`. |
|
|
478
|
+
| `ttf.ticketChanges` | `options`, `change`, `joinWaitlist`, `leaveWaitlist`, `history`. |
|
|
479
|
+
| `ttf.resale` | `sell`, `remove`, `process`, `decline`. |
|
|
480
|
+
| `ttf.refunds` | `options`, `submit`. |
|
|
481
|
+
| `ttf.gifts` | `options`, `send`, `cancel`. |
|
|
482
|
+
| `ttf.passes` | `list`, `get`, `events`, `bookings`, `redeem`, `cancel`. |
|
|
483
|
+
| `ttf.rewards` | `forOrder`, `forAccount`, `submitPrizeDetails`, `createPack`, `joinPack`, `leavePack`, `regenerateShareCard`. |
|
|
484
|
+
| `ttf.waivers` | `forCheckout`, `uploadSignatureImage`. |
|
|
485
|
+
| `ttf.extras` | `accommodation`, `quoteAccommodation`, `reserve`. |
|
|
486
|
+
| `ttf.trips` | `list`, `get`. |
|
|
487
|
+
| `ttf.profile` | `get`, `updateAccount`, `update`, `savePhone`, `sendPhoneCode`, `verifyPhoneCode`. |
|
|
488
|
+
| `ttf.preferences` | `getNotifications`, `saveNotifications`, `get`, `save`, `connectAppleMusic`, `disconnectAppleMusic`, `connectSpotify`, `disconnectSpotify`. |
|
|
489
|
+
| `ttf.friends` | `list`, `preview`, `command`, `saveSettings`, `saveProfileSettings`, `matchContacts`, `profile`. |
|
|
490
|
+
| `ttf.savedEvents` | `list`, `status`, `save`. |
|
|
491
|
+
| `ttf.comments` | `list`, `image`, `create`, `update`, `remove`, `react`, `report`, `block`, `moderate`. |
|
|
492
|
+
| `ttf.word` | `getReaction`, `setReaction`. |
|
|
493
|
+
| `ttf.preRegistration` | `confirm`, `influencers`, `confirmationPage`, `submitShareAction`. |
|
|
494
|
+
| `ttf.delegation` | `checkCustomerExists`, `pageInfo`, `issueTicket`. |
|
|
495
|
+
| `ttf.auth` | Checkout: `loginForCheckout`, `loginCheckoutWithVerifiedPhone`, `registerForCheckout`, `getCheckoutBuyerProfile`, `requestCheckoutEmailCode`, `verifyCheckoutEmailCode`, `verifyCheckoutTwoFactor`, `sendCheckoutTwoFactorSms`, `cancelCheckoutTwoFactor`, `logoutFromCheckout`, `signInWithCheckoutBrowser`. Account/session: `login`, `register`, `registerAccount`, `logout`, `verifyTwoFactor`, `cancelTwoFactor`, `sendTwoFactorSms`, `signInWithBrowser`, `beginBrowserSignIn`, `exchangeBrowserSignIn`, `checkEmailExists`. Recovery/proof: `restorePassword`, `restorePasswordRn`, `validateResetToken`, `resetPassword`, `requestAccountEmailCode`, `verifyAccountEmailCode`, `completeAccount`, `requestCheckoutPhoneCode`, `verifyCheckoutPhoneCode`, `loginWithVerifiedPhone`, `mintVerificationUrl`, `getVerificationInfo`, `updateVerificationStatus`. Account management: `getLinkedAccounts`, `linkAccount`, `disconnectAccount`, `getAccountDeletionStatus`, `sendAccountDeletionCode`, `deleteAccount`. |
|
|
496
|
+
|
|
497
|
+
`ttf.events.track(eventId, { pageUrl?, page?, orderHash? })` is explicit event
|
|
498
|
+
tracking. The host owns its trigger, consent and deduplication. Account and
|
|
499
|
+
post-purchase methods can require a different authority from public checkout.
|
|
500
|
+
Never log raw credentials, buyer answers or payment-provider payloads.
|
|
501
|
+
|
|
502
|
+
## UI type reference
|
|
503
|
+
|
|
504
|
+
In addition to the checkout/section prop tables in the npm README, these
|
|
505
|
+
primitives expose the following contracts:
|
|
506
|
+
|
|
507
|
+
- `Card` accepts HTML `div` attributes. `SectionHeader` requires `title` and
|
|
508
|
+
accepts `step`, `pills`, `className`. `Pill` takes `children` and `muted`.
|
|
509
|
+
- `Button` accepts normal button attributes and `variant`, `block`, `loading`.
|
|
510
|
+
`Field` takes `children`, `label`, `error`, `invalid`, `className`;
|
|
511
|
+
`FieldRow` takes `children` and `className`.
|
|
512
|
+
- `Input`, `Textarea`, `Select` accept the matching HTML attributes and
|
|
513
|
+
`invalid`; `Checkbox` accepts input attributes and `label`.
|
|
514
|
+
- `CustomFieldInput` requires `field`, `value`, `onChange` and accepts `error`.
|
|
515
|
+
`CustomFieldGroupFields` requires `group`, `values`, `onChange(name, value)`
|
|
516
|
+
and accepts `ticketTypeId`. The UI's `customFieldsComplete` helper does not
|
|
517
|
+
replace server conditional-field validation.
|
|
518
|
+
- `PaymentMethods` is controlled: `options`, `selected`, `onSelect`,
|
|
519
|
+
`extraValues`, `onExtraChange` are required. `showValidation`, `children`,
|
|
520
|
+
`inputSlotFor`, `className` are optional. `PaymentMethodOption` identifies
|
|
521
|
+
the label/value, method ID and optional extra input.
|
|
522
|
+
- `Stepper` and `QuantitySelect` require `value` and `onChange`; both accept
|
|
523
|
+
`min`, `max`, `step`, `disabled`, `className`. `QuantitySelect` also accepts
|
|
524
|
+
an accessible `label`.
|
|
525
|
+
- `PriceLine` requires `amount`, with `currency`, `original`, `note`,
|
|
526
|
+
`className`. `Timer` requires `seconds`, with `urgentAt`, `label`,
|
|
527
|
+
`className`; `TimerBanner` accepts optional `seconds`, `urgentAt`, `message`,
|
|
528
|
+
`className`. `Loader` accepts `className`.
|
|
529
|
+
- `SignaturePad` requires `onChange(pngDataUrl, inkLength)`, `label` and
|
|
530
|
+
`clearLabel`; `disabled` is optional. `FrozenFields` takes `children` and an
|
|
531
|
+
optional `frozen`, using a disabled fieldset. `I18nProvider` takes optional
|
|
532
|
+
`locale`, `messages` and `children`; `useT()` reads its translator.
|
|
533
|
+
|
|
534
|
+
`CheckoutTheme` supports `colorScheme`, `accent`, `accentHover`,
|
|
535
|
+
`accentContrast`, `surface`, `surfaceMuted`, `text`, `muted`, `border`,
|
|
536
|
+
`error`, `success`, `radiusCard`, `radiusControl`, `shadow`, `font`, `fontSize`
|
|
537
|
+
and `maxWidth`. `themeToVars` returns corresponding CSS custom properties.
|
|
538
|
+
`LocaleCode` accepts `en-GB`, `en-US`, `es-MX`, `fr`, `de`, `ru`, `id`;
|
|
539
|
+
translations may fall back to English. Always verify event-specific copy,
|
|
540
|
+
contrast, focus handling and third-party payment widgets in the host.
|
package/package.json
CHANGED