@whop/elements 0.0.0 → 1.0.0-beta.1

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,1211 @@
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
+ * Set `false` to turn off Whop's built-in usage analytics for this handle and its elements. The analytics identity is never threaded to its frames. A reserved option, not element data.
48
+ */
49
+ analytics?: false;
50
+ }
51
+ | {
52
+ /**
53
+ * Account ID, prefixed `biz_`. Omit only when calling static methods without a collection surface.
54
+ */
55
+ accountId: string;
56
+ /**
57
+ * Lowercase three-letter ISO 4217 payment currency code. It filters the payment-method matrix.
58
+ */
59
+ currency: string;
60
+ /**
61
+ * Payment amount in minor units. Methods whose bounds exclude it aren't offered.
62
+ */
63
+ amount: number;
64
+ /**
65
+ * 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.
66
+ */
67
+ offerAmounts?: { feeInclusive: number; feeFree: number; };
68
+ /**
69
+ * 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.
70
+ */
71
+ paymentMethodConfiguration?: { enabled?: string[] | undefined; disabled?: string[] | undefined; include_platform_defaults?: boolean | undefined; };
72
+ /**
73
+ * Return URL for off-site bank or 3DS steps. Defaults to the mounting page.
74
+ */
75
+ returnUrl?: string;
76
+ /**
77
+ * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
78
+ */
79
+ setupFutureUsage?: "off_session" | "on_session";
80
+ /**
81
+ * Wallet availability override for deterministic previews. Live checkouts probe the host.
82
+ */
83
+ previewWalletAvailability?: WalletAvailability;
84
+ /**
85
+ * 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.
86
+ */
87
+ checkoutSession?: { id: string; clientSecret: string; };
88
+ /**
89
+ * Runs when the grouped loading state changes. The value is `true` while any mounted element is still loading.
90
+ */
91
+ onLoadingChange?: ((loading: boolean) => void);
92
+ /**
93
+ * Set `false` to turn off Whop's built-in usage analytics for this handle and its elements. The analytics identity is never threaded to its frames. A reserved option, not element data.
94
+ */
95
+ analytics?: false;
96
+ }
97
+ | {
98
+ /**
99
+ * Account ID, prefixed `biz_`. Omit only when calling static methods without a collection surface.
100
+ */
101
+ accountId?: undefined;
102
+ /**
103
+ * Plan ID, prefixed `plan_`. It resolves client-side to currency, amount, and method configuration. Pass a plan or inline currency and amount, never both.
104
+ */
105
+ plan?: undefined;
106
+ /**
107
+ * Lowercase three-letter ISO 4217 payment currency code. It filters the payment-method matrix.
108
+ */
109
+ currency?: undefined;
110
+ /**
111
+ * Payment amount in minor units. Methods whose bounds exclude it aren't offered.
112
+ */
113
+ amount?: undefined;
114
+ /**
115
+ * 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.
116
+ */
117
+ offerAmounts?: undefined;
118
+ /**
119
+ * 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.
120
+ */
121
+ paymentMethodConfiguration?: undefined;
122
+ /**
123
+ * Return URL for off-site bank or 3DS steps. Defaults to the mounting page.
124
+ */
125
+ returnUrl?: string;
126
+ /**
127
+ * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
128
+ */
129
+ setupFutureUsage?: "off_session" | "on_session";
130
+ /**
131
+ * Wallet availability override for deterministic previews. Live checkouts probe the host.
132
+ */
133
+ previewWalletAvailability?: WalletAvailability;
134
+ /**
135
+ * 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.
136
+ */
137
+ checkoutSession?: { id: string; clientSecret: string; };
138
+ /**
139
+ * Runs when the grouped loading state changes. The value is `true` while any mounted element is still loading.
140
+ */
141
+ onLoadingChange?: ((loading: boolean) => void);
142
+ /**
143
+ * Set `false` to turn off Whop's built-in usage analytics for this handle and its elements. The analytics identity is never threaded to its frames. A reserved option, not element data.
144
+ */
145
+ analytics?: false;
146
+ }
147
+ ) & {
148
+ /**
149
+ * Visual customization for this group's elements. Overrides the global `WhopElements({ appearance })`. Change it live with `update({ appearance })`.
150
+ */
151
+ appearance?: import("./_framework.js").Appearance;
152
+ /**
153
+ * 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.
154
+ */
155
+ locale?: import("./_framework.js").WhopElementsLocale;
156
+ };
157
+
158
+ /**
159
+ * Consumer props for the "payment" element. Set at create (or as `<PaymentElement />` JSX props), and updatable live via `update()`.
160
+ * @see https://docs.whop.com/elements/latest/payments/payment
161
+ */
162
+ export interface PaymentElementProps {
163
+ /**
164
+ * Controls display order in either layout. Listed types appear first in order. Unlisted types retain their relative order. Does not affect availability.
165
+ * @default []
166
+ */
167
+ order?: string[];
168
+ /**
169
+ * 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.
170
+ * @default {"billingDetails":"minimal"}
171
+ */
172
+ fields?: { billingDetails?: "full" | "minimal" | "never" | undefined; };
173
+ /**
174
+ * 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.
175
+ * @default "accordion"
176
+ */
177
+ layout?: "accordion" | "horizontal";
178
+ /**
179
+ * `accordion` only. Adds spacing and separate card styling between methods. Ignored when `layout` is `horizontal`.
180
+ * @default false
181
+ */
182
+ separated?: boolean;
183
+ /**
184
+ * 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.
185
+ * @default true
186
+ */
187
+ autoSelect?: boolean;
188
+ }
189
+
190
+ /**
191
+ * The live handle for a mounted "payment" element. Returned by `create("payment")`; in React, the component's `ref`.
192
+ * @see https://docs.whop.com/elements/latest/payments/payment
193
+ */
194
+ export interface PaymentElementHandle {
195
+ /**
196
+ * 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.
197
+ */
198
+ select: (input: string | null) => Promise<void>;
199
+ /**
200
+ * Mounts the element in `target` and starts loading. React components mount themselves.
201
+ */
202
+ mount: (target: string | HTMLElement) => void;
203
+ /**
204
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
205
+ */
206
+ destroy: () => void;
207
+ /**
208
+ * Merges new props into the mounted element. In React, change the component props instead.
209
+ */
210
+ update: (options: Partial<PaymentElementProps>) => void;
211
+ }
212
+
213
+ /**
214
+ * Options for `create("payment")`: the consumer props plus event callbacks and lifecycle hooks.
215
+ * @example
216
+ * ```ts
217
+ * const payment = payments.create("payment", {}); // this interface: props + on<Event> callbacks
218
+ * payment.mount("#payments-payment");
219
+ * ```
220
+ * @see https://docs.whop.com/elements/latest/payments/payment
221
+ */
222
+ export interface PaymentElementCreateOptions {
223
+ /**
224
+ * Controls display order in either layout. Listed types appear first in order. Unlisted types retain their relative order. Does not affect availability.
225
+ * @default []
226
+ */
227
+ order?: string[];
228
+ /**
229
+ * 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.
230
+ * @default {"billingDetails":"minimal"}
231
+ */
232
+ fields?: { billingDetails?: "full" | "minimal" | "never" | undefined; };
233
+ /**
234
+ * 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.
235
+ * @default "accordion"
236
+ */
237
+ layout?: "accordion" | "horizontal";
238
+ /**
239
+ * `accordion` only. Adds spacing and separate card styling between methods. Ignored when `layout` is `horizontal`.
240
+ * @default false
241
+ */
242
+ separated?: boolean;
243
+ /**
244
+ * 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.
245
+ * @default true
246
+ */
247
+ autoSelect?: boolean;
248
+ /**
249
+ * 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.
250
+ */
251
+ 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);
252
+ /**
253
+ * 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.
254
+ */
255
+ onAddressChange?: ((payload: { complete: boolean; address: { line1?: string | undefined; line2?: string | undefined; city?: string | undefined; state?: string | undefined; postal_code?: string | undefined; country: string; }; }) => void);
256
+ /**
257
+ * Runs after the loading skeleton first paints and before `onReady`.
258
+ */
259
+ onLoaderStart?: (() => void);
260
+ /**
261
+ * Runs after the element's first complete paint.
262
+ */
263
+ onReady?: (() => void);
264
+ /**
265
+ * 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.
266
+ */
267
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
268
+ }
269
+
270
+ /**
271
+ * Consumer props for the "address" element. Set at create (or as `<AddressElement />` JSX props), and updatable live via `update()`.
272
+ * @see https://docs.whop.com/elements/latest/payments/address
273
+ */
274
+ export interface AddressElementProps {
275
+ /**
276
+ * `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
277
+ * @default "full"
278
+ */
279
+ layout?: "full" | "compact";
280
+ /**
281
+ * Address line 2: always visible (default), revealed by a text button (`toggle`), or never collected.
282
+ * @default "always"
283
+ */
284
+ line2?: "never" | "toggle" | "always";
285
+ /**
286
+ * The name row: one full-name field (default), split first/last fields, or none.
287
+ * @default "combined"
288
+ */
289
+ name?: "split" | "combined" | "none";
290
+ /**
291
+ * Browser autocomplete purpose: `billing` (default) or `shipping`.
292
+ * @default "billing"
293
+ */
294
+ mode?: "billing" | "shipping";
295
+ /**
296
+ * `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`.
297
+ * @default "full"
298
+ */
299
+ scope?: "full" | "minimal";
300
+ /**
301
+ * Organization fields: none (default), name only, or name with a business/individual selector.
302
+ * @default "none"
303
+ */
304
+ organization?: "name" | "none" | "name_with_type";
305
+ /**
306
+ * Seed values applied once before first paint (`address.country` is an ISO 3166-1 alpha-2 country code). Takes precedence over IP-country detection.
307
+ */
308
+ 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; };
309
+ /**
310
+ * Default the country from the buyer's IP (resolved before first paint). Falls back to the controller's `countryHint`, then US.
311
+ * @default true
312
+ */
313
+ detectCountry?: boolean;
314
+ /**
315
+ * Allowed ISO 3166-1 alpha-2 country codes. With one code, the selector remains visible but offers only that country.
316
+ */
317
+ allowedCountries?: string[];
318
+ /**
319
+ * 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.
320
+ * @default true
321
+ */
322
+ autocomplete?: boolean;
323
+ /**
324
+ * Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
325
+ */
326
+ 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; })[];
327
+ /**
328
+ * Fallback country after `defaultValues` and IP detection. Use an ISO 3166-1 alpha-2 code. An empty value falls back to `US`.
329
+ * @default ""
330
+ */
331
+ countryHint?: string;
332
+ }
333
+
334
+ /**
335
+ * The live handle for a mounted "address" element. Returned by `create("address")`; in React, the component's `ref`.
336
+ * @see https://docs.whop.com/elements/latest/payments/address
337
+ */
338
+ export interface AddressElementHandle {
339
+ /**
340
+ * 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.
341
+ */
342
+ 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>; }>;
343
+ /**
344
+ * Returns `address` and `custom` without validation or revealing errors.
345
+ */
346
+ 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>; }>;
347
+ /**
348
+ * Mounts the element in `target` and starts loading. React components mount themselves.
349
+ */
350
+ mount: (target: string | HTMLElement) => void;
351
+ /**
352
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
353
+ */
354
+ destroy: () => void;
355
+ /**
356
+ * Merges new props into the mounted element. In React, change the component props instead.
357
+ */
358
+ update: (options: Partial<AddressElementProps>) => void;
359
+ }
360
+
361
+ /**
362
+ * Options for `create("address")`: the consumer props plus event callbacks and lifecycle hooks.
363
+ * @example
364
+ * ```ts
365
+ * const address = payments.create("address", {}); // this interface: props + on<Event> callbacks
366
+ * address.mount("#payments-address");
367
+ * ```
368
+ * @see https://docs.whop.com/elements/latest/payments/address
369
+ */
370
+ export interface AddressElementCreateOptions {
371
+ /**
372
+ * `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
373
+ * @default "full"
374
+ */
375
+ layout?: "full" | "compact";
376
+ /**
377
+ * Address line 2: always visible (default), revealed by a text button (`toggle`), or never collected.
378
+ * @default "always"
379
+ */
380
+ line2?: "never" | "toggle" | "always";
381
+ /**
382
+ * The name row: one full-name field (default), split first/last fields, or none.
383
+ * @default "combined"
384
+ */
385
+ name?: "split" | "combined" | "none";
386
+ /**
387
+ * Browser autocomplete purpose: `billing` (default) or `shipping`.
388
+ * @default "billing"
389
+ */
390
+ mode?: "billing" | "shipping";
391
+ /**
392
+ * `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`.
393
+ * @default "full"
394
+ */
395
+ scope?: "full" | "minimal";
396
+ /**
397
+ * Organization fields: none (default), name only, or name with a business/individual selector.
398
+ * @default "none"
399
+ */
400
+ organization?: "name" | "none" | "name_with_type";
401
+ /**
402
+ * Seed values applied once before first paint (`address.country` is an ISO 3166-1 alpha-2 country code). Takes precedence over IP-country detection.
403
+ */
404
+ 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; };
405
+ /**
406
+ * Default the country from the buyer's IP (resolved before first paint). Falls back to the controller's `countryHint`, then US.
407
+ * @default true
408
+ */
409
+ detectCountry?: boolean;
410
+ /**
411
+ * Allowed ISO 3166-1 alpha-2 country codes. With one code, the selector remains visible but offers only that country.
412
+ */
413
+ allowedCountries?: string[];
414
+ /**
415
+ * 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.
416
+ * @default true
417
+ */
418
+ autocomplete?: boolean;
419
+ /**
420
+ * Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
421
+ */
422
+ 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; })[];
423
+ /**
424
+ * Fallback country after `defaultValues` and IP detection. Use an ISO 3166-1 alpha-2 code. An empty value falls back to `US`.
425
+ * @default ""
426
+ */
427
+ countryHint?: string;
428
+ /**
429
+ * 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`.
430
+ */
431
+ 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);
432
+ /**
433
+ * Runs after the loading skeleton first paints and before `onReady`.
434
+ */
435
+ onLoaderStart?: (() => void);
436
+ /**
437
+ * Runs after the element's first complete paint.
438
+ */
439
+ onReady?: (() => void);
440
+ /**
441
+ * 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.
442
+ */
443
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
444
+ }
445
+
446
+ /**
447
+ * Consumer props for the "card" element. Set at create (or as `<CardElement />` JSX props), and updatable live via `update()`.
448
+ * @see https://docs.whop.com/elements/latest/payments/card
449
+ */
450
+ export interface CardElementProps {
451
+ /**
452
+ * `stacked` (default) places the card number above expiration and security code. `compact` places all three in one row.
453
+ * @default "stacked"
454
+ */
455
+ layout?: "compact" | "stacked";
456
+ }
457
+
458
+ /**
459
+ * The live handle for a mounted "card" element. Returned by `create("card")`; in React, the component's `ref`.
460
+ * @see https://docs.whop.com/elements/latest/payments/card
461
+ */
462
+ export interface CardElementHandle {
463
+ /**
464
+ * Mounts the element in `target` and starts loading. React components mount themselves.
465
+ */
466
+ mount: (target: string | HTMLElement) => void;
467
+ /**
468
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
469
+ */
470
+ destroy: () => void;
471
+ /**
472
+ * Merges new props into the mounted element. In React, change the component props instead.
473
+ */
474
+ update: (options: Partial<CardElementProps>) => void;
475
+ }
476
+
477
+ /**
478
+ * Options for `create("card")`: the consumer props plus event callbacks and lifecycle hooks.
479
+ * @example
480
+ * ```ts
481
+ * const card = payments.create("card", {}); // this interface: props + on<Event> callbacks
482
+ * card.mount("#payments-card");
483
+ * ```
484
+ * @see https://docs.whop.com/elements/latest/payments/card
485
+ */
486
+ export interface CardElementCreateOptions {
487
+ /**
488
+ * `stacked` (default) places the card number above expiration and security code. `compact` places all three in one row.
489
+ * @default "stacked"
490
+ */
491
+ layout?: "compact" | "stacked";
492
+ /**
493
+ * 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.
494
+ */
495
+ onChange?: ((payload: { complete: boolean; brand: string; }) => void);
496
+ /**
497
+ * Runs after the loading skeleton first paints and before `onReady`.
498
+ */
499
+ onLoaderStart?: (() => void);
500
+ /**
501
+ * Runs after the element's first complete paint.
502
+ */
503
+ onReady?: (() => void);
504
+ /**
505
+ * 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.
506
+ */
507
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
508
+ }
509
+
510
+ /**
511
+ * Consumer props for the "email" element. Set at create (or as `<EmailElement />` JSX props), and updatable live via `update()`.
512
+ * @see https://docs.whop.com/elements/latest/payments/email
513
+ */
514
+ export interface EmailElementProps {
515
+ /**
516
+ * Shows the localized label. Set `false` when supplying your own. The input retains a localized `aria-label`.
517
+ * @default true
518
+ */
519
+ label?: boolean;
520
+ /**
521
+ * Seed value applied once at mount.
522
+ * @default ""
523
+ */
524
+ defaultValue?: string;
525
+ /**
526
+ * Placeholder text for the email input. Empty (default) renders `you@example.com`.
527
+ * @default ""
528
+ */
529
+ placeholder?: string;
530
+ }
531
+
532
+ /**
533
+ * The live handle for a mounted "email" element. Returned by `create("email")`; in React, the component's `ref`.
534
+ * @see https://docs.whop.com/elements/latest/payments/email
535
+ */
536
+ export interface EmailElementHandle {
537
+ /**
538
+ * Mounts the element in `target` and starts loading. React components mount themselves.
539
+ */
540
+ mount: (target: string | HTMLElement) => void;
541
+ /**
542
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
543
+ */
544
+ destroy: () => void;
545
+ /**
546
+ * Merges new props into the mounted element. In React, change the component props instead.
547
+ */
548
+ update: (options: Partial<EmailElementProps>) => void;
549
+ }
550
+
551
+ /**
552
+ * Options for `create("email")`: the consumer props plus event callbacks and lifecycle hooks.
553
+ * @example
554
+ * ```ts
555
+ * const email = payments.create("email", {}); // this interface: props + on<Event> callbacks
556
+ * email.mount("#payments-email");
557
+ * ```
558
+ * @see https://docs.whop.com/elements/latest/payments/email
559
+ */
560
+ export interface EmailElementCreateOptions {
561
+ /**
562
+ * Shows the localized label. Set `false` when supplying your own. The input retains a localized `aria-label`.
563
+ * @default true
564
+ */
565
+ label?: boolean;
566
+ /**
567
+ * Seed value applied once at mount.
568
+ * @default ""
569
+ */
570
+ defaultValue?: string;
571
+ /**
572
+ * Placeholder text for the email input. Empty (default) renders `you@example.com`.
573
+ * @default ""
574
+ */
575
+ placeholder?: string;
576
+ /**
577
+ * Fires when the email changes. `complete` is true when plausible. Sign-in fires it with the signed-in email, which also feeds `createConfirmationToken()`.
578
+ */
579
+ onChange?: ((payload: { email: string; complete: boolean; }) => void);
580
+ /**
581
+ * Runs after the loading skeleton first paints and before `onReady`.
582
+ */
583
+ onLoaderStart?: (() => void);
584
+ /**
585
+ * Runs after the element's first complete paint.
586
+ */
587
+ onReady?: (() => void);
588
+ /**
589
+ * 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.
590
+ */
591
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
592
+ }
593
+
594
+ /**
595
+ * Consumer props for the "taxId" element. Set at create (or as `<TaxIdElement />` JSX props), and updatable live via `update()`.
596
+ * @see https://docs.whop.com/elements/latest/payments/taxId
597
+ */
598
+ export interface TaxIdElementProps {
599
+ /**
600
+ * Disables both fields while the host saves the last committed registration.
601
+ * @default false
602
+ */
603
+ disabled?: boolean;
604
+ /**
605
+ * 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.
606
+ * @default ""
607
+ */
608
+ country?: string;
609
+ /**
610
+ * Initial `type` and `value` from a resumed session. An unsupported `type` falls back to the country default.
611
+ */
612
+ defaultValue?: { type: string; value: string; };
613
+ /**
614
+ * API validation error shown below the value input. Empty (default) shows nothing.
615
+ * @default ""
616
+ */
617
+ error?: string;
618
+ }
619
+
620
+ /**
621
+ * The live handle for a mounted "taxId" element. Returned by `create("taxId")`; in React, the component's `ref`.
622
+ * @see https://docs.whop.com/elements/latest/payments/taxId
623
+ */
624
+ export interface TaxIdElementHandle {
625
+ /**
626
+ * Mounts the element in `target` and starts loading. React components mount themselves.
627
+ */
628
+ mount: (target: string | HTMLElement) => void;
629
+ /**
630
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
631
+ */
632
+ destroy: () => void;
633
+ /**
634
+ * Merges new props into the mounted element. In React, change the component props instead.
635
+ */
636
+ update: (options: Partial<TaxIdElementProps>) => void;
637
+ }
638
+
639
+ /**
640
+ * Options for `create("taxId")`: the consumer props plus event callbacks and lifecycle hooks.
641
+ * @example
642
+ * ```ts
643
+ * const taxId = payments.create("taxId", {}); // this interface: props + on<Event> callbacks
644
+ * taxId.mount("#payments-taxId");
645
+ * ```
646
+ * @see https://docs.whop.com/elements/latest/payments/taxId
647
+ */
648
+ export interface TaxIdElementCreateOptions {
649
+ /**
650
+ * Disables both fields while the host saves the last committed registration.
651
+ * @default false
652
+ */
653
+ disabled?: boolean;
654
+ /**
655
+ * 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.
656
+ * @default ""
657
+ */
658
+ country?: string;
659
+ /**
660
+ * Initial `type` and `value` from a resumed session. An unsupported `type` falls back to the country default.
661
+ */
662
+ defaultValue?: { type: string; value: string; };
663
+ /**
664
+ * API validation error shown below the value input. Empty (default) shows nothing.
665
+ * @default ""
666
+ */
667
+ error?: string;
668
+ /**
669
+ * 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.
670
+ */
671
+ 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);
672
+ /**
673
+ * Runs after the loading skeleton first paints and before `onReady`.
674
+ */
675
+ onLoaderStart?: (() => void);
676
+ /**
677
+ * Runs after the element's first complete paint.
678
+ */
679
+ onReady?: (() => void);
680
+ /**
681
+ * 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.
682
+ */
683
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
684
+ }
685
+
686
+ /**
687
+ * Consumer props for the "branding" element. Set at create (or as `<BrandingElement />` JSX props), and updatable live via `update()`.
688
+ * @see https://docs.whop.com/elements/latest/payments/branding
689
+ */
690
+ export interface BrandingElementProps {}
691
+
692
+ /**
693
+ * The live handle for a mounted "branding" element. Returned by `create("branding")`; in React, the component's `ref`.
694
+ * @see https://docs.whop.com/elements/latest/payments/branding
695
+ */
696
+ export interface BrandingElementHandle {
697
+ /**
698
+ * Mounts the element in `target` and starts loading. React components mount themselves.
699
+ */
700
+ mount: (target: string | HTMLElement) => void;
701
+ /**
702
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
703
+ */
704
+ destroy: () => void;
705
+ /**
706
+ * Merges new props into the mounted element. In React, change the component props instead.
707
+ */
708
+ update: (options: Partial<BrandingElementProps>) => void;
709
+ }
710
+
711
+ /**
712
+ * Options for `create("branding")`: the consumer props plus event callbacks and lifecycle hooks.
713
+ * @example
714
+ * ```ts
715
+ * const branding = payments.create("branding", {}); // this interface: props + on<Event> callbacks
716
+ * branding.mount("#payments-branding");
717
+ * ```
718
+ * @see https://docs.whop.com/elements/latest/payments/branding
719
+ */
720
+ export interface BrandingElementCreateOptions {
721
+ /**
722
+ * Runs after the loading skeleton first paints and before `onReady`.
723
+ */
724
+ onLoaderStart?: (() => void);
725
+ /**
726
+ * Runs after the element's first complete paint.
727
+ */
728
+ onReady?: (() => void);
729
+ /**
730
+ * 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.
731
+ */
732
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
733
+ }
734
+
735
+ /**
736
+ * 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.
737
+ * @see https://docs.whop.com/elements/latest/payments/overview
738
+ */
739
+ export interface CardFieldsSubOptions {
740
+ /**
741
+ * `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.
742
+ * @default "stacked"
743
+ */
744
+ layout?: "compact" | "stacked";
745
+ /**
746
+ * Advanced Basis Theory publishable key. Omit it to fetch the key automatically.
747
+ */
748
+ publicKey?: string;
749
+ /**
750
+ * 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.
751
+ */
752
+ networks?: CardNetworkArt[];
753
+ /**
754
+ * 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.
755
+ */
756
+ onChange?: ((payload: { complete: boolean; brand: string; }) => void);
757
+ }
758
+
759
+ /**
760
+ * Consumer props for the "cardFields" sub-controller's "cardNumber" element.
761
+ * @see https://docs.whop.com/elements/latest/payments/overview
762
+ */
763
+ export interface CardNumberElementProps {}
764
+
765
+ /**
766
+ * The live handle for a mounted "cardNumber" element. Returned by the "cardFields" sub handle's `create("cardNumber")`.
767
+ * @see https://docs.whop.com/elements/latest/payments/overview
768
+ */
769
+ export interface CardNumberElementHandle {
770
+ /**
771
+ * Mounts the element in `target` and starts loading. React components mount themselves.
772
+ */
773
+ mount: (target: string | HTMLElement) => void;
774
+ /**
775
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
776
+ */
777
+ destroy: () => void;
778
+ /**
779
+ * Merges new props into the mounted element. In React, change the component props instead.
780
+ */
781
+ update: (options: Partial<CardNumberElementProps>) => void;
782
+ }
783
+
784
+ /**
785
+ * Options for the "cardFields" sub handle's `create("cardNumber")`: the consumer props plus event callbacks and lifecycle hooks.
786
+ * @see https://docs.whop.com/elements/latest/payments/overview
787
+ */
788
+ export interface CardNumberElementCreateOptions {
789
+ /**
790
+ * Runs after the loading skeleton first paints and before `onReady`.
791
+ */
792
+ onLoaderStart?: (() => void);
793
+ /**
794
+ * Runs after the element's first complete paint.
795
+ */
796
+ onReady?: (() => void);
797
+ /**
798
+ * 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.
799
+ */
800
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
801
+ }
802
+
803
+ /**
804
+ * Consumer props for the "cardFields" sub-controller's "cardExpiry" element.
805
+ * @see https://docs.whop.com/elements/latest/payments/overview
806
+ */
807
+ export interface CardExpiryElementProps {}
808
+
809
+ /**
810
+ * The live handle for a mounted "cardExpiry" element. Returned by the "cardFields" sub handle's `create("cardExpiry")`.
811
+ * @see https://docs.whop.com/elements/latest/payments/overview
812
+ */
813
+ export interface CardExpiryElementHandle {
814
+ /**
815
+ * Mounts the element in `target` and starts loading. React components mount themselves.
816
+ */
817
+ mount: (target: string | HTMLElement) => void;
818
+ /**
819
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
820
+ */
821
+ destroy: () => void;
822
+ /**
823
+ * Merges new props into the mounted element. In React, change the component props instead.
824
+ */
825
+ update: (options: Partial<CardExpiryElementProps>) => void;
826
+ }
827
+
828
+ /**
829
+ * Options for the "cardFields" sub handle's `create("cardExpiry")`: the consumer props plus event callbacks and lifecycle hooks.
830
+ * @see https://docs.whop.com/elements/latest/payments/overview
831
+ */
832
+ export interface CardExpiryElementCreateOptions {
833
+ /**
834
+ * Runs after the loading skeleton first paints and before `onReady`.
835
+ */
836
+ onLoaderStart?: (() => void);
837
+ /**
838
+ * Runs after the element's first complete paint.
839
+ */
840
+ onReady?: (() => void);
841
+ /**
842
+ * 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.
843
+ */
844
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
845
+ }
846
+
847
+ /**
848
+ * Consumer props for the "cardFields" sub-controller's "cardCvc" element.
849
+ * @see https://docs.whop.com/elements/latest/payments/overview
850
+ */
851
+ export interface CardCvcElementProps {}
852
+
853
+ /**
854
+ * The live handle for a mounted "cardCvc" element. Returned by the "cardFields" sub handle's `create("cardCvc")`.
855
+ * @see https://docs.whop.com/elements/latest/payments/overview
856
+ */
857
+ export interface CardCvcElementHandle {
858
+ /**
859
+ * Mounts the element in `target` and starts loading. React components mount themselves.
860
+ */
861
+ mount: (target: string | HTMLElement) => void;
862
+ /**
863
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
864
+ */
865
+ destroy: () => void;
866
+ /**
867
+ * Merges new props into the mounted element. In React, change the component props instead.
868
+ */
869
+ update: (options: Partial<CardCvcElementProps>) => void;
870
+ }
871
+
872
+ /**
873
+ * Options for the "cardFields" sub handle's `create("cardCvc")`: the consumer props plus event callbacks and lifecycle hooks.
874
+ * @see https://docs.whop.com/elements/latest/payments/overview
875
+ */
876
+ export interface CardCvcElementCreateOptions {
877
+ /**
878
+ * Runs after the loading skeleton first paints and before `onReady`.
879
+ */
880
+ onLoaderStart?: (() => void);
881
+ /**
882
+ * Runs after the element's first complete paint.
883
+ */
884
+ onReady?: (() => void);
885
+ /**
886
+ * 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.
887
+ */
888
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
889
+ }
890
+
891
+ /**
892
+ * The "cardFields" sub-handle, minted by `handle.create("cardFields", …)`. Mounts the sub-controller's elements and carries its actions.
893
+ * Exclusive slot `entry`. Mount exactly one of: payment | card | cardFields.
894
+ * @see https://docs.whop.com/elements/latest/payments/overview
895
+ */
896
+ export interface CardFieldsSubHandle {
897
+ /**
898
+ * PCI-isolated hosted card number field. Card numbers never reach the host page.
899
+ */
900
+ create(name: "cardNumber", options?: CardNumberElementCreateOptions): CardNumberElementHandle;
901
+ /**
902
+ * PCI-isolated hosted card expiration field.
903
+ */
904
+ create(name: "cardExpiry", options?: CardExpiryElementCreateOptions): CardExpiryElementHandle;
905
+ /**
906
+ * PCI-isolated hosted card security code field.
907
+ */
908
+ create(name: "cardCvc", options?: CardCvcElementCreateOptions): CardCvcElementHandle;
909
+ /**
910
+ * 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.
911
+ */
912
+ tokenize: (input: { accountId?: string | undefined; }) => Promise<{ token: string; }>;
913
+ /**
914
+ * `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.
915
+ */
916
+ 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; }; }>;
917
+ /**
918
+ * Merges new props and callbacks into the sub-controller.
919
+ */
920
+ update(options: Partial<CardFieldsSubOptions>): void;
921
+ /**
922
+ * Destroys the sub-controller and its elements, then frees its exclusive slot. A later `create("cardFields")` starts fresh.
923
+ */
924
+ destroy(): void;
925
+ }
926
+
927
+ /**
928
+ * Options for `whop.payments.paymentRequest.create()` — the "paymentRequest" resource's create options.
929
+ * @see https://docs.whop.com/elements/latest/payments/paymentRequest
930
+ */
931
+ export interface PaymentRequestResourceOptions {
932
+ /**
933
+ * Account ID, prefixed `biz_`, that scopes every client-side call.
934
+ */
935
+ accountId: string;
936
+ /**
937
+ * Three-letter ISO 4217 payment currency code.
938
+ */
939
+ currency: string;
940
+ /**
941
+ * Payment amount in minor units.
942
+ */
943
+ amount: number;
944
+ /**
945
+ * Set only after displaying save consent. Marks the token for `off_session` or `on_session` use.
946
+ */
947
+ setupFutureUsage?: "off_session" | "on_session";
948
+ /**
949
+ * Ask the sheet for the payer's email — the confirmation token requires one.
950
+ * @default true
951
+ */
952
+ requestPayerEmail?: boolean;
953
+ /**
954
+ * Ask the sheet for a shipping address (and offer `shippingOptions` when given).
955
+ * @default false
956
+ */
957
+ requestShipping?: boolean;
958
+ /**
959
+ * 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.
960
+ */
961
+ countryCode?: string;
962
+ /**
963
+ * Line items the sheet lists under the total.
964
+ */
965
+ lineItems?: PaymentRequestLineItem[];
966
+ /**
967
+ * Shipping options the sheet offers when `requestShipping` is set. Display-only — update `amount` from your change handler.
968
+ */
969
+ shippingOptions?: PaymentRequestShippingOption[];
970
+ }
971
+
972
+ /**
973
+ * 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.
974
+ * @see https://docs.whop.com/elements/latest/payments/paymentRequest
975
+ */
976
+ export interface PaymentRequestResource {
977
+ /**
978
+ * Returns availability for each wallet when the account offers it, the device supports it, and this page's origin is approved for the account (first-party whop.com pages are pre-approved; a merchant page needs its domain registered as a payment method domain). Apple Pay on non-WebKit browsers is the desktop iPhone-handoff flow, so mobile devices there report it unavailable — native Apple Pay on iOS browsers is unaffected. `order` ranks the wallets by which sheet is native to the browser — Apple Pay first on Safari, Google Pay first elsewhere — so express buttons can stack best-first. This primes `show()`. Always await it first.
979
+ */
980
+ canMakePayment: () => Promise<WalletAvailability>;
981
+ /**
982
+ * Open the selected wallet sheet after awaiting `canMakePayment()`. Apple requires session creation within the gesture stack. Pass `email` when your page already collected one — the sheet takes it and never asks for a second. With `requestPayerEmail: false`, passing one is required, and the sheet refuses to open without it because confirmation tokens require an email.
983
+ * Call synchronously during user activation. Await prerequisites first because browsers revoke activation across asynchronous steps.
984
+ */
985
+ show: (type: "apple_pay" | "google_pay", provided?: { email?: string | undefined; } | undefined) => Promise<PaymentRequestResult>;
986
+ /**
987
+ * The sheet's shipping address changed (redacted pre-authorization: city/state/postal/country only).
988
+ * Call `updateWith(…)` exactly once per event or the flow waits until the vendor times out.
989
+ * Returns the unsubscribe function.
990
+ */
991
+ onShippingAddressChange(handler: (ev: ShippingAddressChangeEvent) => void): () => void;
992
+ /**
993
+ * The buyer picked a shipping option. Amount-only contract: `updateWith` carries amount/lineItems/shippingOptions/errors.
994
+ * Call `updateWith(…)` exactly once per event or the flow waits until the vendor times out.
995
+ * Returns the unsubscribe function.
996
+ */
997
+ onShippingOptionChange(handler: (ev: ShippingOptionChangeEvent) => void): () => void;
998
+ /**
999
+ * 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.
1000
+ * Call `updateWith(…)` exactly once per event or the flow waits until the vendor times out.
1001
+ * Returns the unsubscribe function.
1002
+ */
1003
+ onBillingAddressChange(handler: (ev: BillingAddressChangeEvent) => void): () => void;
1004
+ /**
1005
+ * The sheet created a confirmation token. This is the same result that `show()` returns.
1006
+ * Returns the unsubscribe function.
1007
+ */
1008
+ onConfirmationToken(handler: (ev: PaymentRequestResult) => void): () => void;
1009
+ /**
1010
+ * The buyer dismissed the sheet.
1011
+ * Returns the unsubscribe function.
1012
+ */
1013
+ onCancel(handler: () => void): () => void;
1014
+ }
1015
+
1016
+ /**
1017
+ * The Payments handle, returned by `whop.payments.create()` (React: `usePayments()`). Mounts the elements and carries the controller's actions.
1018
+ * @see https://docs.whop.com/elements/latest/payments/overview
1019
+ */
1020
+ export interface PaymentsHandle {
1021
+ /**
1022
+ * 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.
1023
+ * Exclusive slot `entry`. Mount exactly one of: payment | card | cardFields.
1024
+ */
1025
+ create(name: "payment", options?: PaymentElementCreateOptions): PaymentElementHandle;
1026
+ /**
1027
+ * 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.
1028
+ */
1029
+ create(name: "address", options?: AddressElementCreateOptions): AddressElementHandle;
1030
+ /**
1031
+ * 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`.
1032
+ * Exclusive slot `entry`. Mount exactly one of: payment | card | cardFields.
1033
+ */
1034
+ create(name: "card", options?: CardElementCreateOptions): CardElementHandle;
1035
+ /**
1036
+ * 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.
1037
+ */
1038
+ create(name: "email", options?: EmailElementCreateOptions): EmailElementHandle;
1039
+ /**
1040
+ * 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.
1041
+ */
1042
+ create(name: "taxId", options?: TaxIdElementCreateOptions): TaxIdElementHandle;
1043
+ /**
1044
+ * Whop's merchant-of-record notice: the Whop wordmark with links to the buyer terms and privacy policy. Required — the other payments elements stay in their loading state until it is mounted, and payments cannot be confirmed without it.
1045
+ */
1046
+ create(name: "branding", options?: BrandingElementCreateOptions): BrandingElementHandle;
1047
+ /**
1048
+ * 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(…)`.
1049
+ * Runs on your page (host-side), not in the controller iframe.
1050
+ */
1051
+ 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; }>;
1052
+ /**
1053
+ * 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.
1054
+ * Exclusive slot `entry`. Mount exactly one of: payment | card | cardFields.
1055
+ */
1056
+ create(name: "cardFields", options?: CardFieldsSubOptions): CardFieldsSubHandle;
1057
+ /**
1058
+ * Merges new handle options into every mounted element. In React, change the namespace props instead.
1059
+ */
1060
+ update(options: Partial<PaymentsOptions>): void;
1061
+ /**
1062
+ * Destroys every element and sub-controller this handle created, removes the controller frame, and releases its subscriptions. You can call it more than once, but a destroyed handle refuses any other call — create a new handle to start over. React removes the group automatically when the provider unmounts.
1063
+ */
1064
+ destroy(): void;
1065
+ }
1066
+
1067
+ /**
1068
+ * Payments's static actions, callable with nothing mounted: `whop.payments.<method>()` (React: `useWhop().payments.<method>()`).
1069
+ * @see https://docs.whop.com/elements/latest/payments/overview
1070
+ */
1071
+ export interface PaymentsStatics {
1072
+ /**
1073
+ * 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.
1074
+ */
1075
+ 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; }>;
1076
+ /**
1077
+ * 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.
1078
+ * Mint with `whop.payments.paymentRequest.create(options)` — nothing needs to be mounted.
1079
+ */
1080
+ paymentRequest: { create(options: PaymentRequestResourceOptions): PaymentRequestResource };
1081
+ }
1082
+
1083
+ /**
1084
+ * Host-probed wallet availability after checking offered methods, device capability, and Google Pay origin approval.
1085
+ * Declared from the app's `WalletAvailability`, referenced by a host-capability surface.
1086
+ */
1087
+ export interface WalletAvailability {
1088
+ applePay: boolean;
1089
+ googlePay: boolean;
1090
+ /**
1091
+ * The wallets ranked by which sheet is native to this browser — Apple Pay first on WebKit, Google Pay first everywhere else — so express buttons can stack best-first. Absent on consumer-stated availability (previews) and on wires that predate it. An inline union, not payment-request's WalletSheetType: that module already imports this one.
1092
+ */
1093
+ order?: ("apple_pay" | "google_pay")[] | undefined;
1094
+ }
1095
+
1096
+ /**
1097
+ * The slice of a matrix card network the fields need: identity plus the API-served square art.
1098
+ * Declared from the app's `CardNetworkArt`, referenced by a host-capability surface.
1099
+ */
1100
+ export interface CardNetworkArt {
1101
+ brand: "visa" | "mastercard" | "amex" | "discover" | "jcb" | "diners" | "unionpay" | "elo" | "maestro";
1102
+ icons: { square: { light: { svg: string; }; dark: { svg: string; }; }; };
1103
+ }
1104
+
1105
+ /**
1106
+ * Declared from the app's `PaymentRequestLineItem`, referenced by a host-capability surface.
1107
+ */
1108
+ export interface PaymentRequestLineItem {
1109
+ label: string;
1110
+ /**
1111
+ * Minor units, same as `amount`.
1112
+ */
1113
+ amount: number;
1114
+ }
1115
+
1116
+ /**
1117
+ * Declared from the app's `PaymentRequestShippingOption`, referenced by a host-capability surface.
1118
+ */
1119
+ export interface PaymentRequestShippingOption {
1120
+ id: string;
1121
+ label: string;
1122
+ detail?: string | undefined;
1123
+ /**
1124
+ * Minor-unit display value. The resource doesn't calculate shipping. Update `amount` from your handler.
1125
+ */
1126
+ amount: number;
1127
+ }
1128
+
1129
+ /**
1130
+ * Declared from the app's `PaymentRequestAddress`, referenced by a host-capability surface.
1131
+ */
1132
+ export interface PaymentRequestAddress {
1133
+ line1?: string | undefined;
1134
+ line2?: string | undefined;
1135
+ city?: string | undefined;
1136
+ state?: string | undefined;
1137
+ postal_code?: string | undefined;
1138
+ country?: string | undefined;
1139
+ recipient?: string | undefined;
1140
+ phone?: string | undefined;
1141
+ }
1142
+
1143
+ /**
1144
+ * Declared from the app's `PaymentRequestResult`, referenced by a host-capability surface.
1145
+ */
1146
+ export interface PaymentRequestResult {
1147
+ /**
1148
+ * Confirmation token ID, prefixed `ctok_`. Confirm it server-side with your secret key.
1149
+ */
1150
+ ctok: string;
1151
+ type: "apple_pay" | "google_pay";
1152
+ payer: { email?: string | undefined; name?: string | undefined; phone?: string | undefined; };
1153
+ shipping: { address?: PaymentRequestAddress | undefined; option?: PaymentRequestShippingOption | undefined; } | null;
1154
+ }
1155
+
1156
+ /**
1157
+ * Declared from the app's `PaymentRequestError`, referenced by a host-capability surface.
1158
+ */
1159
+ export interface PaymentRequestError {
1160
+ code?: "shipping_address_invalid" | "shipping_address_unserviceable" | "shipping_option_invalid" | "other" | undefined;
1161
+ message: string;
1162
+ }
1163
+
1164
+ /**
1165
+ * Declared from the app's `PaymentRequestUpdate`, referenced by a host-capability surface.
1166
+ */
1167
+ export interface PaymentRequestUpdate {
1168
+ amount?: number | undefined;
1169
+ lineItems?: PaymentRequestLineItem[] | undefined;
1170
+ shippingOptions?: PaymentRequestShippingOption[] | undefined;
1171
+ errors?: PaymentRequestError[] | undefined;
1172
+ }
1173
+
1174
+ /**
1175
+ * Declared from the app's `ShippingAddressChangeEvent`, referenced by a host-capability surface.
1176
+ */
1177
+ export interface ShippingAddressChangeEvent {
1178
+ /**
1179
+ * Vendor-normalized pre-authorization address. It includes only city, state, postal code, and country.
1180
+ */
1181
+ address: PaymentRequestAddress;
1182
+ /**
1183
+ * Call this exactly once, or the sheet stalls until the vendor times it out.
1184
+ */
1185
+ updateWith: (update: PaymentRequestUpdate) => void;
1186
+ }
1187
+
1188
+ /**
1189
+ * Declared from the app's `ShippingOptionChangeEvent`, referenced by a host-capability surface.
1190
+ */
1191
+ export interface ShippingOptionChangeEvent {
1192
+ /**
1193
+ * Always includes the selected `id`. It includes the full option when it matches one of yours.
1194
+ */
1195
+ option: { id: string; } & Partial<PaymentRequestShippingOption>;
1196
+ updateWith: (update: PaymentRequestUpdate) => void;
1197
+ }
1198
+
1199
+ /**
1200
+ * Declared from the app's `BillingAddressChangeEvent`, referenced by a host-capability surface.
1201
+ */
1202
+ export interface BillingAddressChangeEvent {
1203
+ /**
1204
+ * Vendor-normalized pre-authorization billing address. It includes only city, state, postal code, and country.
1205
+ */
1206
+ address: PaymentRequestAddress;
1207
+ /**
1208
+ * Call this exactly once. An event left unanswered keeps the current total when the reply deadline passes.
1209
+ */
1210
+ updateWith: (update: PaymentRequestUpdate) => void;
1211
+ }