@tickean/checkout-js 0.1.0 → 0.2.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/README.md CHANGED
@@ -2,4 +2,13 @@
2
2
 
3
3
  Framework-agnostic TypeScript client for Tickean Headless Checkout.
4
4
 
5
- See repository root README and `docs/readme/` for guides.
5
+ ## APIs
6
+
7
+ - `createTickean(options)` — low-level client (unchanged public method signatures)
8
+ - `createCheckoutController(options)` — state machine with cart, quote debounce, OTP, purchase+payment, persistence, telemetry
9
+
10
+ ## Phases
11
+
12
+ `initializing` → `browsing` → `quoting` → `verifying_buyer` → `ready_to_purchase` → `purchasing` → `requires_action` | `processing` → `completed` | `failed` | `expired`
13
+
14
+ See repository root README for monorepo build/test commands.
package/dist/index.d.mts CHANGED
@@ -7,7 +7,8 @@ declare class TickeanError extends Error {
7
7
  readonly code: string;
8
8
  readonly details?: Record<string, unknown>;
9
9
  readonly status?: number;
10
- constructor(payload: TickeanErrorPayload, status?: number);
10
+ readonly requestId?: string;
11
+ constructor(payload: TickeanErrorPayload, status?: number, requestId?: string);
11
12
  }
12
13
  type CreateTickeanOptions = {
13
14
  publishableKey: string;
@@ -16,12 +17,55 @@ type CreateTickeanOptions = {
16
17
  demo?: boolean;
17
18
  fetchImpl?: typeof fetch;
18
19
  };
20
+ type CheckoutPhase = "initializing" | "browsing" | "quoting" | "verifying_buyer" | "ready_to_purchase" | "purchasing" | "requires_action" | "processing" | "completed" | "failed" | "expired";
21
+ type NextAction = {
22
+ type: "display_instructions";
23
+ paymentInstructions: unknown;
24
+ } | {
25
+ type: "redirect";
26
+ url: string;
27
+ } | {
28
+ type: "stripe_elements";
29
+ clientSecret: string;
30
+ publishableKey?: string;
31
+ paymentIntentId?: string;
32
+ } | {
33
+ type: "airwallex_dropin";
34
+ intentId: string;
35
+ clientSecret: string;
36
+ currency?: string;
37
+ env?: string;
38
+ countryCode?: string;
39
+ } | {
40
+ type: "dlocal_fields";
41
+ merchantCheckoutToken: string;
42
+ smartFieldsApiKey?: string;
43
+ paymentId?: string;
44
+ sdkUrl?: string;
45
+ } | {
46
+ type: "fintoc_widget";
47
+ sessionToken?: string;
48
+ widgetToken?: string;
49
+ publicKey?: string;
50
+ holderType?: string;
51
+ product?: string;
52
+ } | {
53
+ type: "none";
54
+ };
19
55
  type CheckoutSession = {
20
56
  sessionId: string;
21
57
  sessionToken: string;
22
58
  expiresAt: string;
23
59
  event: PublicEvent;
24
60
  capabilities: Record<string, boolean>;
61
+ phase?: CheckoutPhase | string;
62
+ status?: string;
63
+ otpVerified?: boolean;
64
+ buyerId?: string | null;
65
+ purchaseId?: string | null;
66
+ shoppingCartReference?: string | null;
67
+ nextAction?: NextAction;
68
+ returnUrl?: string | null;
25
69
  };
26
70
  type PublicShowOption = {
27
71
  id: string;
@@ -105,26 +149,58 @@ type PaymentResult = {
105
149
  fintocWidget?: unknown;
106
150
  dlocalGo?: unknown;
107
151
  airwallex?: unknown;
152
+ mercadoPago?: unknown;
153
+ nextAction?: NextAction;
154
+ requiresAction?: boolean;
108
155
  };
109
156
  type PaymentStatusResult = {
110
157
  status: string;
111
158
  purchase?: PurchaseResult["purchase"] | null;
159
+ payment?: PaymentResult | null;
160
+ nextAction?: NextAction;
161
+ requiresAction?: boolean;
162
+ phase?: CheckoutPhase | string;
163
+ };
164
+ type TelemetryEvent = {
165
+ name: string;
166
+ timestamp: number;
167
+ properties?: Record<string, unknown>;
112
168
  };
169
+ interface TelemetryAdapter {
170
+ track(event: TelemetryEvent): void;
171
+ }
172
+ type PersistedCheckoutState = {
173
+ sessionToken?: string;
174
+ eventSlug?: string;
175
+ cart?: CartItem[];
176
+ discountCode?: string | null;
177
+ phase?: CheckoutPhase;
178
+ /** Non-PII buyer flags only */
179
+ buyerVerified?: boolean;
180
+ purchaseId?: string | null;
181
+ };
182
+ interface PersistenceAdapter {
183
+ get(key: string): PersistedCheckoutState | null;
184
+ set(key: string, value: PersistedCheckoutState): void;
185
+ remove(key: string): void;
186
+ }
113
187
  interface CheckoutTransport {
114
188
  request<T>(path: string, init: {
115
189
  method?: string;
116
190
  body?: unknown;
117
191
  sessionToken?: string | null;
192
+ idempotencyKey?: string;
118
193
  }): Promise<T>;
119
194
  }
120
195
 
121
196
  type TickeanClient = ReturnType<typeof createTickean>;
122
197
  declare function createTickean(options: CreateTickeanOptions): {
123
- readonly session: CheckoutSession | null;
198
+ session: CheckoutSession | null;
124
199
  createSession(params: {
125
200
  eventSlug: string;
126
201
  returnUrl?: string;
127
202
  }): Promise<CheckoutSession>;
203
+ getSession(): Promise<CheckoutSession>;
128
204
  getCatalog(): Promise<PublicEvent>;
129
205
  quote(params: {
130
206
  items: CartItem[];
@@ -156,6 +232,13 @@ declare function createTickean(options: CreateTickeanOptions): {
156
232
  paymentMethod: string;
157
233
  currency: string;
158
234
  amount: number;
235
+ idempotencyKey?: string;
236
+ }): Promise<PaymentResult>;
237
+ confirmPayment(params?: {
238
+ paymentId?: string;
239
+ confirmationToken?: string;
240
+ providerPayload?: string;
241
+ idempotencyKey?: string;
159
242
  }): Promise<PaymentResult>;
160
243
  getPaymentStatus(): Promise<PaymentStatusResult>;
161
244
  watchPayment(options?: {
@@ -165,4 +248,199 @@ declare function createTickean(options: CreateTickeanOptions): {
165
248
  }): Promise<PaymentStatusResult>;
166
249
  };
167
250
 
168
- export { type Buyer, type CartItem, type CheckoutSession, type CheckoutTransport, type CreateTickeanOptions, type PaymentResult, type PaymentStatusResult, type PublicEvent, type PublicShow, type PublicShowOption, type PurchaseResult, type QuoteResult, type TickeanClient, TickeanError, type TickeanErrorPayload, createTickean };
251
+ type CheckoutState = {
252
+ phase: CheckoutPhase;
253
+ session: CheckoutSession | null;
254
+ event: PublicEvent | null;
255
+ cart: CartItem[];
256
+ discountCode: string | null;
257
+ quote: QuoteResult | null;
258
+ isQuoting: boolean;
259
+ buyer: Buyer | null;
260
+ buyerVerified: boolean;
261
+ otpSent: boolean;
262
+ purchase: PurchaseResult["purchase"] | null;
263
+ payment: PaymentResult | null;
264
+ nextAction: NextAction;
265
+ error: TickeanError | null;
266
+ loading: boolean;
267
+ };
268
+ type CheckoutAction = {
269
+ type: "INIT_START";
270
+ } | {
271
+ type: "INIT_SUCCESS";
272
+ session: CheckoutSession;
273
+ event: PublicEvent;
274
+ } | {
275
+ type: "INIT_FAILURE";
276
+ error: TickeanError;
277
+ } | {
278
+ type: "SET_CART";
279
+ cart: CartItem[];
280
+ } | {
281
+ type: "SET_DISCOUNT";
282
+ discountCode: string | null;
283
+ } | {
284
+ type: "QUOTE_START";
285
+ } | {
286
+ type: "QUOTE_SUCCESS";
287
+ quote: QuoteResult;
288
+ } | {
289
+ type: "QUOTE_FAILURE";
290
+ error: TickeanError;
291
+ } | {
292
+ type: "OTP_SENT";
293
+ } | {
294
+ type: "OTP_VERIFIED";
295
+ buyer: Buyer;
296
+ } | {
297
+ type: "SET_EVENT";
298
+ event: PublicEvent;
299
+ } | {
300
+ type: "PURCHASE_START";
301
+ } | {
302
+ type: "PURCHASE_SUCCESS";
303
+ purchase: PurchaseResult["purchase"];
304
+ payment: PaymentResult;
305
+ nextAction: NextAction;
306
+ } | {
307
+ type: "PURCHASE_FAILURE";
308
+ error: TickeanError;
309
+ } | {
310
+ type: "SET_NEXT_ACTION";
311
+ nextAction: NextAction;
312
+ payment?: PaymentResult | null;
313
+ } | {
314
+ type: "PROCESSING";
315
+ } | {
316
+ type: "COMPLETED";
317
+ purchase?: PurchaseResult["purchase"] | null;
318
+ } | {
319
+ type: "FAILED";
320
+ error: TickeanError;
321
+ } | {
322
+ type: "EXPIRED";
323
+ } | {
324
+ type: "CLEAR_ERROR";
325
+ } | {
326
+ type: "REHYDRATE";
327
+ partial: Partial<CheckoutState>;
328
+ };
329
+ declare function createInitialState(partial?: Partial<CheckoutState>): CheckoutState;
330
+ declare function checkoutReducer(state: CheckoutState, action: CheckoutAction): CheckoutState;
331
+
332
+ type CreateCheckoutControllerOptions = CreateTickeanOptions & {
333
+ eventSlug: string;
334
+ returnUrl?: string;
335
+ quoteDebounceMs?: number;
336
+ persistence?: PersistenceAdapter | false;
337
+ persistenceKey?: string;
338
+ telemetry?: TelemetryAdapter;
339
+ };
340
+ declare function createCheckoutController(options: CreateCheckoutControllerOptions): {
341
+ client: {
342
+ session: CheckoutSession | null;
343
+ createSession(params: {
344
+ eventSlug: string;
345
+ returnUrl?: string;
346
+ }): Promise<CheckoutSession>;
347
+ getSession(): Promise<CheckoutSession>;
348
+ getCatalog(): Promise<PublicEvent>;
349
+ quote(params: {
350
+ items: CartItem[];
351
+ discountCode?: string;
352
+ showId?: string;
353
+ }): Promise<QuoteResult>;
354
+ sendOtp(params: {
355
+ phone: string;
356
+ channel?: string;
357
+ }): Promise<unknown>;
358
+ verifyOtp(params: {
359
+ phone: string;
360
+ code: string;
361
+ name?: string;
362
+ email?: string;
363
+ }): Promise<unknown>;
364
+ createPurchase(params: {
365
+ items: CartItem[];
366
+ paymentMethod: string;
367
+ currency: string;
368
+ showId?: string;
369
+ discountCode?: string;
370
+ expectedTotal?: number;
371
+ shoppingCartReference?: string;
372
+ idempotencyKey?: string;
373
+ }): Promise<PurchaseResult>;
374
+ createPayment(params: {
375
+ orderId: string;
376
+ paymentMethod: string;
377
+ currency: string;
378
+ amount: number;
379
+ idempotencyKey?: string;
380
+ }): Promise<PaymentResult>;
381
+ confirmPayment(params?: {
382
+ paymentId?: string;
383
+ confirmationToken?: string;
384
+ providerPayload?: string;
385
+ idempotencyKey?: string;
386
+ }): Promise<PaymentResult>;
387
+ getPaymentStatus(): Promise<PaymentStatusResult>;
388
+ watchPayment(options?: {
389
+ intervalMs?: number;
390
+ timeoutMs?: number;
391
+ signal?: AbortSignal;
392
+ }): Promise<PaymentStatusResult>;
393
+ };
394
+ ready: Promise<void>;
395
+ getSnapshot: () => CheckoutState;
396
+ subscribe: (listener: (snapshot: CheckoutState) => void) => () => void;
397
+ setCartItem: (showOptionId: string, amount: number) => void;
398
+ setCart: (cart: CartItem[]) => void;
399
+ applyDiscountCode: (code: string) => Promise<QuoteResult>;
400
+ sendOtp: (phone: string, channel?: string) => Promise<void>;
401
+ verifyOtp: (params: {
402
+ phone: string;
403
+ code: string;
404
+ name?: string;
405
+ email?: string;
406
+ }) => Promise<void>;
407
+ purchaseAndPay: (params: {
408
+ paymentMethod: string;
409
+ currency: string;
410
+ discountCode?: string;
411
+ showId?: string;
412
+ idempotencyKey?: string;
413
+ }) => Promise<{
414
+ purchaseId: string;
415
+ payment: PaymentResult;
416
+ nextAction: NextAction;
417
+ }>;
418
+ confirmPayment: (params?: {
419
+ paymentId?: string;
420
+ confirmationToken?: string;
421
+ providerPayload?: string;
422
+ idempotencyKey?: string;
423
+ }) => Promise<PaymentResult>;
424
+ watchPayment: (watchOptions?: {
425
+ intervalMs?: number;
426
+ timeoutMs?: number;
427
+ signal?: AbortSignal;
428
+ }) => Promise<PaymentStatusResult>;
429
+ refreshCatalog: () => Promise<PublicEvent>;
430
+ dispose: () => void;
431
+ /** @internal test helper */
432
+ _dispatch: (action: CheckoutAction) => void;
433
+ };
434
+ type CheckoutController = ReturnType<typeof createCheckoutController>;
435
+
436
+ declare function createMemoryPersistence(): PersistenceAdapter;
437
+ /** sessionStorage adapter — stores only non-PII checkout resume data. */
438
+ declare function createSessionStoragePersistence(storage?: Storage): PersistenceAdapter;
439
+
440
+ declare function createNoopTelemetry(): TelemetryAdapter;
441
+ type TelemetryListener = (event: TelemetryEvent) => void;
442
+ declare function createEventEmitterTelemetry(listeners?: TelemetryListener[]): TelemetryAdapter & {
443
+ subscribe(listener: TelemetryListener): () => void;
444
+ };
445
+
446
+ export { type Buyer, type CartItem, type CheckoutAction, type CheckoutController, type CheckoutPhase, type CheckoutSession, type CheckoutState, type CheckoutTransport, type CreateCheckoutControllerOptions, type CreateTickeanOptions, type NextAction, type PaymentResult, type PaymentStatusResult, type PersistedCheckoutState, type PersistenceAdapter, type PublicEvent, type PublicShow, type PublicShowOption, type PurchaseResult, type QuoteResult, type TelemetryAdapter, type TelemetryEvent, type TelemetryListener, type TickeanClient, TickeanError, type TickeanErrorPayload, checkoutReducer, createCheckoutController, createEventEmitterTelemetry, createInitialState, createMemoryPersistence, createNoopTelemetry, createSessionStoragePersistence, createTickean };
package/dist/index.d.ts CHANGED
@@ -7,7 +7,8 @@ declare class TickeanError extends Error {
7
7
  readonly code: string;
8
8
  readonly details?: Record<string, unknown>;
9
9
  readonly status?: number;
10
- constructor(payload: TickeanErrorPayload, status?: number);
10
+ readonly requestId?: string;
11
+ constructor(payload: TickeanErrorPayload, status?: number, requestId?: string);
11
12
  }
12
13
  type CreateTickeanOptions = {
13
14
  publishableKey: string;
@@ -16,12 +17,55 @@ type CreateTickeanOptions = {
16
17
  demo?: boolean;
17
18
  fetchImpl?: typeof fetch;
18
19
  };
20
+ type CheckoutPhase = "initializing" | "browsing" | "quoting" | "verifying_buyer" | "ready_to_purchase" | "purchasing" | "requires_action" | "processing" | "completed" | "failed" | "expired";
21
+ type NextAction = {
22
+ type: "display_instructions";
23
+ paymentInstructions: unknown;
24
+ } | {
25
+ type: "redirect";
26
+ url: string;
27
+ } | {
28
+ type: "stripe_elements";
29
+ clientSecret: string;
30
+ publishableKey?: string;
31
+ paymentIntentId?: string;
32
+ } | {
33
+ type: "airwallex_dropin";
34
+ intentId: string;
35
+ clientSecret: string;
36
+ currency?: string;
37
+ env?: string;
38
+ countryCode?: string;
39
+ } | {
40
+ type: "dlocal_fields";
41
+ merchantCheckoutToken: string;
42
+ smartFieldsApiKey?: string;
43
+ paymentId?: string;
44
+ sdkUrl?: string;
45
+ } | {
46
+ type: "fintoc_widget";
47
+ sessionToken?: string;
48
+ widgetToken?: string;
49
+ publicKey?: string;
50
+ holderType?: string;
51
+ product?: string;
52
+ } | {
53
+ type: "none";
54
+ };
19
55
  type CheckoutSession = {
20
56
  sessionId: string;
21
57
  sessionToken: string;
22
58
  expiresAt: string;
23
59
  event: PublicEvent;
24
60
  capabilities: Record<string, boolean>;
61
+ phase?: CheckoutPhase | string;
62
+ status?: string;
63
+ otpVerified?: boolean;
64
+ buyerId?: string | null;
65
+ purchaseId?: string | null;
66
+ shoppingCartReference?: string | null;
67
+ nextAction?: NextAction;
68
+ returnUrl?: string | null;
25
69
  };
26
70
  type PublicShowOption = {
27
71
  id: string;
@@ -105,26 +149,58 @@ type PaymentResult = {
105
149
  fintocWidget?: unknown;
106
150
  dlocalGo?: unknown;
107
151
  airwallex?: unknown;
152
+ mercadoPago?: unknown;
153
+ nextAction?: NextAction;
154
+ requiresAction?: boolean;
108
155
  };
109
156
  type PaymentStatusResult = {
110
157
  status: string;
111
158
  purchase?: PurchaseResult["purchase"] | null;
159
+ payment?: PaymentResult | null;
160
+ nextAction?: NextAction;
161
+ requiresAction?: boolean;
162
+ phase?: CheckoutPhase | string;
163
+ };
164
+ type TelemetryEvent = {
165
+ name: string;
166
+ timestamp: number;
167
+ properties?: Record<string, unknown>;
112
168
  };
169
+ interface TelemetryAdapter {
170
+ track(event: TelemetryEvent): void;
171
+ }
172
+ type PersistedCheckoutState = {
173
+ sessionToken?: string;
174
+ eventSlug?: string;
175
+ cart?: CartItem[];
176
+ discountCode?: string | null;
177
+ phase?: CheckoutPhase;
178
+ /** Non-PII buyer flags only */
179
+ buyerVerified?: boolean;
180
+ purchaseId?: string | null;
181
+ };
182
+ interface PersistenceAdapter {
183
+ get(key: string): PersistedCheckoutState | null;
184
+ set(key: string, value: PersistedCheckoutState): void;
185
+ remove(key: string): void;
186
+ }
113
187
  interface CheckoutTransport {
114
188
  request<T>(path: string, init: {
115
189
  method?: string;
116
190
  body?: unknown;
117
191
  sessionToken?: string | null;
192
+ idempotencyKey?: string;
118
193
  }): Promise<T>;
119
194
  }
120
195
 
121
196
  type TickeanClient = ReturnType<typeof createTickean>;
122
197
  declare function createTickean(options: CreateTickeanOptions): {
123
- readonly session: CheckoutSession | null;
198
+ session: CheckoutSession | null;
124
199
  createSession(params: {
125
200
  eventSlug: string;
126
201
  returnUrl?: string;
127
202
  }): Promise<CheckoutSession>;
203
+ getSession(): Promise<CheckoutSession>;
128
204
  getCatalog(): Promise<PublicEvent>;
129
205
  quote(params: {
130
206
  items: CartItem[];
@@ -156,6 +232,13 @@ declare function createTickean(options: CreateTickeanOptions): {
156
232
  paymentMethod: string;
157
233
  currency: string;
158
234
  amount: number;
235
+ idempotencyKey?: string;
236
+ }): Promise<PaymentResult>;
237
+ confirmPayment(params?: {
238
+ paymentId?: string;
239
+ confirmationToken?: string;
240
+ providerPayload?: string;
241
+ idempotencyKey?: string;
159
242
  }): Promise<PaymentResult>;
160
243
  getPaymentStatus(): Promise<PaymentStatusResult>;
161
244
  watchPayment(options?: {
@@ -165,4 +248,199 @@ declare function createTickean(options: CreateTickeanOptions): {
165
248
  }): Promise<PaymentStatusResult>;
166
249
  };
167
250
 
168
- export { type Buyer, type CartItem, type CheckoutSession, type CheckoutTransport, type CreateTickeanOptions, type PaymentResult, type PaymentStatusResult, type PublicEvent, type PublicShow, type PublicShowOption, type PurchaseResult, type QuoteResult, type TickeanClient, TickeanError, type TickeanErrorPayload, createTickean };
251
+ type CheckoutState = {
252
+ phase: CheckoutPhase;
253
+ session: CheckoutSession | null;
254
+ event: PublicEvent | null;
255
+ cart: CartItem[];
256
+ discountCode: string | null;
257
+ quote: QuoteResult | null;
258
+ isQuoting: boolean;
259
+ buyer: Buyer | null;
260
+ buyerVerified: boolean;
261
+ otpSent: boolean;
262
+ purchase: PurchaseResult["purchase"] | null;
263
+ payment: PaymentResult | null;
264
+ nextAction: NextAction;
265
+ error: TickeanError | null;
266
+ loading: boolean;
267
+ };
268
+ type CheckoutAction = {
269
+ type: "INIT_START";
270
+ } | {
271
+ type: "INIT_SUCCESS";
272
+ session: CheckoutSession;
273
+ event: PublicEvent;
274
+ } | {
275
+ type: "INIT_FAILURE";
276
+ error: TickeanError;
277
+ } | {
278
+ type: "SET_CART";
279
+ cart: CartItem[];
280
+ } | {
281
+ type: "SET_DISCOUNT";
282
+ discountCode: string | null;
283
+ } | {
284
+ type: "QUOTE_START";
285
+ } | {
286
+ type: "QUOTE_SUCCESS";
287
+ quote: QuoteResult;
288
+ } | {
289
+ type: "QUOTE_FAILURE";
290
+ error: TickeanError;
291
+ } | {
292
+ type: "OTP_SENT";
293
+ } | {
294
+ type: "OTP_VERIFIED";
295
+ buyer: Buyer;
296
+ } | {
297
+ type: "SET_EVENT";
298
+ event: PublicEvent;
299
+ } | {
300
+ type: "PURCHASE_START";
301
+ } | {
302
+ type: "PURCHASE_SUCCESS";
303
+ purchase: PurchaseResult["purchase"];
304
+ payment: PaymentResult;
305
+ nextAction: NextAction;
306
+ } | {
307
+ type: "PURCHASE_FAILURE";
308
+ error: TickeanError;
309
+ } | {
310
+ type: "SET_NEXT_ACTION";
311
+ nextAction: NextAction;
312
+ payment?: PaymentResult | null;
313
+ } | {
314
+ type: "PROCESSING";
315
+ } | {
316
+ type: "COMPLETED";
317
+ purchase?: PurchaseResult["purchase"] | null;
318
+ } | {
319
+ type: "FAILED";
320
+ error: TickeanError;
321
+ } | {
322
+ type: "EXPIRED";
323
+ } | {
324
+ type: "CLEAR_ERROR";
325
+ } | {
326
+ type: "REHYDRATE";
327
+ partial: Partial<CheckoutState>;
328
+ };
329
+ declare function createInitialState(partial?: Partial<CheckoutState>): CheckoutState;
330
+ declare function checkoutReducer(state: CheckoutState, action: CheckoutAction): CheckoutState;
331
+
332
+ type CreateCheckoutControllerOptions = CreateTickeanOptions & {
333
+ eventSlug: string;
334
+ returnUrl?: string;
335
+ quoteDebounceMs?: number;
336
+ persistence?: PersistenceAdapter | false;
337
+ persistenceKey?: string;
338
+ telemetry?: TelemetryAdapter;
339
+ };
340
+ declare function createCheckoutController(options: CreateCheckoutControllerOptions): {
341
+ client: {
342
+ session: CheckoutSession | null;
343
+ createSession(params: {
344
+ eventSlug: string;
345
+ returnUrl?: string;
346
+ }): Promise<CheckoutSession>;
347
+ getSession(): Promise<CheckoutSession>;
348
+ getCatalog(): Promise<PublicEvent>;
349
+ quote(params: {
350
+ items: CartItem[];
351
+ discountCode?: string;
352
+ showId?: string;
353
+ }): Promise<QuoteResult>;
354
+ sendOtp(params: {
355
+ phone: string;
356
+ channel?: string;
357
+ }): Promise<unknown>;
358
+ verifyOtp(params: {
359
+ phone: string;
360
+ code: string;
361
+ name?: string;
362
+ email?: string;
363
+ }): Promise<unknown>;
364
+ createPurchase(params: {
365
+ items: CartItem[];
366
+ paymentMethod: string;
367
+ currency: string;
368
+ showId?: string;
369
+ discountCode?: string;
370
+ expectedTotal?: number;
371
+ shoppingCartReference?: string;
372
+ idempotencyKey?: string;
373
+ }): Promise<PurchaseResult>;
374
+ createPayment(params: {
375
+ orderId: string;
376
+ paymentMethod: string;
377
+ currency: string;
378
+ amount: number;
379
+ idempotencyKey?: string;
380
+ }): Promise<PaymentResult>;
381
+ confirmPayment(params?: {
382
+ paymentId?: string;
383
+ confirmationToken?: string;
384
+ providerPayload?: string;
385
+ idempotencyKey?: string;
386
+ }): Promise<PaymentResult>;
387
+ getPaymentStatus(): Promise<PaymentStatusResult>;
388
+ watchPayment(options?: {
389
+ intervalMs?: number;
390
+ timeoutMs?: number;
391
+ signal?: AbortSignal;
392
+ }): Promise<PaymentStatusResult>;
393
+ };
394
+ ready: Promise<void>;
395
+ getSnapshot: () => CheckoutState;
396
+ subscribe: (listener: (snapshot: CheckoutState) => void) => () => void;
397
+ setCartItem: (showOptionId: string, amount: number) => void;
398
+ setCart: (cart: CartItem[]) => void;
399
+ applyDiscountCode: (code: string) => Promise<QuoteResult>;
400
+ sendOtp: (phone: string, channel?: string) => Promise<void>;
401
+ verifyOtp: (params: {
402
+ phone: string;
403
+ code: string;
404
+ name?: string;
405
+ email?: string;
406
+ }) => Promise<void>;
407
+ purchaseAndPay: (params: {
408
+ paymentMethod: string;
409
+ currency: string;
410
+ discountCode?: string;
411
+ showId?: string;
412
+ idempotencyKey?: string;
413
+ }) => Promise<{
414
+ purchaseId: string;
415
+ payment: PaymentResult;
416
+ nextAction: NextAction;
417
+ }>;
418
+ confirmPayment: (params?: {
419
+ paymentId?: string;
420
+ confirmationToken?: string;
421
+ providerPayload?: string;
422
+ idempotencyKey?: string;
423
+ }) => Promise<PaymentResult>;
424
+ watchPayment: (watchOptions?: {
425
+ intervalMs?: number;
426
+ timeoutMs?: number;
427
+ signal?: AbortSignal;
428
+ }) => Promise<PaymentStatusResult>;
429
+ refreshCatalog: () => Promise<PublicEvent>;
430
+ dispose: () => void;
431
+ /** @internal test helper */
432
+ _dispatch: (action: CheckoutAction) => void;
433
+ };
434
+ type CheckoutController = ReturnType<typeof createCheckoutController>;
435
+
436
+ declare function createMemoryPersistence(): PersistenceAdapter;
437
+ /** sessionStorage adapter — stores only non-PII checkout resume data. */
438
+ declare function createSessionStoragePersistence(storage?: Storage): PersistenceAdapter;
439
+
440
+ declare function createNoopTelemetry(): TelemetryAdapter;
441
+ type TelemetryListener = (event: TelemetryEvent) => void;
442
+ declare function createEventEmitterTelemetry(listeners?: TelemetryListener[]): TelemetryAdapter & {
443
+ subscribe(listener: TelemetryListener): () => void;
444
+ };
445
+
446
+ export { type Buyer, type CartItem, type CheckoutAction, type CheckoutController, type CheckoutPhase, type CheckoutSession, type CheckoutState, type CheckoutTransport, type CreateCheckoutControllerOptions, type CreateTickeanOptions, type NextAction, type PaymentResult, type PaymentStatusResult, type PersistedCheckoutState, type PersistenceAdapter, type PublicEvent, type PublicShow, type PublicShowOption, type PurchaseResult, type QuoteResult, type TelemetryAdapter, type TelemetryEvent, type TelemetryListener, type TickeanClient, TickeanError, type TickeanErrorPayload, checkoutReducer, createCheckoutController, createEventEmitterTelemetry, createInitialState, createMemoryPersistence, createNoopTelemetry, createSessionStoragePersistence, createTickean };