@whop/elements 1.0.0-beta.3 → 1.0.0-beta.5

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 CHANGED
@@ -12,9 +12,13 @@
12
12
  export type PaymentsOptions = (
13
13
  | {
14
14
  /**
15
- * Account ID, prefixed `biz_`. Omit only when calling static methods without a collection surface.
15
+ * Account ID, prefixed `biz_`. Omit only when calling static methods without an account surface.
16
16
  */
17
17
  accountId: string;
18
+ /**
19
+ * Mount mode, `payment` by default. `setup` saves a payment method and charges nothing, now or later: only methods that can be saved are offered and amount bounds do not apply. Confirm with `createConfirmationToken()`, then create the setup intent server-side.
20
+ */
21
+ mode?: "payment";
18
22
  /**
19
23
  * 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
24
  */
@@ -28,7 +32,7 @@ export type PaymentsOptions = (
28
32
  */
29
33
  returnUrl?: string;
30
34
  /**
31
- * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
35
+ * A setup saves the payment method for `off_session` use, the only usage a setup accepts.
32
36
  */
33
37
  setupFutureUsage?: "off_session" | "on_session";
34
38
  /**
@@ -50,11 +54,15 @@ export type PaymentsOptions = (
50
54
  }
51
55
  | {
52
56
  /**
53
- * Account ID, prefixed `biz_`. Omit only when calling static methods without a collection surface.
57
+ * Account ID, prefixed `biz_`. Omit only when calling static methods without an account surface.
54
58
  */
55
59
  accountId: string;
56
60
  /**
57
- * Lowercase three-letter ISO 4217 payment currency code. It filters the payment-method matrix.
61
+ * Mount mode, `payment` by default. `setup` saves a payment method and charges nothing, now or later: only methods that can be saved are offered and amount bounds do not apply. Confirm with `createConfirmationToken()`, then create the setup intent server-side.
62
+ */
63
+ mode?: "payment";
64
+ /**
65
+ * Lowercase three-letter ISO 4217 currency code. It filters the payment-method matrix.
58
66
  */
59
67
  currency: string;
60
68
  /**
@@ -74,7 +82,7 @@ export type PaymentsOptions = (
74
82
  */
75
83
  returnUrl?: string;
76
84
  /**
77
- * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
85
+ * A setup saves the payment method for `off_session` use, the only usage a setup accepts.
78
86
  */
79
87
  setupFutureUsage?: "off_session" | "on_session";
80
88
  /**
@@ -96,15 +104,73 @@ export type PaymentsOptions = (
96
104
  }
97
105
  | {
98
106
  /**
99
- * Account ID, prefixed `biz_`. Omit only when calling static methods without a collection surface.
107
+ * Account ID, prefixed `biz_`. Omit only when calling static methods without an account surface.
108
+ */
109
+ accountId: string;
110
+ /**
111
+ * Mount mode, `payment` by default. `setup` saves a payment method and charges nothing, now or later: only methods that can be saved are offered and amount bounds do not apply. Confirm with `createConfirmationToken()`, then create the setup intent server-side.
100
112
  */
101
- accountId?: undefined;
113
+ mode: "setup";
114
+ /**
115
+ * Lowercase three-letter ISO 4217 currency code. It filters the payment-method matrix.
116
+ */
117
+ currency: string;
102
118
  /**
103
119
  * 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
120
  */
105
121
  plan?: undefined;
106
122
  /**
107
- * Lowercase three-letter ISO 4217 payment currency code. It filters the payment-method matrix.
123
+ * Payment amount in minor units. Methods whose bounds exclude it aren't offered.
124
+ */
125
+ amount?: undefined;
126
+ /**
127
+ * 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.
128
+ */
129
+ offerAmounts?: undefined;
130
+ /**
131
+ * 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.
132
+ */
133
+ paymentMethodConfiguration?: { enabled?: string[] | undefined; disabled?: string[] | undefined; include_platform_defaults?: boolean | undefined; };
134
+ /**
135
+ * Return URL for off-site bank or 3DS steps. Defaults to the mounting page.
136
+ */
137
+ returnUrl?: string;
138
+ /**
139
+ * A setup saves the payment method for `off_session` use, the only usage a setup accepts.
140
+ */
141
+ setupFutureUsage?: "off_session";
142
+ /**
143
+ * Wallet availability override for deterministic previews. Live checkouts probe the host.
144
+ */
145
+ previewWalletAvailability?: WalletAvailability;
146
+ /**
147
+ * 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.
148
+ */
149
+ checkoutSession?: { id: string; clientSecret: string; };
150
+ /**
151
+ * Runs when the grouped loading state changes. The value is `true` while any mounted element is still loading.
152
+ */
153
+ onLoadingChange?: ((loading: boolean) => void);
154
+ /**
155
+ * 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.
156
+ */
157
+ analytics?: false;
158
+ }
159
+ | {
160
+ /**
161
+ * Account ID, prefixed `biz_`. Omit only when calling static methods without an account surface.
162
+ */
163
+ accountId?: string;
164
+ /**
165
+ * Mount mode, `payment` by default. `setup` saves a payment method and charges nothing, now or later: only methods that can be saved are offered and amount bounds do not apply. Confirm with `createConfirmationToken()`, then create the setup intent server-side.
166
+ */
167
+ mode?: undefined;
168
+ /**
169
+ * Plan ID, prefixed `plan_`. It resolves client-side to currency, amount, and method configuration. Pass a plan or inline currency and amount, never both.
170
+ */
171
+ plan?: undefined;
172
+ /**
173
+ * Lowercase three-letter ISO 4217 currency code. It filters the payment-method matrix.
108
174
  */
109
175
  currency?: undefined;
110
176
  /**
@@ -124,7 +190,7 @@ export type PaymentsOptions = (
124
190
  */
125
191
  returnUrl?: string;
126
192
  /**
127
- * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
193
+ * A setup saves the payment method for `off_session` use, the only usage a setup accepts.
128
194
  */
129
195
  setupFutureUsage?: "off_session" | "on_session";
130
196
  /**
@@ -166,10 +232,10 @@ export interface PaymentElementProps {
166
232
  */
167
233
  order?: string[];
168
234
  /**
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. With an installment plan selected, it narrows to the countries the plan serves — the billing country is the transaction country the charge processes under. It locks when only one is available.
235
+ * 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. `phone: 'never'` hides only the billing phone input when your form already collects it; pass `billingDetails.phone` to `createConfirmationToken` for methods that require it. Pass the address to `createConfirmationToken` instead. The country selector includes only countries supported by the method and payment currency. With an installment plan selected, it narrows to the countries the plan serves — the billing country is the transaction country the charge processes under. It locks when only one is available.
170
236
  * @default {"billingDetails":"minimal"}
171
237
  */
172
- fields?: { billingDetails?: "full" | "minimal" | "never" | undefined; };
238
+ fields?: { billingDetails?: "full" | "minimal" | "never" | undefined; phone?: "never" | "auto" | undefined; };
173
239
  /**
174
240
  * 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
241
  * @default "accordion"
@@ -226,10 +292,10 @@ export interface PaymentElementCreateOptions {
226
292
  */
227
293
  order?: string[];
228
294
  /**
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. With an installment plan selected, it narrows to the countries the plan serves — the billing country is the transaction country the charge processes under. It locks when only one is available.
295
+ * 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. `phone: 'never'` hides only the billing phone input when your form already collects it; pass `billingDetails.phone` to `createConfirmationToken` for methods that require it. Pass the address to `createConfirmationToken` instead. The country selector includes only countries supported by the method and payment currency. With an installment plan selected, it narrows to the countries the plan serves — the billing country is the transaction country the charge processes under. It locks when only one is available.
230
296
  * @default {"billingDetails":"minimal"}
231
297
  */
232
- fields?: { billingDetails?: "full" | "minimal" | "never" | undefined; };
298
+ fields?: { billingDetails?: "full" | "minimal" | "never" | undefined; phone?: "never" | "auto" | undefined; };
233
299
  /**
234
300
  * 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
301
  * @default "accordion"
@@ -246,9 +312,9 @@ export interface PaymentElementCreateOptions {
246
312
  */
247
313
  autoSelect?: boolean;
248
314
  /**
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.
315
+ * 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. `requiresBillingPhone` indicates whether the selected method requires a phone in billing details, including when `fields.phone` disables its input. `supportsBuyerFee` indicates whether to include Whop's buyer service fee in the displayed total.
250
316
  */
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);
317
+ onChange?: ((payload: { complete: boolean; type?: string | undefined; supportsBuyerFee?: boolean | undefined; requiresBillingPhone?: 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
318
  /**
253
319
  * 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
320
  */
@@ -272,6 +338,11 @@ export interface PaymentElementCreateOptions {
272
338
  * @see https://docs.whop.com/elements/latest/payments/address
273
339
  */
274
340
  export interface AddressElementProps {
341
+ /**
342
+ * Browser autocomplete purpose: `billing` (default) or `shipping`.
343
+ * @default "billing"
344
+ */
345
+ mode?: "billing" | "shipping";
275
346
  /**
276
347
  * `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
277
348
  * @default "full"
@@ -287,11 +358,6 @@ export interface AddressElementProps {
287
358
  * @default "combined"
288
359
  */
289
360
  name?: "split" | "combined" | "none";
290
- /**
291
- * Browser autocomplete purpose: `billing` (default) or `shipping`.
292
- * @default "billing"
293
- */
294
- mode?: "billing" | "shipping";
295
361
  /**
296
362
  * `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
363
  * @default "full"
@@ -323,7 +389,7 @@ export interface AddressElementProps {
323
389
  /**
324
390
  * Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
325
391
  */
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; })[];
392
+ customFields?: ({ key: string; label: string; type: "phone" | "text" | "select" | "date"; position: "after_name" | "after_organization" | "before_country" | "after_address"; required?: boolean | undefined; options?: string[] | undefined; format?: string | undefined; autocomplete?: string | undefined; })[];
327
393
  /**
328
394
  * Fallback country after `defaultValues` and IP detection. Use an ISO 3166-1 alpha-2 code. An empty value falls back to `US`.
329
395
  * @default ""
@@ -368,6 +434,11 @@ export interface AddressElementHandle {
368
434
  * @see https://docs.whop.com/elements/latest/payments/address
369
435
  */
370
436
  export interface AddressElementCreateOptions {
437
+ /**
438
+ * Browser autocomplete purpose: `billing` (default) or `shipping`.
439
+ * @default "billing"
440
+ */
441
+ mode?: "billing" | "shipping";
371
442
  /**
372
443
  * `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
373
444
  * @default "full"
@@ -383,11 +454,6 @@ export interface AddressElementCreateOptions {
383
454
  * @default "combined"
384
455
  */
385
456
  name?: "split" | "combined" | "none";
386
- /**
387
- * Browser autocomplete purpose: `billing` (default) or `shipping`.
388
- * @default "billing"
389
- */
390
- mode?: "billing" | "shipping";
391
457
  /**
392
458
  * `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
459
  * @default "full"
@@ -419,7 +485,7 @@ export interface AddressElementCreateOptions {
419
485
  /**
420
486
  * Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
421
487
  */
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; })[];
488
+ customFields?: ({ key: string; label: string; type: "phone" | "text" | "select" | "date"; position: "after_name" | "after_organization" | "before_country" | "after_address"; required?: boolean | undefined; options?: string[] | undefined; format?: string | undefined; autocomplete?: string | undefined; })[];
423
489
  /**
424
490
  * Fallback country after `defaultValues` and IP detection. Use an ISO 3166-1 alpha-2 code. An empty value falls back to `US`.
425
491
  * @default ""
@@ -950,6 +1016,11 @@ export interface PaymentRequestResourceOptions {
950
1016
  * @default true
951
1017
  */
952
1018
  requestPayerEmail?: boolean;
1019
+ /**
1020
+ * Ask the sheet for the payer's phone number, delivered as `payer.phone` on the result — in E.164 where it parses against the country of the contact that supplied it, as the wallet gave it otherwise; `payer.country` is the billing country. Google Pay collects it through the billing address the sheet already asks for.
1021
+ * @default false
1022
+ */
1023
+ requestPayerPhone?: boolean;
953
1024
  /**
954
1025
  * Ask the sheet for a shipping address (and offer `shippingOptions` when given).
955
1026
  * @default false
@@ -975,7 +1046,7 @@ export interface PaymentRequestResourceOptions {
975
1046
  */
976
1047
  export interface PaymentRequestResource {
977
1048
  /**
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 and verified as a [payment method domain](/api-reference/beta/payment-method-domains/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.
1049
+ * 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 and verified as a [payment method domain](/api-reference/beta/payment-method-domains/payment-method-domain), and offering Google Pay there is subject to the [Google Pay API Terms of Service](https://payments.developers.google.com/terms/sellertos)). 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
1050
  */
980
1051
  canMakePayment: () => Promise<WalletAvailability>;
981
1052
  /**
@@ -1045,10 +1116,10 @@ export interface PaymentsHandle {
1045
1116
  */
1046
1117
  create(name: "branding", options?: BrandingElementCreateOptions): BrandingElementHandle;
1047
1118
  /**
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(…)`.
1119
+ * Creates a confirmation token for the selected method from your pay button. Pass the checkout's billing details. They must include `email`. Supply `phone` for methods that require it when billing collection is disabled. 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
1120
  * Runs on your page (host-side), not in the controller iframe.
1050
1121
  */
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; }>;
1122
+ createConfirmationToken: (input: { billingDetails?: { email?: string | undefined; name?: string | undefined; phone?: 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
1123
  /**
1053
1124
  * 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
1125
  * Exclusive slot `entry`. Mount exactly one of: payment | card | cardFields.
@@ -1070,7 +1141,7 @@ export interface PaymentsHandle {
1070
1141
  */
1071
1142
  export interface PaymentsStatics {
1072
1143
  /**
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. Inside an iframe they navigate the top-level tab. If the embedding page refuses that navigation, they reject with code `TAB_NAVIGATION_BLOCKED`, and the payment stays pending. 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.
1144
+ * 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. Inside an iframe they navigate the top-level tab. If the embedding page refuses that navigation, they reject with code `TAB_NAVIGATION_BLOCKED`, and the payment stays pending. 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 whose charge is still being decided is polled until a step appears or it settles; a decided payment with no step resolves immediately.
1074
1145
  */
1075
1146
  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
1147
  /**
@@ -1149,7 +1220,7 @@ export interface PaymentRequestResult {
1149
1220
  */
1150
1221
  ctok: string;
1151
1222
  type: "apple_pay" | "google_pay";
1152
- payer: { email?: string | undefined; name?: string | undefined; phone?: string | undefined; };
1223
+ payer: { email?: string | undefined; name?: string | undefined; phone?: string | undefined; country?: string | undefined; };
1153
1224
  shipping: { address?: PaymentRequestAddress | undefined; option?: PaymentRequestShippingOption | undefined; } | null;
1154
1225
  }
1155
1226
 
package/payments.d.ts CHANGED
@@ -12,9 +12,13 @@
12
12
  export type PaymentsOptions = (
13
13
  | {
14
14
  /**
15
- * Account ID, prefixed `biz_`. Omit only when calling static methods without a collection surface.
15
+ * Account ID, prefixed `biz_`. Omit only when calling static methods without an account surface.
16
16
  */
17
17
  accountId: string;
18
+ /**
19
+ * Mount mode, `payment` by default. `setup` saves a payment method and charges nothing, now or later: only methods that can be saved are offered and amount bounds do not apply. Confirm with `createConfirmationToken()`, then create the setup intent server-side.
20
+ */
21
+ mode?: "payment";
18
22
  /**
19
23
  * 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
24
  */
@@ -28,7 +32,7 @@ export type PaymentsOptions = (
28
32
  */
29
33
  returnUrl?: string;
30
34
  /**
31
- * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
35
+ * A setup saves the payment method for `off_session` use, the only usage a setup accepts.
32
36
  */
33
37
  setupFutureUsage?: "off_session" | "on_session";
34
38
  /**
@@ -50,11 +54,15 @@ export type PaymentsOptions = (
50
54
  }
51
55
  | {
52
56
  /**
53
- * Account ID, prefixed `biz_`. Omit only when calling static methods without a collection surface.
57
+ * Account ID, prefixed `biz_`. Omit only when calling static methods without an account surface.
54
58
  */
55
59
  accountId: string;
56
60
  /**
57
- * Lowercase three-letter ISO 4217 payment currency code. It filters the payment-method matrix.
61
+ * Mount mode, `payment` by default. `setup` saves a payment method and charges nothing, now or later: only methods that can be saved are offered and amount bounds do not apply. Confirm with `createConfirmationToken()`, then create the setup intent server-side.
62
+ */
63
+ mode?: "payment";
64
+ /**
65
+ * Lowercase three-letter ISO 4217 currency code. It filters the payment-method matrix.
58
66
  */
59
67
  currency: string;
60
68
  /**
@@ -74,7 +82,7 @@ export type PaymentsOptions = (
74
82
  */
75
83
  returnUrl?: string;
76
84
  /**
77
- * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
85
+ * A setup saves the payment method for `off_session` use, the only usage a setup accepts.
78
86
  */
79
87
  setupFutureUsage?: "off_session" | "on_session";
80
88
  /**
@@ -96,15 +104,73 @@ export type PaymentsOptions = (
96
104
  }
97
105
  | {
98
106
  /**
99
- * Account ID, prefixed `biz_`. Omit only when calling static methods without a collection surface.
107
+ * Account ID, prefixed `biz_`. Omit only when calling static methods without an account surface.
108
+ */
109
+ accountId: string;
110
+ /**
111
+ * Mount mode, `payment` by default. `setup` saves a payment method and charges nothing, now or later: only methods that can be saved are offered and amount bounds do not apply. Confirm with `createConfirmationToken()`, then create the setup intent server-side.
100
112
  */
101
- accountId?: undefined;
113
+ mode: "setup";
114
+ /**
115
+ * Lowercase three-letter ISO 4217 currency code. It filters the payment-method matrix.
116
+ */
117
+ currency: string;
102
118
  /**
103
119
  * 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
120
  */
105
121
  plan?: undefined;
106
122
  /**
107
- * Lowercase three-letter ISO 4217 payment currency code. It filters the payment-method matrix.
123
+ * Payment amount in minor units. Methods whose bounds exclude it aren't offered.
124
+ */
125
+ amount?: undefined;
126
+ /**
127
+ * 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.
128
+ */
129
+ offerAmounts?: undefined;
130
+ /**
131
+ * 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.
132
+ */
133
+ paymentMethodConfiguration?: { enabled?: string[] | undefined; disabled?: string[] | undefined; include_platform_defaults?: boolean | undefined; };
134
+ /**
135
+ * Return URL for off-site bank or 3DS steps. Defaults to the mounting page.
136
+ */
137
+ returnUrl?: string;
138
+ /**
139
+ * A setup saves the payment method for `off_session` use, the only usage a setup accepts.
140
+ */
141
+ setupFutureUsage?: "off_session";
142
+ /**
143
+ * Wallet availability override for deterministic previews. Live checkouts probe the host.
144
+ */
145
+ previewWalletAvailability?: WalletAvailability;
146
+ /**
147
+ * 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.
148
+ */
149
+ checkoutSession?: { id: string; clientSecret: string; };
150
+ /**
151
+ * Runs when the grouped loading state changes. The value is `true` while any mounted element is still loading.
152
+ */
153
+ onLoadingChange?: ((loading: boolean) => void);
154
+ /**
155
+ * 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.
156
+ */
157
+ analytics?: false;
158
+ }
159
+ | {
160
+ /**
161
+ * Account ID, prefixed `biz_`. Omit only when calling static methods without an account surface.
162
+ */
163
+ accountId?: string;
164
+ /**
165
+ * Mount mode, `payment` by default. `setup` saves a payment method and charges nothing, now or later: only methods that can be saved are offered and amount bounds do not apply. Confirm with `createConfirmationToken()`, then create the setup intent server-side.
166
+ */
167
+ mode?: undefined;
168
+ /**
169
+ * Plan ID, prefixed `plan_`. It resolves client-side to currency, amount, and method configuration. Pass a plan or inline currency and amount, never both.
170
+ */
171
+ plan?: undefined;
172
+ /**
173
+ * Lowercase three-letter ISO 4217 currency code. It filters the payment-method matrix.
108
174
  */
109
175
  currency?: undefined;
110
176
  /**
@@ -124,7 +190,7 @@ export type PaymentsOptions = (
124
190
  */
125
191
  returnUrl?: string;
126
192
  /**
127
- * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
193
+ * A setup saves the payment method for `off_session` use, the only usage a setup accepts.
128
194
  */
129
195
  setupFutureUsage?: "off_session" | "on_session";
130
196
  /**
@@ -166,10 +232,10 @@ export interface PaymentElementProps {
166
232
  */
167
233
  order?: string[];
168
234
  /**
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. With an installment plan selected, it narrows to the countries the plan serves — the billing country is the transaction country the charge processes under. It locks when only one is available.
235
+ * 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. `phone: 'never'` hides only the billing phone input when your form already collects it; pass `billingDetails.phone` to `createConfirmationToken` for methods that require it. Pass the address to `createConfirmationToken` instead. The country selector includes only countries supported by the method and payment currency. With an installment plan selected, it narrows to the countries the plan serves — the billing country is the transaction country the charge processes under. It locks when only one is available.
170
236
  * @default {"billingDetails":"minimal"}
171
237
  */
172
- fields?: { billingDetails?: "full" | "minimal" | "never" | undefined; };
238
+ fields?: { billingDetails?: "full" | "minimal" | "never" | undefined; phone?: "never" | "auto" | undefined; };
173
239
  /**
174
240
  * 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
241
  * @default "accordion"
@@ -226,10 +292,10 @@ export interface PaymentElementCreateOptions {
226
292
  */
227
293
  order?: string[];
228
294
  /**
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. With an installment plan selected, it narrows to the countries the plan serves — the billing country is the transaction country the charge processes under. It locks when only one is available.
295
+ * 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. `phone: 'never'` hides only the billing phone input when your form already collects it; pass `billingDetails.phone` to `createConfirmationToken` for methods that require it. Pass the address to `createConfirmationToken` instead. The country selector includes only countries supported by the method and payment currency. With an installment plan selected, it narrows to the countries the plan serves — the billing country is the transaction country the charge processes under. It locks when only one is available.
230
296
  * @default {"billingDetails":"minimal"}
231
297
  */
232
- fields?: { billingDetails?: "full" | "minimal" | "never" | undefined; };
298
+ fields?: { billingDetails?: "full" | "minimal" | "never" | undefined; phone?: "never" | "auto" | undefined; };
233
299
  /**
234
300
  * 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
301
  * @default "accordion"
@@ -246,9 +312,9 @@ export interface PaymentElementCreateOptions {
246
312
  */
247
313
  autoSelect?: boolean;
248
314
  /**
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.
315
+ * 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. `requiresBillingPhone` indicates whether the selected method requires a phone in billing details, including when `fields.phone` disables its input. `supportsBuyerFee` indicates whether to include Whop's buyer service fee in the displayed total.
250
316
  */
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);
317
+ onChange?: ((payload: { complete: boolean; type?: string | undefined; supportsBuyerFee?: boolean | undefined; requiresBillingPhone?: 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
318
  /**
253
319
  * 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
320
  */
@@ -272,6 +338,11 @@ export interface PaymentElementCreateOptions {
272
338
  * @see https://docs.whop.com/elements/latest/payments/address
273
339
  */
274
340
  export interface AddressElementProps {
341
+ /**
342
+ * Browser autocomplete purpose: `billing` (default) or `shipping`.
343
+ * @default "billing"
344
+ */
345
+ mode?: "billing" | "shipping";
275
346
  /**
276
347
  * `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
277
348
  * @default "full"
@@ -287,11 +358,6 @@ export interface AddressElementProps {
287
358
  * @default "combined"
288
359
  */
289
360
  name?: "split" | "combined" | "none";
290
- /**
291
- * Browser autocomplete purpose: `billing` (default) or `shipping`.
292
- * @default "billing"
293
- */
294
- mode?: "billing" | "shipping";
295
361
  /**
296
362
  * `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
363
  * @default "full"
@@ -323,7 +389,7 @@ export interface AddressElementProps {
323
389
  /**
324
390
  * Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
325
391
  */
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; })[];
392
+ customFields?: ({ key: string; label: string; type: "phone" | "text" | "select" | "date"; position: "after_name" | "after_organization" | "before_country" | "after_address"; required?: boolean | undefined; options?: string[] | undefined; format?: string | undefined; autocomplete?: string | undefined; })[];
327
393
  /**
328
394
  * Fallback country after `defaultValues` and IP detection. Use an ISO 3166-1 alpha-2 code. An empty value falls back to `US`.
329
395
  * @default ""
@@ -368,6 +434,11 @@ export interface AddressElementHandle {
368
434
  * @see https://docs.whop.com/elements/latest/payments/address
369
435
  */
370
436
  export interface AddressElementCreateOptions {
437
+ /**
438
+ * Browser autocomplete purpose: `billing` (default) or `shipping`.
439
+ * @default "billing"
440
+ */
441
+ mode?: "billing" | "shipping";
371
442
  /**
372
443
  * `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
373
444
  * @default "full"
@@ -383,11 +454,6 @@ export interface AddressElementCreateOptions {
383
454
  * @default "combined"
384
455
  */
385
456
  name?: "split" | "combined" | "none";
386
- /**
387
- * Browser autocomplete purpose: `billing` (default) or `shipping`.
388
- * @default "billing"
389
- */
390
- mode?: "billing" | "shipping";
391
457
  /**
392
458
  * `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
459
  * @default "full"
@@ -419,7 +485,7 @@ export interface AddressElementCreateOptions {
419
485
  /**
420
486
  * Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
421
487
  */
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; })[];
488
+ customFields?: ({ key: string; label: string; type: "phone" | "text" | "select" | "date"; position: "after_name" | "after_organization" | "before_country" | "after_address"; required?: boolean | undefined; options?: string[] | undefined; format?: string | undefined; autocomplete?: string | undefined; })[];
423
489
  /**
424
490
  * Fallback country after `defaultValues` and IP detection. Use an ISO 3166-1 alpha-2 code. An empty value falls back to `US`.
425
491
  * @default ""
@@ -950,6 +1016,11 @@ export interface PaymentRequestResourceOptions {
950
1016
  * @default true
951
1017
  */
952
1018
  requestPayerEmail?: boolean;
1019
+ /**
1020
+ * Ask the sheet for the payer's phone number, delivered as `payer.phone` on the result — in E.164 where it parses against the country of the contact that supplied it, as the wallet gave it otherwise; `payer.country` is the billing country. Google Pay collects it through the billing address the sheet already asks for.
1021
+ * @default false
1022
+ */
1023
+ requestPayerPhone?: boolean;
953
1024
  /**
954
1025
  * Ask the sheet for a shipping address (and offer `shippingOptions` when given).
955
1026
  * @default false
@@ -975,7 +1046,7 @@ export interface PaymentRequestResourceOptions {
975
1046
  */
976
1047
  export interface PaymentRequestResource {
977
1048
  /**
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 and verified as a [payment method domain](/api-reference/beta/payment-method-domains/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.
1049
+ * 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 and verified as a [payment method domain](/api-reference/beta/payment-method-domains/payment-method-domain), and offering Google Pay there is subject to the [Google Pay API Terms of Service](https://payments.developers.google.com/terms/sellertos)). 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
1050
  */
980
1051
  canMakePayment: () => Promise<WalletAvailability>;
981
1052
  /**
@@ -1045,10 +1116,10 @@ export interface PaymentsHandle {
1045
1116
  */
1046
1117
  create(name: "branding", options?: BrandingElementCreateOptions): BrandingElementHandle;
1047
1118
  /**
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(…)`.
1119
+ * Creates a confirmation token for the selected method from your pay button. Pass the checkout's billing details. They must include `email`. Supply `phone` for methods that require it when billing collection is disabled. 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
1120
  * Runs on your page (host-side), not in the controller iframe.
1050
1121
  */
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; }>;
1122
+ createConfirmationToken: (input: { billingDetails?: { email?: string | undefined; name?: string | undefined; phone?: 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
1123
  /**
1053
1124
  * 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
1125
  * Exclusive slot `entry`. Mount exactly one of: payment | card | cardFields.
@@ -1070,7 +1141,7 @@ export interface PaymentsHandle {
1070
1141
  */
1071
1142
  export interface PaymentsStatics {
1072
1143
  /**
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. Inside an iframe they navigate the top-level tab. If the embedding page refuses that navigation, they reject with code `TAB_NAVIGATION_BLOCKED`, and the payment stays pending. 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.
1144
+ * 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. Inside an iframe they navigate the top-level tab. If the embedding page refuses that navigation, they reject with code `TAB_NAVIGATION_BLOCKED`, and the payment stays pending. 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 whose charge is still being decided is polled until a step appears or it settles; a decided payment with no step resolves immediately.
1074
1145
  */
1075
1146
  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
1147
  /**
@@ -1149,7 +1220,7 @@ export interface PaymentRequestResult {
1149
1220
  */
1150
1221
  ctok: string;
1151
1222
  type: "apple_pay" | "google_pay";
1152
- payer: { email?: string | undefined; name?: string | undefined; phone?: string | undefined; };
1223
+ payer: { email?: string | undefined; name?: string | undefined; phone?: string | undefined; country?: string | undefined; };
1153
1224
  shipping: { address?: PaymentRequestAddress | undefined; option?: PaymentRequestShippingOption | undefined; } | null;
1154
1225
  }
1155
1226
 
@@ -237,7 +237,7 @@ export interface RfiElementCreateOptions {
237
237
  /**
238
238
  * One group of requirements was answered. Fires per group, not once per field.
239
239
  */
240
- onSubmitted?: ((payload: { source: "identity" | "payout" | "audit" | "card_issuing" | "bank" | "ads" | "application"; itemIds: string[]; }) => void);
240
+ onSubmitted?: ((payload: { source: "identity" | "payout" | "audit" | "card_issuing" | "bank" | "ads" | "application" | "airwallex"; itemIds: string[]; }) => void);
241
241
  /**
242
242
  * Nothing is outstanding any more. Fires when the element first observes an empty list, including on mount.
243
243
  */
@@ -301,7 +301,7 @@ export interface ActionRequiredItem {
301
301
  requirement: string;
302
302
  type: string;
303
303
  label: string;
304
- source?: "identity" | "payout" | "audit" | "card_issuing" | "bank" | "ads" | "application" | undefined;
304
+ source?: "identity" | "payout" | "audit" | "card_issuing" | "bank" | "ads" | "application" | "airwallex" | undefined;
305
305
  optional?: boolean | undefined;
306
306
  options?: string[] | undefined;
307
307
  errors?: { code: string; reason: string; }[] | undefined;