@whop/elements 0.0.0 → 1.0.0-beta.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/payments.d.cts ADDED
@@ -0,0 +1,1142 @@
1
+ /**
2
+ * Options for `whop.payments.create()`: the controller's props plus its `on<Event>` callbacks. In React, these are the `<Payments>` component's props.
3
+ * @example
4
+ * ```ts
5
+ * import { loadWhop } from "@whop/elements";
6
+ *
7
+ * const whop = (await loadWhop())({ locale: "en" });
8
+ * const payments = whop.payments.create({}); // options: props + on<Event> callbacks
9
+ * ```
10
+ * @see https://docs.whop.com/elements/latest/payments/overview
11
+ */
12
+ export type PaymentsOptions = (
13
+ | {
14
+ /**
15
+ * Account ID, prefixed `biz_`. Omit only when calling static methods without a collection surface.
16
+ */
17
+ accountId: string;
18
+ /**
19
+ * Plan ID, prefixed `plan_`. It resolves client-side to currency, amount, and method configuration. Pass a plan or inline currency and amount, never both.
20
+ */
21
+ plan: string;
22
+ /**
23
+ * Minor-unit `feeInclusive` and `feeFree` totals used to gate methods when checkout re-prices `amount` for a fee-free method such as BNPL. Each method is checked against its matching total, preventing the selected fee-free method from disappearing. When omitted, `amount` gates every method.
24
+ */
25
+ offerAmounts?: undefined;
26
+ /**
27
+ * Return URL for off-site bank or 3DS steps. Defaults to the mounting page.
28
+ */
29
+ returnUrl?: string;
30
+ /**
31
+ * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
32
+ */
33
+ setupFutureUsage?: "off_session" | "on_session";
34
+ /**
35
+ * Wallet availability override for deterministic previews. Live checkouts probe the host.
36
+ */
37
+ previewWalletAvailability?: WalletAvailability;
38
+ /**
39
+ * Checkout session updated when a buyer signs in. Pass its `chs_`-prefixed `id` and `client_secret`. Without them, sign-in succeeds but the session does not record the buyer.
40
+ */
41
+ checkoutSession?: { id: string; clientSecret: string; };
42
+ /**
43
+ * Runs when the grouped loading state changes. The value is `true` while any mounted element is still loading.
44
+ */
45
+ onLoadingChange?: ((loading: boolean) => void);
46
+ }
47
+ | {
48
+ /**
49
+ * Account ID, prefixed `biz_`. Omit only when calling static methods without a collection surface.
50
+ */
51
+ accountId: string;
52
+ /**
53
+ * Lowercase three-letter ISO 4217 payment currency code. It filters the payment-method matrix.
54
+ */
55
+ currency: string;
56
+ /**
57
+ * Payment amount in minor units. Methods whose bounds exclude it aren't offered.
58
+ */
59
+ amount: number;
60
+ /**
61
+ * Minor-unit `feeInclusive` and `feeFree` totals used to gate methods when checkout re-prices `amount` for a fee-free method such as BNPL. Each method is checked against its matching total, preventing the selected fee-free method from disappearing. When omitted, `amount` gates every method.
62
+ */
63
+ offerAmounts?: { feeInclusive: number; feeFree: number; };
64
+ /**
65
+ * Account payment-method filters in the API's `enabled`, `disabled`, and `include_platform_defaults` format. `disabled` removes types, `enabled` restores offered types, and `include_platform_defaults: false` leaves only enabled types. Plans provide their own configuration.
66
+ */
67
+ paymentMethodConfiguration?: { enabled?: string[] | undefined; disabled?: string[] | undefined; include_platform_defaults?: boolean | undefined; };
68
+ /**
69
+ * Return URL for off-site bank or 3DS steps. Defaults to the mounting page.
70
+ */
71
+ returnUrl?: string;
72
+ /**
73
+ * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
74
+ */
75
+ setupFutureUsage?: "off_session" | "on_session";
76
+ /**
77
+ * Wallet availability override for deterministic previews. Live checkouts probe the host.
78
+ */
79
+ previewWalletAvailability?: WalletAvailability;
80
+ /**
81
+ * Checkout session updated when a buyer signs in. Pass its `chs_`-prefixed `id` and `client_secret`. Without them, sign-in succeeds but the session does not record the buyer.
82
+ */
83
+ checkoutSession?: { id: string; clientSecret: string; };
84
+ /**
85
+ * Runs when the grouped loading state changes. The value is `true` while any mounted element is still loading.
86
+ */
87
+ onLoadingChange?: ((loading: boolean) => void);
88
+ }
89
+ | {
90
+ /**
91
+ * Account ID, prefixed `biz_`. Omit only when calling static methods without a collection surface.
92
+ */
93
+ accountId?: undefined;
94
+ /**
95
+ * Plan ID, prefixed `plan_`. It resolves client-side to currency, amount, and method configuration. Pass a plan or inline currency and amount, never both.
96
+ */
97
+ plan?: undefined;
98
+ /**
99
+ * Lowercase three-letter ISO 4217 payment currency code. It filters the payment-method matrix.
100
+ */
101
+ currency?: undefined;
102
+ /**
103
+ * Payment amount in minor units. Methods whose bounds exclude it aren't offered.
104
+ */
105
+ amount?: undefined;
106
+ /**
107
+ * Minor-unit `feeInclusive` and `feeFree` totals used to gate methods when checkout re-prices `amount` for a fee-free method such as BNPL. Each method is checked against its matching total, preventing the selected fee-free method from disappearing. When omitted, `amount` gates every method.
108
+ */
109
+ offerAmounts?: undefined;
110
+ /**
111
+ * Account payment-method filters in the API's `enabled`, `disabled`, and `include_platform_defaults` format. `disabled` removes types, `enabled` restores offered types, and `include_platform_defaults: false` leaves only enabled types. Plans provide their own configuration.
112
+ */
113
+ paymentMethodConfiguration?: undefined;
114
+ /**
115
+ * Return URL for off-site bank or 3DS steps. Defaults to the mounting page.
116
+ */
117
+ returnUrl?: string;
118
+ /**
119
+ * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
120
+ */
121
+ setupFutureUsage?: "off_session" | "on_session";
122
+ /**
123
+ * Wallet availability override for deterministic previews. Live checkouts probe the host.
124
+ */
125
+ previewWalletAvailability?: WalletAvailability;
126
+ /**
127
+ * Checkout session updated when a buyer signs in. Pass its `chs_`-prefixed `id` and `client_secret`. Without them, sign-in succeeds but the session does not record the buyer.
128
+ */
129
+ checkoutSession?: { id: string; clientSecret: string; };
130
+ /**
131
+ * Runs when the grouped loading state changes. The value is `true` while any mounted element is still loading.
132
+ */
133
+ onLoadingChange?: ((loading: boolean) => void);
134
+ }
135
+ ) & {
136
+ /**
137
+ * Visual customization for this group's elements. Overrides the global `WhopElements({ appearance })`. Change it live with `update({ appearance })`.
138
+ */
139
+ appearance?: import("./_framework.js").Appearance;
140
+ /**
141
+ * Locale for this group's element UI text. Set it to one of the app's built locales to override the global configuration. Any other value falls back to the default locale.
142
+ */
143
+ locale?: import("./_framework.js").WhopElementsLocale;
144
+ };
145
+
146
+ /**
147
+ * Consumer props for the "payment" element. Set at create (or as `<PaymentElement />` JSX props), and updatable live via `update()`.
148
+ * @see https://docs.whop.com/elements/latest/payments/payment
149
+ */
150
+ export interface PaymentElementProps {
151
+ /**
152
+ * Controls billing-details collection. `billingDetails: 'minimal'` (default) follows each method's matrix. Methods collect name and the complete country format by default. An override may collect only the declared minimum or nothing. For cards, the minimum is name on card, country, and postal code. `'full'` requires name and the complete country format for every fresh method. `'never'` hides the block. Pass the address to `createConfirmationToken` instead. The country selector includes only countries supported by the method and payment currency. It locks when only one is available.
153
+ * @default {"billingDetails":"minimal"}
154
+ */
155
+ fields?: { billingDetails?: "full" | "minimal" | "never" | undefined; };
156
+ /**
157
+ * Picker layout. `accordion` (default) stacks methods and expands details inline. `horizontal` shows equal-width, non-scrolling tiles with selected details below. After four methods, a More tile opens a native selector. The method picked there occupies the final tile until the next selection. Selection and confirmation behave identically.
158
+ * @default "accordion"
159
+ */
160
+ layout?: "accordion" | "horizontal";
161
+ /**
162
+ * `accordion` only. Adds spacing and separate card styling between methods. Ignored when `layout` is `horizontal`.
163
+ * @default false
164
+ */
165
+ separated?: boolean;
166
+ /**
167
+ * Controls display order in either layout. Listed types appear first in order. Unlisted types retain their relative order. Does not affect availability.
168
+ * @default []
169
+ */
170
+ order?: string[];
171
+ /**
172
+ * Whether to select the first offered method after resolution. The default `true` respects `order` and emits `selected` and `change` like a buyer interaction. It runs once before buyer interaction and does nothing when no method is offered. Set `false` to mount unselected. Independently, if an update removes the selected method, selection falls back to the first offered method. An already unselected element stays unselected.
173
+ * @default true
174
+ */
175
+ autoSelect?: boolean;
176
+ }
177
+
178
+ /**
179
+ * The live handle for a mounted "payment" element. Returned by `create("payment")`; in React, the component's `ref`.
180
+ * @see https://docs.whop.com/elements/latest/payments/payment
181
+ */
182
+ export interface PaymentElementHandle {
183
+ /**
184
+ * Select a method through the same path as a buyer interaction. For example, `select('cashapp')` expands the tile and emits `selected` and `change`. Cards remain `complete: false` until their fields are complete. Unknown, unavailable, or amount-gated methods reject with code `METHOD_NOT_OFFERED`. `select(null)` clears selection and emits `change` with `complete: false`. Use with `autoSelect={false}` for full external control.
185
+ */
186
+ select: (input: string | null) => Promise<void>;
187
+ /**
188
+ * Mounts the element in `target` and starts loading. React components mount themselves.
189
+ */
190
+ mount: (target: string | HTMLElement) => void;
191
+ /**
192
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
193
+ */
194
+ destroy: () => void;
195
+ /**
196
+ * Merges new props into the mounted element. In React, change the component props instead.
197
+ */
198
+ update: (options: Partial<PaymentElementProps>) => void;
199
+ }
200
+
201
+ /**
202
+ * Options for `create("payment")`: the consumer props plus event callbacks and lifecycle hooks.
203
+ * @example
204
+ * ```ts
205
+ * const payment = payments.create("payment", {}); // this interface: props + on<Event> callbacks
206
+ * payment.mount("#payments-payment");
207
+ * ```
208
+ * @see https://docs.whop.com/elements/latest/payments/payment
209
+ */
210
+ export interface PaymentElementCreateOptions {
211
+ /**
212
+ * Controls billing-details collection. `billingDetails: 'minimal'` (default) follows each method's matrix. Methods collect name and the complete country format by default. An override may collect only the declared minimum or nothing. For cards, the minimum is name on card, country, and postal code. `'full'` requires name and the complete country format for every fresh method. `'never'` hides the block. Pass the address to `createConfirmationToken` instead. The country selector includes only countries supported by the method and payment currency. It locks when only one is available.
213
+ * @default {"billingDetails":"minimal"}
214
+ */
215
+ fields?: { billingDetails?: "full" | "minimal" | "never" | undefined; };
216
+ /**
217
+ * Picker layout. `accordion` (default) stacks methods and expands details inline. `horizontal` shows equal-width, non-scrolling tiles with selected details below. After four methods, a More tile opens a native selector. The method picked there occupies the final tile until the next selection. Selection and confirmation behave identically.
218
+ * @default "accordion"
219
+ */
220
+ layout?: "accordion" | "horizontal";
221
+ /**
222
+ * `accordion` only. Adds spacing and separate card styling between methods. Ignored when `layout` is `horizontal`.
223
+ * @default false
224
+ */
225
+ separated?: boolean;
226
+ /**
227
+ * Controls display order in either layout. Listed types appear first in order. Unlisted types retain their relative order. Does not affect availability.
228
+ * @default []
229
+ */
230
+ order?: string[];
231
+ /**
232
+ * Whether to select the first offered method after resolution. The default `true` respects `order` and emits `selected` and `change` like a buyer interaction. It runs once before buyer interaction and does nothing when no method is offered. Set `false` to mount unselected. Independently, if an update removes the selected method, selection falls back to the first offered method. An already unselected element stays unselected.
233
+ * @default true
234
+ */
235
+ autoSelect?: boolean;
236
+ /**
237
+ * Fires when selection changes. `complete: true` means the buyer selected a method and completed its card fields or required inputs. Use it to enable confirmation. `method` provides category, per-currency countries, and amount bounds for dependent UI such as country fields. `supportsBuyerFee` indicates whether to include Whop's buyer service fee in the displayed total.
238
+ */
239
+ onChange?: ((payload: { complete: boolean; type?: string | undefined; supportsBuyerFee?: boolean | undefined; method?: { type: string; category: string; template: string; display_name: string; countries: ({ country: string; min_amount: number | null; max_amount: number | null; })[]; min_amount: number | null; max_amount: number | null; } | undefined; }) => void);
240
+ /**
241
+ * Fires about 300 ms after the internal billing address changes. Use it for tax, shipping, or other address-dependent updates. `country` is an ISO 3166-1 alpha-2 code. The payload omits other address keys when empty or unused for that country. `complete: true` means the billing block is valid and complete. This event fires only while the payment element owns address collection. With `fields.billingDetails: 'never'`, use your address source. With a mounted `AddressElement`, use its `change` event.
242
+ */
243
+ onAddressChange?: ((payload: { complete: boolean; address: { line1?: string | undefined; line2?: string | undefined; city?: string | undefined; state?: string | undefined; postal_code?: string | undefined; country: string; }; }) => void);
244
+ /**
245
+ * Runs after the loading skeleton first paints and before `onReady`.
246
+ */
247
+ onLoaderStart?: (() => void);
248
+ /**
249
+ * Runs after the element's first complete paint.
250
+ */
251
+ onReady?: (() => void);
252
+ /**
253
+ * Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
254
+ */
255
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
256
+ }
257
+
258
+ /**
259
+ * Consumer props for the "address" element. Set at create (or as `<AddressElement />` JSX props), and updatable live via `update()`.
260
+ * @see https://docs.whop.com/elements/latest/payments/address
261
+ */
262
+ export interface AddressElementProps {
263
+ /**
264
+ * `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
265
+ * @default "full"
266
+ */
267
+ layout?: "full" | "compact";
268
+ /**
269
+ * Address line 2: always visible (default), revealed by a text button (`toggle`), or never collected.
270
+ * @default "always"
271
+ */
272
+ line2?: "never" | "toggle" | "always";
273
+ /**
274
+ * The name row: one full-name field (default), split first/last fields, or none.
275
+ * @default "combined"
276
+ */
277
+ name?: "split" | "combined" | "none";
278
+ /**
279
+ * Browser autocomplete purpose: `billing` (default) or `shipping`.
280
+ * @default "billing"
281
+ */
282
+ mode?: "billing" | "shipping";
283
+ /**
284
+ * `full` (default) follows the selected country's complete address format. `minimal` collects only country and postal code. `name` independently adds required name fields. Set `name` to `none` to omit them. This element does not add fields required by a payment method. Card confirmation requires a name, country, and postal code, so keep `name` enabled or pass `billingDetails.name`.
285
+ * @default "full"
286
+ */
287
+ scope?: "full" | "minimal";
288
+ /**
289
+ * Organization fields: none (default), name only, or name with a business/individual selector.
290
+ * @default "none"
291
+ */
292
+ organization?: "name" | "none" | "name_with_type";
293
+ /**
294
+ * Seed values applied once before first paint (`address.country` is an ISO 3166-1 alpha-2 country code). Takes precedence over IP-country detection.
295
+ */
296
+ defaultValues?: { name?: string | undefined; address?: { name?: string | undefined; first_name?: string | undefined; last_name?: string | undefined; organization?: string | undefined; organization_type?: "business" | "individual" | undefined; line1?: string | undefined; line2?: string | undefined; city?: string | undefined; state?: string | undefined; postal_code?: string | undefined; country?: string | undefined; } | undefined; };
297
+ /**
298
+ * Default the country from the buyer's IP (resolved before first paint). Falls back to the controller's `countryHint`, then US.
299
+ * @default true
300
+ */
301
+ detectCountry?: boolean;
302
+ /**
303
+ * Allowed ISO 3166-1 alpha-2 country codes. With one code, the selector remains visible but offers only that country.
304
+ */
305
+ allowedCountries?: string[];
306
+ /**
307
+ * Enables Google Places suggestions for the street address. If no match appears or Places is blocked, the list reports no matches and lets buyers enter the address manually. Set `false` for a plain input.
308
+ * @default true
309
+ */
310
+ autocomplete?: boolean;
311
+ /**
312
+ * Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
313
+ */
314
+ customFields?: ({ key: string; label: string; type: "text" | "phone" | "select" | "date"; position: "after_name" | "after_organization" | "before_country" | "after_address"; required?: boolean | undefined; options?: string[] | undefined; format?: string | undefined; autocomplete?: string | undefined; })[];
315
+ /**
316
+ * Fallback country after `defaultValues` and IP detection. Use an ISO 3166-1 alpha-2 code. An empty value falls back to `US`.
317
+ * @default ""
318
+ */
319
+ countryHint?: string;
320
+ }
321
+
322
+ /**
323
+ * The live handle for a mounted "address" element. Returned by `create("address")`; in React, the component's `ref`.
324
+ * @see https://docs.whop.com/elements/latest/payments/address
325
+ */
326
+ export interface AddressElementHandle {
327
+ /**
328
+ * Validates the form, reveals all inline errors, and never throws. Returns `complete`, `address`, and `errors`. `errors` is empty exactly when `complete` is true. Keys use contract names such as `postal_code` and `line1`, `custom:<key>` for custom fields, and transient `form` while loading.
329
+ */
330
+ validate: () => Promise<{ complete: boolean; address: { name?: string | undefined; first_name?: string | undefined; last_name?: string | undefined; organization?: string | undefined; organization_type?: "business" | "individual" | undefined; line1?: string | undefined; line2?: string | undefined; city?: string | undefined; state?: string | undefined; postal_code?: string | undefined; country: string; }; errors: Record<string, string>; }>;
331
+ /**
332
+ * Returns `address` and `custom` without validation or revealing errors.
333
+ */
334
+ getValues: () => Promise<{ address: { name?: string | undefined; first_name?: string | undefined; last_name?: string | undefined; organization?: string | undefined; organization_type?: "business" | "individual" | undefined; line1?: string | undefined; line2?: string | undefined; city?: string | undefined; state?: string | undefined; postal_code?: string | undefined; country: string; }; custom: Record<string, string>; }>;
335
+ /**
336
+ * Mounts the element in `target` and starts loading. React components mount themselves.
337
+ */
338
+ mount: (target: string | HTMLElement) => void;
339
+ /**
340
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
341
+ */
342
+ destroy: () => void;
343
+ /**
344
+ * Merges new props into the mounted element. In React, change the component props instead.
345
+ */
346
+ update: (options: Partial<AddressElementProps>) => void;
347
+ }
348
+
349
+ /**
350
+ * Options for `create("address")`: the consumer props plus event callbacks and lifecycle hooks.
351
+ * @example
352
+ * ```ts
353
+ * const address = payments.create("address", {}); // this interface: props + on<Event> callbacks
354
+ * address.mount("#payments-address");
355
+ * ```
356
+ * @see https://docs.whop.com/elements/latest/payments/address
357
+ */
358
+ export interface AddressElementCreateOptions {
359
+ /**
360
+ * `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
361
+ * @default "full"
362
+ */
363
+ layout?: "full" | "compact";
364
+ /**
365
+ * Address line 2: always visible (default), revealed by a text button (`toggle`), or never collected.
366
+ * @default "always"
367
+ */
368
+ line2?: "never" | "toggle" | "always";
369
+ /**
370
+ * The name row: one full-name field (default), split first/last fields, or none.
371
+ * @default "combined"
372
+ */
373
+ name?: "split" | "combined" | "none";
374
+ /**
375
+ * Browser autocomplete purpose: `billing` (default) or `shipping`.
376
+ * @default "billing"
377
+ */
378
+ mode?: "billing" | "shipping";
379
+ /**
380
+ * `full` (default) follows the selected country's complete address format. `minimal` collects only country and postal code. `name` independently adds required name fields. Set `name` to `none` to omit them. This element does not add fields required by a payment method. Card confirmation requires a name, country, and postal code, so keep `name` enabled or pass `billingDetails.name`.
381
+ * @default "full"
382
+ */
383
+ scope?: "full" | "minimal";
384
+ /**
385
+ * Organization fields: none (default), name only, or name with a business/individual selector.
386
+ * @default "none"
387
+ */
388
+ organization?: "name" | "none" | "name_with_type";
389
+ /**
390
+ * Seed values applied once before first paint (`address.country` is an ISO 3166-1 alpha-2 country code). Takes precedence over IP-country detection.
391
+ */
392
+ defaultValues?: { name?: string | undefined; address?: { name?: string | undefined; first_name?: string | undefined; last_name?: string | undefined; organization?: string | undefined; organization_type?: "business" | "individual" | undefined; line1?: string | undefined; line2?: string | undefined; city?: string | undefined; state?: string | undefined; postal_code?: string | undefined; country?: string | undefined; } | undefined; };
393
+ /**
394
+ * Default the country from the buyer's IP (resolved before first paint). Falls back to the controller's `countryHint`, then US.
395
+ * @default true
396
+ */
397
+ detectCountry?: boolean;
398
+ /**
399
+ * Allowed ISO 3166-1 alpha-2 country codes. With one code, the selector remains visible but offers only that country.
400
+ */
401
+ allowedCountries?: string[];
402
+ /**
403
+ * Enables Google Places suggestions for the street address. If no match appears or Places is blocked, the list reports no matches and lets buyers enter the address manually. Set `false` for a plain input.
404
+ * @default true
405
+ */
406
+ autocomplete?: boolean;
407
+ /**
408
+ * Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
409
+ */
410
+ customFields?: ({ key: string; label: string; type: "text" | "phone" | "select" | "date"; position: "after_name" | "after_organization" | "before_country" | "after_address"; required?: boolean | undefined; options?: string[] | undefined; format?: string | undefined; autocomplete?: string | undefined; })[];
411
+ /**
412
+ * Fallback country after `defaultValues` and IP detection. Use an ISO 3166-1 alpha-2 code. An empty value falls back to `US`.
413
+ * @default ""
414
+ */
415
+ countryHint?: string;
416
+ /**
417
+ * Fires when the address changes. `complete` is true when all country-specific fields and required custom fields are valid. `address` follows confirmation-token `billing_details` names, including `postal_code`. `country` is an ISO 3166-1 alpha-2 code. Custom values are in `custom`.
418
+ */
419
+ onChange?: ((payload: { complete: boolean; address: { name?: string | undefined; first_name?: string | undefined; last_name?: string | undefined; organization?: string | undefined; organization_type?: "business" | "individual" | undefined; line1?: string | undefined; line2?: string | undefined; city?: string | undefined; state?: string | undefined; postal_code?: string | undefined; country: string; }; custom: Record<string, string>; }) => void);
420
+ /**
421
+ * Runs after the loading skeleton first paints and before `onReady`.
422
+ */
423
+ onLoaderStart?: (() => void);
424
+ /**
425
+ * Runs after the element's first complete paint.
426
+ */
427
+ onReady?: (() => void);
428
+ /**
429
+ * Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
430
+ */
431
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
432
+ }
433
+
434
+ /**
435
+ * Consumer props for the "card" element. Set at create (or as `<CardElement />` JSX props), and updatable live via `update()`.
436
+ * @see https://docs.whop.com/elements/latest/payments/card
437
+ */
438
+ export interface CardElementProps {
439
+ /**
440
+ * `stacked` (default) places the card number above expiration and security code. `compact` places all three in one row.
441
+ * @default "stacked"
442
+ */
443
+ layout?: "compact" | "stacked";
444
+ }
445
+
446
+ /**
447
+ * The live handle for a mounted "card" element. Returned by `create("card")`; in React, the component's `ref`.
448
+ * @see https://docs.whop.com/elements/latest/payments/card
449
+ */
450
+ export interface CardElementHandle {
451
+ /**
452
+ * Mounts the element in `target` and starts loading. React components mount themselves.
453
+ */
454
+ mount: (target: string | HTMLElement) => void;
455
+ /**
456
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
457
+ */
458
+ destroy: () => void;
459
+ /**
460
+ * Merges new props into the mounted element. In React, change the component props instead.
461
+ */
462
+ update: (options: Partial<CardElementProps>) => void;
463
+ }
464
+
465
+ /**
466
+ * Options for `create("card")`: the consumer props plus event callbacks and lifecycle hooks.
467
+ * @example
468
+ * ```ts
469
+ * const card = payments.create("card", {}); // this interface: props + on<Event> callbacks
470
+ * card.mount("#payments-card");
471
+ * ```
472
+ * @see https://docs.whop.com/elements/latest/payments/card
473
+ */
474
+ export interface CardElementCreateOptions {
475
+ /**
476
+ * `stacked` (default) places the card number above expiration and security code. `compact` places all three in one row.
477
+ * @default "stacked"
478
+ */
479
+ layout?: "compact" | "stacked";
480
+ /**
481
+ * Fires when card fields change. `complete` becomes true after the buyer fills all three. Use it to enable confirmation. `brand` is the detected card network.
482
+ */
483
+ onChange?: ((payload: { complete: boolean; brand: string; }) => void);
484
+ /**
485
+ * Runs after the loading skeleton first paints and before `onReady`.
486
+ */
487
+ onLoaderStart?: (() => void);
488
+ /**
489
+ * Runs after the element's first complete paint.
490
+ */
491
+ onReady?: (() => void);
492
+ /**
493
+ * Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
494
+ */
495
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
496
+ }
497
+
498
+ /**
499
+ * Consumer props for the "email" element. Set at create (or as `<EmailElement />` JSX props), and updatable live via `update()`.
500
+ * @see https://docs.whop.com/elements/latest/payments/email
501
+ */
502
+ export interface EmailElementProps {
503
+ /**
504
+ * Shows the localized label. Set `false` when supplying your own. The input retains a localized `aria-label`.
505
+ * @default true
506
+ */
507
+ label?: boolean;
508
+ /**
509
+ * Seed value applied once at mount.
510
+ * @default ""
511
+ */
512
+ defaultValue?: string;
513
+ /**
514
+ * Placeholder text for the email input. Empty (default) renders `you@example.com`.
515
+ * @default ""
516
+ */
517
+ placeholder?: string;
518
+ }
519
+
520
+ /**
521
+ * The live handle for a mounted "email" element. Returned by `create("email")`; in React, the component's `ref`.
522
+ * @see https://docs.whop.com/elements/latest/payments/email
523
+ */
524
+ export interface EmailElementHandle {
525
+ /**
526
+ * Mounts the element in `target` and starts loading. React components mount themselves.
527
+ */
528
+ mount: (target: string | HTMLElement) => void;
529
+ /**
530
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
531
+ */
532
+ destroy: () => void;
533
+ /**
534
+ * Merges new props into the mounted element. In React, change the component props instead.
535
+ */
536
+ update: (options: Partial<EmailElementProps>) => void;
537
+ }
538
+
539
+ /**
540
+ * Options for `create("email")`: the consumer props plus event callbacks and lifecycle hooks.
541
+ * @example
542
+ * ```ts
543
+ * const email = payments.create("email", {}); // this interface: props + on<Event> callbacks
544
+ * email.mount("#payments-email");
545
+ * ```
546
+ * @see https://docs.whop.com/elements/latest/payments/email
547
+ */
548
+ export interface EmailElementCreateOptions {
549
+ /**
550
+ * Shows the localized label. Set `false` when supplying your own. The input retains a localized `aria-label`.
551
+ * @default true
552
+ */
553
+ label?: boolean;
554
+ /**
555
+ * Seed value applied once at mount.
556
+ * @default ""
557
+ */
558
+ defaultValue?: string;
559
+ /**
560
+ * Placeholder text for the email input. Empty (default) renders `you@example.com`.
561
+ * @default ""
562
+ */
563
+ placeholder?: string;
564
+ /**
565
+ * Fires when the email changes. `complete` is true when plausible. Sign-in fires it with the signed-in email, which also feeds `createConfirmationToken()`.
566
+ */
567
+ onChange?: ((payload: { email: string; complete: boolean; }) => void);
568
+ /**
569
+ * Runs after the loading skeleton first paints and before `onReady`.
570
+ */
571
+ onLoaderStart?: (() => void);
572
+ /**
573
+ * Runs after the element's first complete paint.
574
+ */
575
+ onReady?: (() => void);
576
+ /**
577
+ * Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
578
+ */
579
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
580
+ }
581
+
582
+ /**
583
+ * Consumer props for the "taxId" element. Set at create (or as `<TaxIdElement />` JSX props), and updatable live via `update()`.
584
+ * @see https://docs.whop.com/elements/latest/payments/taxId
585
+ */
586
+ export interface TaxIdElementProps {
587
+ /**
588
+ * Disables both fields while the host saves the last committed registration.
589
+ * @default false
590
+ */
591
+ disabled?: boolean;
592
+ /**
593
+ * ISO 3166-1 alpha-2 buyer country used to preselect the type. `AR` selects `ar_cuit`. EU and unmapped or empty values select `eu_vat`. Other uniquely mapped countries select their type. A manual selection persists across country changes.
594
+ * @default ""
595
+ */
596
+ country?: string;
597
+ /**
598
+ * Initial `type` and `value` from a resumed session. An unsupported `type` falls back to the country default.
599
+ */
600
+ defaultValue?: { type: string; value: string; };
601
+ /**
602
+ * API validation error shown below the value input. Empty (default) shows nothing.
603
+ * @default ""
604
+ */
605
+ error?: string;
606
+ }
607
+
608
+ /**
609
+ * The live handle for a mounted "taxId" element. Returned by `create("taxId")`; in React, the component's `ref`.
610
+ * @see https://docs.whop.com/elements/latest/payments/taxId
611
+ */
612
+ export interface TaxIdElementHandle {
613
+ /**
614
+ * Mounts the element in `target` and starts loading. React components mount themselves.
615
+ */
616
+ mount: (target: string | HTMLElement) => void;
617
+ /**
618
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
619
+ */
620
+ destroy: () => void;
621
+ /**
622
+ * Merges new props into the mounted element. In React, change the component props instead.
623
+ */
624
+ update: (options: Partial<TaxIdElementProps>) => void;
625
+ }
626
+
627
+ /**
628
+ * Options for `create("taxId")`: the consumer props plus event callbacks and lifecycle hooks.
629
+ * @example
630
+ * ```ts
631
+ * const taxId = payments.create("taxId", {}); // this interface: props + on<Event> callbacks
632
+ * taxId.mount("#payments-taxId");
633
+ * ```
634
+ * @see https://docs.whop.com/elements/latest/payments/taxId
635
+ */
636
+ export interface TaxIdElementCreateOptions {
637
+ /**
638
+ * Disables both fields while the host saves the last committed registration.
639
+ * @default false
640
+ */
641
+ disabled?: boolean;
642
+ /**
643
+ * ISO 3166-1 alpha-2 buyer country used to preselect the type. `AR` selects `ar_cuit`. EU and unmapped or empty values select `eu_vat`. Other uniquely mapped countries select their type. A manual selection persists across country changes.
644
+ * @default ""
645
+ */
646
+ country?: string;
647
+ /**
648
+ * Initial `type` and `value` from a resumed session. An unsupported `type` falls back to the country default.
649
+ */
650
+ defaultValue?: { type: string; value: string; };
651
+ /**
652
+ * API validation error shown below the value input. Empty (default) shows nothing.
653
+ * @default ""
654
+ */
655
+ error?: string;
656
+ /**
657
+ * Fires on blur or Enter when the value is nonempty, or when the type changes with a value present. Identical consecutive values fire once. Clearing the value doesn't fire. The host must clear stored registrations.
658
+ */
659
+ onChange?: ((payload: { taxId: { type: "ad_nrt" | "ao_tin" | "ar_cuit" | "al_tin" | "am_tin" | "aw_tin" | "au_abn" | "au_arn" | "eu_vat" | "az_tin" | "bs_tin" | "bh_vat" | "bd_bin" | "bb_tin" | "by_tin" | "bj_ifu" | "bo_tin" | "ba_tin" | "br_cnpj" | "br_cpf" | "bg_uic" | "bf_ifu" | "kh_tin" | "cm_niu" | "ca_bn" | "ca_gst_hst" | "ca_pst_bc" | "ca_pst_mb" | "ca_pst_sk" | "ca_qst" | "cv_nif" | "cl_tin" | "cn_tin" | "co_nit" | "cd_nif" | "cr_tin" | "hr_oib" | "do_rcn" | "ec_ruc" | "eg_tin" | "sv_nit" | "et_tin" | "eu_oss_vat" | "ge_vat" | "gh_tin" | "de_stn" | "gb_vat" | "gn_nif" | "hk_br" | "hu_tin" | "is_vat" | "in_gst" | "id_npwp" | "il_vat" | "jp_cn" | "jp_rn" | "jp_trn" | "kz_bin" | "ke_pin" | "kg_tin" | "la_tin" | "li_uid" | "li_vat" | "my_frp" | "my_itn" | "my_sst" | "mr_nif" | "mx_rfc" | "md_vat" | "me_pib" | "ma_vat" | "np_pan" | "nz_gst" | "ng_tin" | "mk_vat" | "no_vat" | "no_voec" | "om_vat" | "pe_ruc" | "ph_tin" | "pl_nip" | "ro_tin" | "ru_inn" | "ru_kpp" | "sa_vat" | "sn_ninea" | "rs_pib" | "sg_gst" | "sg_uen" | "si_tin" | "za_vat" | "kr_brn" | "es_cif" | "ch_uid" | "ch_vat" | "tw_vat" | "tj_tin" | "tz_vat" | "th_vat" | "tr_tin" | "ug_tin" | "ua_vat" | "ae_trn" | "us_ein" | "uy_ruc" | "uz_tin" | "uz_vat" | "ve_rif" | "vn_tin" | "zm_tin" | "zw_tin" | "sr_fin" | "xi_vat"; value: string; }; }) => void);
660
+ /**
661
+ * Runs after the loading skeleton first paints and before `onReady`.
662
+ */
663
+ onLoaderStart?: (() => void);
664
+ /**
665
+ * Runs after the element's first complete paint.
666
+ */
667
+ onReady?: (() => void);
668
+ /**
669
+ * Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
670
+ */
671
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
672
+ }
673
+
674
+ /**
675
+ * Consumer props for the "cardFields" sub-controller: the `create("cardFields")` options and the minted sub handle's `update()` payload (React: `<CardFields>` props). Parent-injected props never appear here.
676
+ * @see https://docs.whop.com/elements/latest/payments/overview
677
+ */
678
+ export interface CardFieldsSubOptions {
679
+ /**
680
+ * `stacked` (default) shapes composed fields as a number row above expiration and security code. `compact` shapes one row. Separately mounted fields ignore this layout and render with full borders and rounded corners.
681
+ * @default "stacked"
682
+ */
683
+ layout?: "compact" | "stacked";
684
+ /**
685
+ * Advanced Basis Theory publishable key. Omit it to fetch the key automatically.
686
+ */
687
+ publicKey?: string;
688
+ /**
689
+ * The seller's accepted card networks in display order — the matrix card entry's `networks` objects, whose API-served icons drive the number field's brand art. Omit it to fetch alongside the key.
690
+ */
691
+ networks?: CardNetworkArt[];
692
+ /**
693
+ * Fires when completeness changes. `complete` becomes true after the buyer fills all three fields. Use it to enable confirmation. `brand` is the detected card network.
694
+ */
695
+ onChange?: ((payload: { complete: boolean; brand: string; }) => void);
696
+ /**
697
+ * Runs when the grouped loading state changes. The value is `true` while any mounted element is still loading.
698
+ */
699
+ onLoadingChange?: ((loading: boolean) => void);
700
+ }
701
+
702
+ /**
703
+ * Consumer props for the "cardFields" sub-controller's "cardNumber" element.
704
+ * @see https://docs.whop.com/elements/latest/payments/overview
705
+ */
706
+ export interface CardNumberElementProps {}
707
+
708
+ /**
709
+ * The live handle for a mounted "cardNumber" element. Returned by the "cardFields" sub handle's `create("cardNumber")`.
710
+ * @see https://docs.whop.com/elements/latest/payments/overview
711
+ */
712
+ export interface CardNumberElementHandle {
713
+ /**
714
+ * Mounts the element in `target` and starts loading. React components mount themselves.
715
+ */
716
+ mount: (target: string | HTMLElement) => void;
717
+ /**
718
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
719
+ */
720
+ destroy: () => void;
721
+ /**
722
+ * Merges new props into the mounted element. In React, change the component props instead.
723
+ */
724
+ update: (options: Partial<CardNumberElementProps>) => void;
725
+ }
726
+
727
+ /**
728
+ * Options for the "cardFields" sub handle's `create("cardNumber")`: the consumer props plus event callbacks and lifecycle hooks.
729
+ * @see https://docs.whop.com/elements/latest/payments/overview
730
+ */
731
+ export interface CardNumberElementCreateOptions {
732
+ /**
733
+ * Runs after the loading skeleton first paints and before `onReady`.
734
+ */
735
+ onLoaderStart?: (() => void);
736
+ /**
737
+ * Runs after the element's first complete paint.
738
+ */
739
+ onReady?: (() => void);
740
+ /**
741
+ * Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
742
+ */
743
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
744
+ }
745
+
746
+ /**
747
+ * Consumer props for the "cardFields" sub-controller's "cardExpiry" element.
748
+ * @see https://docs.whop.com/elements/latest/payments/overview
749
+ */
750
+ export interface CardExpiryElementProps {}
751
+
752
+ /**
753
+ * The live handle for a mounted "cardExpiry" element. Returned by the "cardFields" sub handle's `create("cardExpiry")`.
754
+ * @see https://docs.whop.com/elements/latest/payments/overview
755
+ */
756
+ export interface CardExpiryElementHandle {
757
+ /**
758
+ * Mounts the element in `target` and starts loading. React components mount themselves.
759
+ */
760
+ mount: (target: string | HTMLElement) => void;
761
+ /**
762
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
763
+ */
764
+ destroy: () => void;
765
+ /**
766
+ * Merges new props into the mounted element. In React, change the component props instead.
767
+ */
768
+ update: (options: Partial<CardExpiryElementProps>) => void;
769
+ }
770
+
771
+ /**
772
+ * Options for the "cardFields" sub handle's `create("cardExpiry")`: the consumer props plus event callbacks and lifecycle hooks.
773
+ * @see https://docs.whop.com/elements/latest/payments/overview
774
+ */
775
+ export interface CardExpiryElementCreateOptions {
776
+ /**
777
+ * Runs after the loading skeleton first paints and before `onReady`.
778
+ */
779
+ onLoaderStart?: (() => void);
780
+ /**
781
+ * Runs after the element's first complete paint.
782
+ */
783
+ onReady?: (() => void);
784
+ /**
785
+ * Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
786
+ */
787
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
788
+ }
789
+
790
+ /**
791
+ * Consumer props for the "cardFields" sub-controller's "cardCvc" element.
792
+ * @see https://docs.whop.com/elements/latest/payments/overview
793
+ */
794
+ export interface CardCvcElementProps {}
795
+
796
+ /**
797
+ * The live handle for a mounted "cardCvc" element. Returned by the "cardFields" sub handle's `create("cardCvc")`.
798
+ * @see https://docs.whop.com/elements/latest/payments/overview
799
+ */
800
+ export interface CardCvcElementHandle {
801
+ /**
802
+ * Mounts the element in `target` and starts loading. React components mount themselves.
803
+ */
804
+ mount: (target: string | HTMLElement) => void;
805
+ /**
806
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
807
+ */
808
+ destroy: () => void;
809
+ /**
810
+ * Merges new props into the mounted element. In React, change the component props instead.
811
+ */
812
+ update: (options: Partial<CardCvcElementProps>) => void;
813
+ }
814
+
815
+ /**
816
+ * Options for the "cardFields" sub handle's `create("cardCvc")`: the consumer props plus event callbacks and lifecycle hooks.
817
+ * @see https://docs.whop.com/elements/latest/payments/overview
818
+ */
819
+ export interface CardCvcElementCreateOptions {
820
+ /**
821
+ * Runs after the loading skeleton first paints and before `onReady`.
822
+ */
823
+ onLoaderStart?: (() => void);
824
+ /**
825
+ * Runs after the element's first complete paint.
826
+ */
827
+ onReady?: (() => void);
828
+ /**
829
+ * Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
830
+ */
831
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
832
+ }
833
+
834
+ /**
835
+ * The "cardFields" sub-handle, minted by `handle.create("cardFields", …)`. Mounts the sub-controller's elements and carries its actions.
836
+ * Exclusive slot `entry`. Mount exactly one of: payment | card | cardFields.
837
+ * @see https://docs.whop.com/elements/latest/payments/overview
838
+ */
839
+ export interface CardFieldsSubHandle {
840
+ /**
841
+ * PCI-isolated hosted card number field. Card numbers never reach the host page.
842
+ */
843
+ create(name: "cardNumber", options?: CardNumberElementCreateOptions): CardNumberElementHandle;
844
+ /**
845
+ * PCI-isolated hosted card expiration field.
846
+ */
847
+ create(name: "cardExpiry", options?: CardExpiryElementCreateOptions): CardExpiryElementHandle;
848
+ /**
849
+ * PCI-isolated hosted card security code field.
850
+ */
851
+ create(name: "cardCvc", options?: CardCvcElementCreateOptions): CardCvcElementHandle;
852
+ /**
853
+ * Advanced method that tokenizes the three fields without creating a confirmation token. It emits `tokenized` to the payments controller. Validation errors appear on the failing field, and the method throws. Use `payments.createConfirmationToken()` to confirm a payment.
854
+ */
855
+ tokenize: (input: { accountId?: string | undefined; }) => Promise<{ token: string; }>;
856
+ /**
857
+ * `payments.createConfirmationToken()` calls this action for `cardFields`. Don't call it directly. It tokenizes the fields and returns the data used to create the confirmation token.
858
+ */
859
+ collect: (input: { billingDetails?: { email?: string | undefined; name?: string | undefined; address?: { country?: string | undefined; line1?: string | undefined; city?: string | undefined; postal_code?: string | undefined; } | undefined; } | undefined; }) => Promise<{ paymentMethod: { type: string; category: string; card: { token: string; }; }; billingDetails: { email: string; name?: string | undefined; address?: { country?: string | undefined; line1?: string | undefined; city?: string | undefined; postal_code?: string | undefined; } | undefined; }; }>;
860
+ /**
861
+ * Merges new props and callbacks into the sub-controller.
862
+ */
863
+ update(options: Partial<CardFieldsSubOptions>): void;
864
+ /**
865
+ * Destroys the sub-controller and its elements, then frees its exclusive slot. A later `create("cardFields")` starts fresh.
866
+ */
867
+ destroy(): void;
868
+ }
869
+
870
+ /**
871
+ * Options for `whop.payments.paymentRequest.create()` — the "paymentRequest" resource's create options.
872
+ * @see https://docs.whop.com/elements/latest/payments/paymentRequest
873
+ */
874
+ export interface PaymentRequestResourceOptions {
875
+ /**
876
+ * Account ID, prefixed `biz_`, that scopes every client-side call.
877
+ */
878
+ accountId: string;
879
+ /**
880
+ * Three-letter ISO 4217 payment currency code.
881
+ */
882
+ currency: string;
883
+ /**
884
+ * Payment amount in minor units.
885
+ */
886
+ amount: number;
887
+ /**
888
+ * Set only after displaying save consent. Marks the token for `off_session` or `on_session` use.
889
+ */
890
+ setupFutureUsage?: "off_session" | "on_session";
891
+ /**
892
+ * Ask the sheet for the payer's email — the confirmation token requires one.
893
+ * @default true
894
+ */
895
+ requestPayerEmail?: boolean;
896
+ /**
897
+ * Ask the sheet for a shipping address (and offer `shippingOptions` when given).
898
+ * @default false
899
+ */
900
+ requestShipping?: boolean;
901
+ /**
902
+ * Account ISO 3166-1 alpha-2 country code for the Apple Pay sheet. Omit it to use the account's published registration country. The sheet defaults to `US` when neither is available.
903
+ */
904
+ countryCode?: string;
905
+ /**
906
+ * Line items the sheet lists under the total.
907
+ */
908
+ lineItems?: PaymentRequestLineItem[];
909
+ /**
910
+ * Shipping options the sheet offers when `requestShipping` is set. Display-only — update `amount` from your change handler.
911
+ */
912
+ shippingOptions?: PaymentRequestShippingOption[];
913
+ }
914
+
915
+ /**
916
+ * A minted "paymentRequest" resource — returned by `whop.payments.paymentRequest.create()`. Low-level Apple Pay or Google Pay sheet for custom buttons, express checkout, and shipping callbacks. Wallet tiles automate this flow through `payments.createConfirmationToken`. Await `canMakePayment()` to check availability and prime the sheet, then call `show(type)` synchronously in the user-interaction handler. The resolved `ctok` is a `ctok_`-prefixed confirmation token. Confirm it server-side like an element-minted token.
917
+ * @see https://docs.whop.com/elements/latest/payments/paymentRequest
918
+ */
919
+ export interface PaymentRequestResource {
920
+ /**
921
+ * Returns availability for each wallet when the account offers it and the device supports it. Google Pay also requires origin approval. This primes `show()`. Always await it first.
922
+ */
923
+ canMakePayment: () => Promise<WalletAvailability>;
924
+ /**
925
+ * Open the selected wallet sheet after awaiting `canMakePayment()`. Apple requires session creation within the gesture stack. If `requestPayerEmail` is `false`, pass `email` from your form. Otherwise, the sheet refuses to open because confirmation tokens require an email.
926
+ * Call synchronously during user activation. Await prerequisites first because browsers revoke activation across asynchronous steps.
927
+ */
928
+ show: (type: "apple_pay" | "google_pay", provided?: { email?: string | undefined; } | undefined) => Promise<PaymentRequestResult>;
929
+ /**
930
+ * The sheet's shipping address changed (redacted pre-authorization: city/state/postal/country only).
931
+ * Call `updateWith(…)` exactly once per event or the flow waits until the vendor times out.
932
+ * Returns the unsubscribe function.
933
+ */
934
+ onShippingAddressChange(handler: (ev: ShippingAddressChangeEvent) => void): () => void;
935
+ /**
936
+ * The buyer picked a shipping option. Amount-only contract: `updateWith` carries amount/lineItems/shippingOptions/errors.
937
+ * Call `updateWith(…)` exactly once per event or the flow waits until the vendor times out.
938
+ * Returns the unsubscribe function.
939
+ */
940
+ onShippingOptionChange(handler: (ev: ShippingOptionChangeEvent) => void): () => void;
941
+ /**
942
+ * Fires at sheet open and on card switches with the selected card's redacted billing address (city/state/postal/country only) — reprice the total for the address the charge taxes off. Answer `updateWith({ amount })` in minor units, or `updateWith({})` to keep the current total. Every event is answered exactly once: a slow, thrown, or superseded handler answers keep-current.
943
+ * Call `updateWith(…)` exactly once per event or the flow waits until the vendor times out.
944
+ * Returns the unsubscribe function.
945
+ */
946
+ onBillingAddressChange(handler: (ev: BillingAddressChangeEvent) => void): () => void;
947
+ /**
948
+ * The sheet created a confirmation token. This is the same result that `show()` returns.
949
+ * Returns the unsubscribe function.
950
+ */
951
+ onConfirmationToken(handler: (ev: PaymentRequestResult) => void): () => void;
952
+ /**
953
+ * The buyer dismissed the sheet.
954
+ * Returns the unsubscribe function.
955
+ */
956
+ onCancel(handler: () => void): () => void;
957
+ }
958
+
959
+ /**
960
+ * The Payments handle, returned by `whop.payments.create()` (React: `usePayments()`). Mounts the elements and carries the controller's actions.
961
+ * @see https://docs.whop.com/elements/latest/payments/overview
962
+ */
963
+ export interface PaymentsHandle {
964
+ /**
965
+ * Shows available payment methods and collects the selected method's required fields and disclosures. Use `change` to enable your pay button. In its activation handler, call `payments.createConfirmationToken()`. Confirm the token server-side, then pass any pending step to `payments.handleNextAction(…)`. Use `addressChange` for address-dependent updates.
966
+ * Exclusive slot `entry`. Mount exactly one of: payment | card | cardFields.
967
+ */
968
+ create(name: "payment", options?: PaymentElementCreateOptions): PaymentElementHandle;
969
+ /**
970
+ * Collects a billing or shipping address. Fields, order, and validation follow the selected country. Includes street autocomplete and methods to read or validate the address.
971
+ */
972
+ create(name: "address", options?: AddressElementCreateOptions): AddressElementHandle;
973
+ /**
974
+ * Prearranged fields for card number, expiration, and security code. Create with `payments.create("card")`, enable your payment button from `onChange`, and confirm with `payments.createConfirmationToken()`. Card numbers remain in PCI-isolated hosted fields. `layout` supports `stacked` (default) and `compact`.
975
+ * Exclusive slot `entry`. Mount exactly one of: payment | card | cardFields.
976
+ */
977
+ create(name: "card", options?: CardElementCreateOptions): CardElementHandle;
978
+ /**
979
+ * Collects the buyer's email and passes it to `payments.createConfirmationToken()` while mounted. Explicit `billingDetails.email` wins. A matching Whop account shows optional sign-in with code verification. Successful sign-in unlocks saved payment methods in the payment element. Buyers can continue as guests.
980
+ */
981
+ create(name: "email", options?: EmailElementCreateOptions): EmailElementHandle;
982
+ /**
983
+ * Collects a business tax registration accepted by the API. Labels use buyer-facing names. The placeholder matches the selected format. `country` preselects a type. `onChange` emits committed pairs. The host supplies API validation errors.
984
+ */
985
+ create(name: "taxId", options?: TaxIdElementCreateOptions): TaxIdElementHandle;
986
+ /**
987
+ * Creates a confirmation token for the selected method from your pay button. Pass the checkout's billing details. They must include `email`. Cards also need `name` and an address containing `line1` and `country`. Wallet selections open their sheet during the pay-button interaction. Confirm the returned `confirmationToken` server-side, then call `WhopElements.payments.handleNextAction(…)`.
988
+ * Runs on your page (host-side), not in the controller iframe.
989
+ */
990
+ createConfirmationToken: (input: { billingDetails?: { email?: string | undefined; name?: string | undefined; address?: { country?: string | undefined; line1?: string | undefined; line2?: string | undefined; city?: string | undefined; state?: string | undefined; postal_code?: string | undefined; } | undefined; } | undefined; }) => Promise<{ confirmationToken: string; type: string; }>;
991
+ /**
992
+ * Three separately mountable, PCI-isolated card fields for custom layouts: number, expiration, and security code. Create with `payments.create("cardFields")`, place each field, enable your payment button from `onChange`, and confirm with `payments.createConfirmationToken()`. Card numbers remain in hosted fields.
993
+ * Exclusive slot `entry`. Mount exactly one of: payment | card | cardFields.
994
+ */
995
+ create(name: "cardFields", options?: CardFieldsSubOptions): CardFieldsSubHandle;
996
+ /**
997
+ * Merges new handle options into every mounted element. In React, change the namespace props instead.
998
+ */
999
+ update(options: Partial<PaymentsOptions>): void;
1000
+ }
1001
+
1002
+ /**
1003
+ * Payments's static actions, callable with nothing mounted: `whop.payments.<method>()` (React: `useWhop().payments.<method>()`).
1004
+ * @see https://docs.whop.com/elements/latest/payments/overview
1005
+ */
1006
+ export interface PaymentsStatics {
1007
+ /**
1008
+ * Completes a confirmed payment's pending step without mounting an element. `clientSecret` identifies the payment. You don't need a payment ID. Inline steps open in a dialog and resolve with `redirected: false`. Dismissing the dialog returns the payment's current status, which can remain pending. Full-page steps redirect with `redirected: true` to `return_url`, or a hosted receipt when the payment has no return URL. They reject with code `FULL_PAGE_STEP_IN_FRAME` inside subordinate frames. Set `returnUrl` to update the destination before presentation. An update failure rejects before any step runs. Inline steps never navigate to that URL. A payment with no pending step resolves immediately.
1009
+ */
1010
+ handleNextAction: (input: { clientSecret: string; returnUrl?: string | undefined; pollIntervalMs?: number | undefined; }) => Promise<{ status: string; redirected: boolean; lastPaymentError: { code?: string | null | undefined; decline_code?: string | null | undefined; message?: string | null | undefined; } | null; }>;
1011
+ /**
1012
+ * Low-level Apple Pay or Google Pay sheet for custom buttons, express checkout, and shipping callbacks. Wallet tiles automate this flow through `payments.createConfirmationToken`. Await `canMakePayment()` to check availability and prime the sheet, then call `show(type)` synchronously in the user-interaction handler. The resolved `ctok` is a `ctok_`-prefixed confirmation token. Confirm it server-side like an element-minted token.
1013
+ * Mint with `whop.payments.paymentRequest.create(options)` — nothing needs to be mounted.
1014
+ */
1015
+ paymentRequest: { create(options: PaymentRequestResourceOptions): PaymentRequestResource };
1016
+ }
1017
+
1018
+ /**
1019
+ * Host-probed wallet availability after checking offered methods, device capability, and Google Pay origin approval.
1020
+ * Declared from the app's `WalletAvailability`, referenced by a host-capability surface.
1021
+ */
1022
+ export interface WalletAvailability {
1023
+ applePay: boolean;
1024
+ googlePay: boolean;
1025
+ }
1026
+
1027
+ /**
1028
+ * The slice of a matrix card network the fields need: identity plus the API-served square art.
1029
+ * Declared from the app's `CardNetworkArt`, referenced by a host-capability surface.
1030
+ */
1031
+ export interface CardNetworkArt {
1032
+ brand: "visa" | "mastercard" | "amex" | "discover" | "jcb" | "diners" | "unionpay" | "elo" | "maestro";
1033
+ icons: { square: { light: { svg: string; }; dark: { svg: string; }; }; };
1034
+ }
1035
+
1036
+ /**
1037
+ * Declared from the app's `PaymentRequestLineItem`, referenced by a host-capability surface.
1038
+ */
1039
+ export interface PaymentRequestLineItem {
1040
+ label: string;
1041
+ /**
1042
+ * Minor units, same as `amount`.
1043
+ */
1044
+ amount: number;
1045
+ }
1046
+
1047
+ /**
1048
+ * Declared from the app's `PaymentRequestShippingOption`, referenced by a host-capability surface.
1049
+ */
1050
+ export interface PaymentRequestShippingOption {
1051
+ id: string;
1052
+ label: string;
1053
+ detail?: string | undefined;
1054
+ /**
1055
+ * Minor-unit display value. The resource doesn't calculate shipping. Update `amount` from your handler.
1056
+ */
1057
+ amount: number;
1058
+ }
1059
+
1060
+ /**
1061
+ * Declared from the app's `PaymentRequestAddress`, referenced by a host-capability surface.
1062
+ */
1063
+ export interface PaymentRequestAddress {
1064
+ line1?: string | undefined;
1065
+ line2?: string | undefined;
1066
+ city?: string | undefined;
1067
+ state?: string | undefined;
1068
+ postal_code?: string | undefined;
1069
+ country?: string | undefined;
1070
+ recipient?: string | undefined;
1071
+ phone?: string | undefined;
1072
+ }
1073
+
1074
+ /**
1075
+ * Declared from the app's `PaymentRequestResult`, referenced by a host-capability surface.
1076
+ */
1077
+ export interface PaymentRequestResult {
1078
+ /**
1079
+ * Confirmation token ID, prefixed `ctok_`. Confirm it server-side with your secret key.
1080
+ */
1081
+ ctok: string;
1082
+ type: "apple_pay" | "google_pay";
1083
+ payer: { email?: string | undefined; name?: string | undefined; phone?: string | undefined; };
1084
+ shipping: { address?: PaymentRequestAddress | undefined; option?: PaymentRequestShippingOption | undefined; } | null;
1085
+ }
1086
+
1087
+ /**
1088
+ * Declared from the app's `PaymentRequestError`, referenced by a host-capability surface.
1089
+ */
1090
+ export interface PaymentRequestError {
1091
+ code?: "shipping_address_invalid" | "shipping_address_unserviceable" | "shipping_option_invalid" | "other" | undefined;
1092
+ message: string;
1093
+ }
1094
+
1095
+ /**
1096
+ * Declared from the app's `PaymentRequestUpdate`, referenced by a host-capability surface.
1097
+ */
1098
+ export interface PaymentRequestUpdate {
1099
+ amount?: number | undefined;
1100
+ lineItems?: PaymentRequestLineItem[] | undefined;
1101
+ shippingOptions?: PaymentRequestShippingOption[] | undefined;
1102
+ errors?: PaymentRequestError[] | undefined;
1103
+ }
1104
+
1105
+ /**
1106
+ * Declared from the app's `ShippingAddressChangeEvent`, referenced by a host-capability surface.
1107
+ */
1108
+ export interface ShippingAddressChangeEvent {
1109
+ /**
1110
+ * Vendor-normalized pre-authorization address. It includes only city, state, postal code, and country.
1111
+ */
1112
+ address: PaymentRequestAddress;
1113
+ /**
1114
+ * Call this exactly once, or the sheet stalls until the vendor times it out.
1115
+ */
1116
+ updateWith: (update: PaymentRequestUpdate) => void;
1117
+ }
1118
+
1119
+ /**
1120
+ * Declared from the app's `ShippingOptionChangeEvent`, referenced by a host-capability surface.
1121
+ */
1122
+ export interface ShippingOptionChangeEvent {
1123
+ /**
1124
+ * Always includes the selected `id`. It includes the full option when it matches one of yours.
1125
+ */
1126
+ option: { id: string; } & Partial<PaymentRequestShippingOption>;
1127
+ updateWith: (update: PaymentRequestUpdate) => void;
1128
+ }
1129
+
1130
+ /**
1131
+ * Declared from the app's `BillingAddressChangeEvent`, referenced by a host-capability surface.
1132
+ */
1133
+ export interface BillingAddressChangeEvent {
1134
+ /**
1135
+ * Vendor-normalized pre-authorization billing address. It includes only city, state, postal code, and country.
1136
+ */
1137
+ address: PaymentRequestAddress;
1138
+ /**
1139
+ * Call this exactly once. An event left unanswered keeps the current total when the reply deadline passes.
1140
+ */
1141
+ updateWith: (update: PaymentRequestUpdate) => void;
1142
+ }