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

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.ts CHANGED
@@ -12,9 +12,17 @@
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_`. Required for PaymentsElement; 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";
22
+ /**
23
+ * Scoped bearer token for PaymentsElement. Requires `payment:basic:read`; buyer emails additionally require `member:email:read`. Omit only with a same-origin Whop session.
24
+ */
25
+ accessToken?: string;
18
26
  /**
19
27
  * 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
28
  */
@@ -28,7 +36,7 @@ export type PaymentsOptions = (
28
36
  */
29
37
  returnUrl?: string;
30
38
  /**
31
- * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
39
+ * A setup saves the payment method for `off_session` use, the only usage a setup accepts, and displays the save consent.
32
40
  */
33
41
  setupFutureUsage?: "off_session" | "on_session";
34
42
  /**
@@ -50,11 +58,19 @@ export type PaymentsOptions = (
50
58
  }
51
59
  | {
52
60
  /**
53
- * Account ID, prefixed `biz_`. Omit only when calling static methods without a collection surface.
61
+ * Account ID, prefixed `biz_`. Required for PaymentsElement; omit only when calling static methods without an account surface.
54
62
  */
55
63
  accountId: string;
56
64
  /**
57
- * Lowercase three-letter ISO 4217 payment currency code. It filters the payment-method matrix.
65
+ * 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.
66
+ */
67
+ mode?: "payment";
68
+ /**
69
+ * Scoped bearer token for PaymentsElement. Requires `payment:basic:read`; buyer emails additionally require `member:email:read`. Omit only with a same-origin Whop session.
70
+ */
71
+ accessToken?: string;
72
+ /**
73
+ * Lowercase three-letter ISO 4217 currency code. It filters the payment-method matrix.
58
74
  */
59
75
  currency: string;
60
76
  /**
@@ -74,7 +90,7 @@ export type PaymentsOptions = (
74
90
  */
75
91
  returnUrl?: string;
76
92
  /**
77
- * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
93
+ * A setup saves the payment method for `off_session` use, the only usage a setup accepts, and displays the save consent.
78
94
  */
79
95
  setupFutureUsage?: "off_session" | "on_session";
80
96
  /**
@@ -96,15 +112,81 @@ export type PaymentsOptions = (
96
112
  }
97
113
  | {
98
114
  /**
99
- * Account ID, prefixed `biz_`. Omit only when calling static methods without a collection surface.
115
+ * Account ID, prefixed `biz_`. Required for PaymentsElement; omit only when calling static methods without an account surface.
116
+ */
117
+ accountId: string;
118
+ /**
119
+ * 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
120
  */
101
- accountId?: undefined;
121
+ mode: "setup";
122
+ /**
123
+ * Scoped bearer token for PaymentsElement. Requires `payment:basic:read`; buyer emails additionally require `member:email:read`. Omit only with a same-origin Whop session.
124
+ */
125
+ accessToken?: string;
126
+ /**
127
+ * Lowercase three-letter ISO 4217 currency code. It filters the payment-method matrix.
128
+ */
129
+ currency: string;
102
130
  /**
103
131
  * 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
132
  */
105
133
  plan?: undefined;
106
134
  /**
107
- * Lowercase three-letter ISO 4217 payment currency code. It filters the payment-method matrix.
135
+ * Payment amount in minor units. Methods whose bounds exclude it aren't offered.
136
+ */
137
+ amount?: undefined;
138
+ /**
139
+ * 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.
140
+ */
141
+ offerAmounts?: undefined;
142
+ /**
143
+ * 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.
144
+ */
145
+ paymentMethodConfiguration?: { enabled?: string[] | undefined; disabled?: string[] | undefined; include_platform_defaults?: boolean | undefined; };
146
+ /**
147
+ * Return URL for off-site bank or 3DS steps. Defaults to the mounting page.
148
+ */
149
+ returnUrl?: string;
150
+ /**
151
+ * A setup saves the payment method for `off_session` use, the only usage a setup accepts, and displays the save consent.
152
+ */
153
+ setupFutureUsage?: "off_session";
154
+ /**
155
+ * Wallet availability override for deterministic previews. Live checkouts probe the host.
156
+ */
157
+ previewWalletAvailability?: WalletAvailability;
158
+ /**
159
+ * 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.
160
+ */
161
+ checkoutSession?: { id: string; clientSecret: string; };
162
+ /**
163
+ * Runs when the grouped loading state changes. The value is `true` while any mounted element is still loading.
164
+ */
165
+ onLoadingChange?: ((loading: boolean) => void);
166
+ /**
167
+ * 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.
168
+ */
169
+ analytics?: false;
170
+ }
171
+ | {
172
+ /**
173
+ * Account ID, prefixed `biz_`. Required for PaymentsElement; omit only when calling static methods without an account surface.
174
+ */
175
+ accountId?: string;
176
+ /**
177
+ * Scoped bearer token for PaymentsElement. Requires `payment:basic:read`; buyer emails additionally require `member:email:read`. Omit only with a same-origin Whop session.
178
+ */
179
+ accessToken?: string;
180
+ /**
181
+ * 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.
182
+ */
183
+ mode?: undefined;
184
+ /**
185
+ * Plan ID, prefixed `plan_`. It resolves client-side to currency, amount, and method configuration. Pass a plan or inline currency and amount, never both.
186
+ */
187
+ plan?: undefined;
188
+ /**
189
+ * Lowercase three-letter ISO 4217 currency code. It filters the payment-method matrix.
108
190
  */
109
191
  currency?: undefined;
110
192
  /**
@@ -124,7 +206,7 @@ export type PaymentsOptions = (
124
206
  */
125
207
  returnUrl?: string;
126
208
  /**
127
- * Displays consent to save the payment method and marks the token for `off_session` or `on_session` use.
209
+ * A setup saves the payment method for `off_session` use, the only usage a setup accepts, and displays the save consent.
128
210
  */
129
211
  setupFutureUsage?: "off_session" | "on_session";
130
212
  /**
@@ -155,6 +237,120 @@ export type PaymentsOptions = (
155
237
  locale?: import("./_framework.js").WhopElementsLocale;
156
238
  };
157
239
 
240
+ /**
241
+ * Consumer props for the "payments" element. Set at create (or as `<PaymentsElement />` JSX props), and updatable live via `update()`.
242
+ * @see https://docs.whop.com/elements/latest/payments/payments
243
+ */
244
+ export interface PaymentsElementProps {
245
+ /**
246
+ * Show the header action menu, Export button, and table settings button.
247
+ * @default true
248
+ */
249
+ showActions?: boolean;
250
+ /**
251
+ * Show the three-dot action menu on each payment row.
252
+ * @default true
253
+ */
254
+ showRowActions?: boolean;
255
+ /**
256
+ * Show the six payment status boxes above the filters.
257
+ * @default true
258
+ */
259
+ showStatusTabs?: boolean;
260
+ /**
261
+ * Show the tracking column and filter for physical-product accounts. Tracking data requires `shipment:basic:read`.
262
+ * @default true
263
+ */
264
+ showTracking?: boolean;
265
+ }
266
+
267
+ /**
268
+ * The live handle for a mounted "payments" element. Returned by `create("payments")`; in React, the component's `ref`.
269
+ * @see https://docs.whop.com/elements/latest/payments/payments
270
+ */
271
+ export interface PaymentsElementHandle {
272
+ /**
273
+ * Reload payments after a refund or another change.
274
+ */
275
+ refresh: () => Promise<void>;
276
+ /**
277
+ * Mounts the element in `target` and starts loading. React components mount themselves.
278
+ */
279
+ mount: (target: string | HTMLElement) => void;
280
+ /**
281
+ * Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
282
+ */
283
+ destroy: () => void;
284
+ /**
285
+ * Merges new props into the mounted element. In React, change the component props instead.
286
+ */
287
+ update: (options: Partial<PaymentsElementProps>) => void;
288
+ }
289
+
290
+ /**
291
+ * Options for `create("payments")`: the consumer props plus event callbacks and lifecycle hooks.
292
+ * @example
293
+ * ```ts
294
+ * const payments = payments.create("payments", {}); // this interface: props + on<Event> callbacks
295
+ * payments.mount("#payments-payments");
296
+ * ```
297
+ * @see https://docs.whop.com/elements/latest/payments/payments
298
+ */
299
+ export interface PaymentsElementCreateOptions {
300
+ /**
301
+ * Show the header action menu, Export button, and table settings button.
302
+ * @default true
303
+ */
304
+ showActions?: boolean;
305
+ /**
306
+ * Show the three-dot action menu on each payment row.
307
+ * @default true
308
+ */
309
+ showRowActions?: boolean;
310
+ /**
311
+ * Show the six payment status boxes above the filters.
312
+ * @default true
313
+ */
314
+ showStatusTabs?: boolean;
315
+ /**
316
+ * Show the tracking column and filter for physical-product accounts. Tracking data requires `shipment:basic:read`.
317
+ * @default true
318
+ */
319
+ showTracking?: boolean;
320
+ /**
321
+ * Open payment details in your application.
322
+ */
323
+ onPaymentSelected?: ((payload: { paymentId: string; }) => void);
324
+ /**
325
+ * Open the invoice in your application.
326
+ */
327
+ onInvoiceRequested?: ((payload: { paymentId: string; }) => void);
328
+ /**
329
+ * Open the buyer in your application.
330
+ */
331
+ onUserSelected?: ((payload: { userId: string; }) => void);
332
+ /**
333
+ * The viewer requested a refund. Your application must confirm and authorize it server-side. Refund controls are enabled only when this callback is provided.
334
+ */
335
+ onRefundRequested?: ((payload: { paymentIds: string[]; }) => void);
336
+ /**
337
+ * Open the account’s payment settings in your application.
338
+ */
339
+ onSettingsRequested?: ((payload: Record<string, never>) => void);
340
+ /**
341
+ * Runs after the loading skeleton first paints and before `onReady`.
342
+ */
343
+ onLoaderStart?: (() => void);
344
+ /**
345
+ * Runs after the element's first complete paint.
346
+ */
347
+ onReady?: (() => void);
348
+ /**
349
+ * 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.
350
+ */
351
+ onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
352
+ }
353
+
158
354
  /**
159
355
  * Consumer props for the "payment" element. Set at create (or as `<PaymentElement />` JSX props), and updatable live via `update()`.
160
356
  * @see https://docs.whop.com/elements/latest/payments/payment
@@ -273,10 +469,10 @@ export interface PaymentElementCreateOptions {
273
469
  */
274
470
  export interface AddressElementProps {
275
471
  /**
276
- * `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
277
- * @default "full"
472
+ * Browser autocomplete purpose: `billing` (default) or `shipping`.
473
+ * @default "billing"
278
474
  */
279
- layout?: "full" | "compact";
475
+ mode?: "billing" | "shipping";
280
476
  /**
281
477
  * Address line 2: always visible (default), revealed by a text button (`toggle`), or never collected.
282
478
  * @default "always"
@@ -288,10 +484,10 @@ export interface AddressElementProps {
288
484
  */
289
485
  name?: "split" | "combined" | "none";
290
486
  /**
291
- * Browser autocomplete purpose: `billing` (default) or `shipping`.
292
- * @default "billing"
487
+ * `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
488
+ * @default "full"
293
489
  */
294
- mode?: "billing" | "shipping";
490
+ layout?: "full" | "compact";
295
491
  /**
296
492
  * `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
493
  * @default "full"
@@ -323,7 +519,7 @@ export interface AddressElementProps {
323
519
  /**
324
520
  * Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
325
521
  */
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; })[];
522
+ customFields?: ({ key: string; label: string; type: "text" | "select" | "phone" | "date"; position: "after_name" | "after_organization" | "before_country" | "after_address"; required?: boolean | undefined; options?: string[] | undefined; format?: string | undefined; autocomplete?: string | undefined; })[];
327
523
  /**
328
524
  * Fallback country after `defaultValues` and IP detection. Use an ISO 3166-1 alpha-2 code. An empty value falls back to `US`.
329
525
  * @default ""
@@ -369,10 +565,10 @@ export interface AddressElementHandle {
369
565
  */
370
566
  export interface AddressElementCreateOptions {
371
567
  /**
372
- * `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
373
- * @default "full"
568
+ * Browser autocomplete purpose: `billing` (default) or `shipping`.
569
+ * @default "billing"
374
570
  */
375
- layout?: "full" | "compact";
571
+ mode?: "billing" | "shipping";
376
572
  /**
377
573
  * Address line 2: always visible (default), revealed by a text button (`toggle`), or never collected.
378
574
  * @default "always"
@@ -384,10 +580,10 @@ export interface AddressElementCreateOptions {
384
580
  */
385
581
  name?: "split" | "combined" | "none";
386
582
  /**
387
- * Browser autocomplete purpose: `billing` (default) or `shipping`.
388
- * @default "billing"
583
+ * `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
584
+ * @default "full"
389
585
  */
390
- mode?: "billing" | "shipping";
586
+ layout?: "full" | "compact";
391
587
  /**
392
588
  * `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
589
  * @default "full"
@@ -419,7 +615,7 @@ export interface AddressElementCreateOptions {
419
615
  /**
420
616
  * Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
421
617
  */
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; })[];
618
+ customFields?: ({ key: string; label: string; type: "text" | "select" | "phone" | "date"; position: "after_name" | "after_organization" | "before_country" | "after_address"; required?: boolean | undefined; options?: string[] | undefined; format?: string | undefined; autocomplete?: string | undefined; })[];
423
619
  /**
424
620
  * Fallback country after `defaultValues` and IP detection. Use an ISO 3166-1 alpha-2 code. An empty value falls back to `US`.
425
621
  * @default ""
@@ -950,6 +1146,11 @@ export interface PaymentRequestResourceOptions {
950
1146
  * @default true
951
1147
  */
952
1148
  requestPayerEmail?: boolean;
1149
+ /**
1150
+ * 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.
1151
+ * @default false
1152
+ */
1153
+ requestPayerPhone?: boolean;
953
1154
  /**
954
1155
  * Ask the sheet for a shipping address (and offer `shippingOptions` when given).
955
1156
  * @default false
@@ -1018,6 +1219,10 @@ export interface PaymentRequestResource {
1018
1219
  * @see https://docs.whop.com/elements/latest/payments/overview
1019
1220
  */
1020
1221
  export interface PaymentsHandle {
1222
+ /**
1223
+ * The dashboard payments table with status cards, search, filters, sorting, row selection, CSV export, column settings, and pagination. Reads all payment pages to compute complete counts and filter locally; intended for accounts with modest payment histories. Customer details and refunds are handed to your application through events.
1224
+ */
1225
+ create(name: "payments", options?: PaymentsElementCreateOptions): PaymentsElementHandle;
1021
1226
  /**
1022
1227
  * 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
1228
  * Exclusive slot `entry`. Mount exactly one of: payment | card | cardFields.
@@ -1070,7 +1275,7 @@ export interface PaymentsHandle {
1070
1275
  */
1071
1276
  export interface PaymentsStatics {
1072
1277
  /**
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.
1278
+ * 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
1279
  */
1075
1280
  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
1281
  /**
@@ -1149,7 +1354,7 @@ export interface PaymentRequestResult {
1149
1354
  */
1150
1355
  ctok: string;
1151
1356
  type: "apple_pay" | "google_pay";
1152
- payer: { email?: string | undefined; name?: string | undefined; phone?: string | undefined; };
1357
+ payer: { email?: string | undefined; name?: string | undefined; phone?: string | undefined; country?: string | undefined; };
1153
1358
  shipping: { address?: PaymentRequestAddress | undefined; option?: PaymentRequestShippingOption | undefined; } | null;
1154
1359
  }
1155
1360
 
@@ -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
  */
@@ -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
  */