@whop/elements 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/payments.d.ts CHANGED
@@ -215,6 +215,11 @@ export interface PaymentElementProps {
215
215
  * @default []
216
216
  */
217
217
  order?: string[];
218
+ /**
219
+ * Controls which wallets the element offers. Each key defaults to `'auto'`, which offers the wallet wherever the account, the buyer's device, and the charge support it. `'never'` removes that wallet from the method list. Use it when your page draws its own Apple Pay, Google Pay, or PayPal buttons with `paymentRequest`, so buyers see each wallet once. `payPal: 'never'` removes the PayPal method. Saved payment methods are unaffected.
220
+ * @default {}
221
+ */
222
+ wallets?: { applePay?: "never" | "auto" | undefined; googlePay?: "never" | "auto" | undefined; payPal?: "never" | "auto" | undefined; };
218
223
  /**
219
224
  * 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.
220
225
  * @default {"billingDetails":"minimal"}
@@ -279,6 +284,11 @@ export interface PaymentElementCreateOptions {
279
284
  * @default []
280
285
  */
281
286
  order?: string[];
287
+ /**
288
+ * Controls which wallets the element offers. Each key defaults to `'auto'`, which offers the wallet wherever the account, the buyer's device, and the charge support it. `'never'` removes that wallet from the method list. Use it when your page draws its own Apple Pay, Google Pay, or PayPal buttons with `paymentRequest`, so buyers see each wallet once. `payPal: 'never'` removes the PayPal method. Saved payment methods are unaffected.
289
+ * @default {}
290
+ */
291
+ wallets?: { applePay?: "never" | "auto" | undefined; googlePay?: "never" | "auto" | undefined; payPal?: "never" | "auto" | undefined; };
282
292
  /**
283
293
  * 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.
284
294
  * @default {"billingDetails":"minimal"}
@@ -304,9 +314,9 @@ export interface PaymentElementCreateOptions {
304
314
  */
305
315
  autoSelect?: boolean;
306
316
  /**
307
- * 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.
317
+ * 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. `paymentMethod` is the selected payment method, saved or new, or `null` while nothing is selected: `displayName` and `icons` name the pick the way the element shows it (with `balance.imageUrl`, a balance owner's image), `card` carries a card's network, last four digits and funding, `requiresBillingPhone` says whether the method needs a phone in billing details, and `countries` lists where the method can pay from in the charge's currency. `type`, `requiresBillingPhone` and `method` at the top level are deprecated: read them from `paymentMethod`. `supportsBuyerFee` at the top level is deprecated too, with no replacement: Whop prices its buyer service fee itself.
308
318
  */
309
- 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);
319
+ onChange?: ((payload: PaymentElementChangeEvent) => void);
310
320
  /**
311
321
  * 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.
312
322
  */
@@ -339,7 +349,7 @@ export interface AddressElementProps {
339
349
  * The name row: one full-name field (default), split first/last fields, or none.
340
350
  * @default "combined"
341
351
  */
342
- name?: "split" | "combined" | "none";
352
+ name?: "split" | "none" | "combined";
343
353
  /**
344
354
  * Address line 2: always visible (default), revealed by a text button (`toggle`), or never collected.
345
355
  * @default "always"
@@ -368,7 +378,7 @@ export interface AddressElementProps {
368
378
  * Organization fields: none (default), name only, or name with a business/individual selector.
369
379
  * @default "none"
370
380
  */
371
- organization?: "name" | "none" | "name_with_type";
381
+ organization?: "none" | "name" | "name_with_type";
372
382
  /**
373
383
  * Default the country from the buyer's IP (resolved before first paint). Falls back to the controller's `countryHint`, then US.
374
384
  * @default true
@@ -379,7 +389,7 @@ export interface AddressElementProps {
379
389
  */
380
390
  allowedCountries?: string[];
381
391
  /**
382
- * 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.
392
+ * 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. On a phone, the suggestions open full screen from a search button in the street field instead of under it, where the keyboard would cover them. Set `false` for a plain input.
383
393
  * @default true
384
394
  */
385
395
  autocomplete?: boolean;
@@ -445,7 +455,7 @@ export interface AddressElementCreateOptions {
445
455
  * The name row: one full-name field (default), split first/last fields, or none.
446
456
  * @default "combined"
447
457
  */
448
- name?: "split" | "combined" | "none";
458
+ name?: "split" | "none" | "combined";
449
459
  /**
450
460
  * Address line 2: always visible (default), revealed by a text button (`toggle`), or never collected.
451
461
  * @default "always"
@@ -474,7 +484,7 @@ export interface AddressElementCreateOptions {
474
484
  * Organization fields: none (default), name only, or name with a business/individual selector.
475
485
  * @default "none"
476
486
  */
477
- organization?: "name" | "none" | "name_with_type";
487
+ organization?: "none" | "name" | "name_with_type";
478
488
  /**
479
489
  * Default the country from the buyer's IP (resolved before first paint). Falls back to the controller's `countryHint`, then US.
480
490
  * @default true
@@ -485,7 +495,7 @@ export interface AddressElementCreateOptions {
485
495
  */
486
496
  allowedCountries?: string[];
487
497
  /**
488
- * 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.
498
+ * 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. On a phone, the suggestions open full screen from a search button in the street field instead of under it, where the keyboard would cover them. Set `false` for a plain input.
489
499
  * @default true
490
500
  */
491
501
  autocomplete?: boolean;
@@ -595,6 +605,11 @@ export interface EmailElementProps {
595
605
  * @default true
596
606
  */
597
607
  label?: boolean;
608
+ /**
609
+ * Placeholder text for the email input. Empty (default) renders `you@example.com`. With floating labels the label text is the placeholder instead.
610
+ * @default ""
611
+ */
612
+ placeholder?: string;
598
613
  /**
599
614
  * `above` (default) shows the label above the input. `floating` uses the label text as the placeholder, then shows a small label above the typed text once the input has a value. Ignored when `label` is `false`.
600
615
  * @default "above"
@@ -605,11 +620,6 @@ export interface EmailElementProps {
605
620
  * @default ""
606
621
  */
607
622
  defaultValue?: string;
608
- /**
609
- * Placeholder text for the email input. Empty (default) renders `you@example.com`. With floating labels the label text is the placeholder instead.
610
- * @default ""
611
- */
612
- placeholder?: string;
613
623
  }
614
624
 
615
625
  /**
@@ -646,6 +656,11 @@ export interface EmailElementCreateOptions {
646
656
  * @default true
647
657
  */
648
658
  label?: boolean;
659
+ /**
660
+ * Placeholder text for the email input. Empty (default) renders `you@example.com`. With floating labels the label text is the placeholder instead.
661
+ * @default ""
662
+ */
663
+ placeholder?: string;
649
664
  /**
650
665
  * `above` (default) shows the label above the input. `floating` uses the label text as the placeholder, then shows a small label above the typed text once the input has a value. Ignored when `label` is `false`.
651
666
  * @default "above"
@@ -656,11 +671,6 @@ export interface EmailElementCreateOptions {
656
671
  * @default ""
657
672
  */
658
673
  defaultValue?: string;
659
- /**
660
- * Placeholder text for the email input. Empty (default) renders `you@example.com`. With floating labels the label text is the placeholder instead.
661
- * @default ""
662
- */
663
- placeholder?: string;
664
674
  /**
665
675
  * Fires when the email changes. `complete` is true when plausible. Sign-in fires it with the signed-in email, which also feeds `createConfirmationToken()`.
666
676
  */
@@ -825,6 +835,10 @@ export interface BrandingElementCreateOptions {
825
835
  * @see https://docs.whop.com/elements/latest/payments/overview
826
836
  */
827
837
  export interface CardFieldsSubOptions {
838
+ /**
839
+ * 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.
840
+ */
841
+ networks?: CardNetworkArt[];
828
842
  /**
829
843
  * `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.
830
844
  * @default "stacked"
@@ -835,13 +849,9 @@ export interface CardFieldsSubOptions {
835
849
  */
836
850
  publicKey?: string;
837
851
  /**
838
- * 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.
839
- */
840
- networks?: CardNetworkArt[];
841
- /**
842
- * 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. `funding` is the detected funding type (`credit`, `debit`, or `prepaid`), `null` until the number identifies one. `issuingCountry` is the lowercase two-letter code of the country the card was issued in, `null` until the number identifies one.
852
+ * 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 as the field reports it; `network` is the same detection in the API's network vocabulary (matches the matrix card entry's `networks`, `null` while unknown). `last4` is the number's last four digits, `null` until the number is far enough along. `funding` is the detected funding type (`credit`, `debit`, or `prepaid`), `null` until the number identifies one. `issuingCountry` is the lowercase two-letter code of the country the card was issued in, `null` until the number identifies one.
843
853
  */
844
- onChange?: ((payload: { complete: boolean; brand: string; funding: string | null; issuingCountry: string | null; }) => void);
854
+ onChange?: ((payload: { complete: boolean; brand: string; network: "visa" | "mastercard" | "amex" | "discover" | "jcb" | "diners" | "unionpay" | "elo" | "maestro" | null; last4: string | null; funding: string | null; issuingCountry: string | null; }) => void);
845
855
  }
846
856
 
847
857
  /**
@@ -1034,6 +1044,10 @@ export interface PaymentRequestResourceOptions {
1034
1044
  * Set only after displaying save consent. Marks the token for `off_session` or `on_session` use.
1035
1045
  */
1036
1046
  setupFutureUsage?: "off_session" | "on_session";
1047
+ /**
1048
+ * Payment method filters in the API's `enabled`, `disabled`, and `include_platform_defaults` format. They narrow the wallets `canMakePayment()` reports: `disabled` removes types, `enabled` restores offered types, and `include_platform_defaults: false` leaves only enabled types. They never add a method the account doesn't offer. PayPal follows the `paypal` type.
1049
+ */
1050
+ paymentMethodConfiguration?: PaymentMethodConfigurationShape;
1037
1051
  /**
1038
1052
  * Ask the sheet for the payer's email — the confirmation token requires one.
1039
1053
  * @default true
@@ -1055,11 +1069,11 @@ export interface PaymentRequestResourceOptions {
1055
1069
  */
1056
1070
  requestPromoCode?: boolean;
1057
1071
  /**
1058
- * A promo code already applied to the charge, prefilled into the sheet so the buyer can see or remove it.
1072
+ * A promo code already applied to the charge, prefilled into the sheet so the buyer can see, replace or remove it.
1059
1073
  */
1060
1074
  appliedPromoCode?: string;
1061
1075
  /**
1062
- * What `appliedPromoCode` does, shown next to the code where the sheet captions applied codes (Google Pay).
1076
+ * What `appliedPromoCode` does, shown next to the code in Google Pay. Apple Pay's coupon field has no caption.
1063
1077
  */
1064
1078
  appliedPromoDescription?: string;
1065
1079
  /**
@@ -1072,7 +1086,7 @@ export interface PaymentRequestResourceOptions {
1072
1086
  */
1073
1087
  lineItems?: PaymentRequestLineItem[];
1074
1088
  /**
1075
- * Shipping options the sheet offers when `requestShipping` is set. Display-only — update `amount` from your change handler.
1089
+ * Shipping options the sheet offers when `requestShipping` is set. Display-only — update `amount` from your change handler. The sheet opens with the first option selected and fires no `onShippingOptionChange` for it, so `amount` must already include its price.
1076
1090
  * Change it later with `update()`.
1077
1091
  */
1078
1092
  shippingOptions?: PaymentRequestShippingOption[];
@@ -1084,7 +1098,7 @@ export interface PaymentRequestResourceOptions {
1084
1098
  */
1085
1099
  export interface PaymentRequestResource {
1086
1100
  /**
1087
- * 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)). On a page that is itself inside an iframe, Apple Pay checks the top-level page's domain instead when the browser exposes it. 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, PayPal last — so express buttons can stack best-first. `payPal` reports PayPal where the account offers it in this currency, the amount is within PayPal's limits, the request neither sets `setupFutureUsage` nor asks for the payer's phone, PayPal's scripts load on this page, and this page's origin is approved for the account like the other wallets'. A page with a Content Security Policy must allow PayPal's hosts, which `contentSecurityPolicy()` includes. A page that already loads PayPal's own v5 JavaScript SDK reports `payPal: false`. Pass `types` to check only the wallets you list; `show(type)` needs that wallet checked. `wallets` carries each available wallet's official button art (`light` and `dark` color and image). This primes `show()`. Always await it first.
1101
+ * 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)). On a page that is itself inside an iframe, Apple Pay checks the top-level page's domain instead when the browser exposes it. 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, PayPal last — so express buttons can stack best-first. `payPal` reports PayPal where the account offers it in this currency, the amount is within PayPal's limits, the request does not ask for the payer's phone (an `off_session` request may be $0, which saves PayPal without a charge), PayPal's scripts load on this page, and this page's origin is approved for the account like the other wallets'. A page with a Content Security Policy must allow PayPal's hosts, which `contentSecurityPolicy()` includes. A page that already loads PayPal's own v5 JavaScript SDK reports `payPal: false`. Pass `types` to check only the wallets you list; `show(type)` needs that wallet checked. `wallets` carries each available wallet's official button art (`light` and `dark` color and image). This primes `show()`. Always await it first.
1088
1102
  */
1089
1103
  canMakePayment: (filter?: { types?: ("apple_pay" | "google_pay" | "paypal_express")[] | undefined; } | undefined) => Promise<WalletAvailability>;
1090
1104
  /**
@@ -1097,31 +1111,43 @@ export interface PaymentRequestResource {
1097
1111
  */
1098
1112
  update: (patch: { amount?: number | undefined; lineItems?: PaymentRequestLineItem[] | undefined; shippingOptions?: PaymentRequestShippingOption[] | undefined; }) => void;
1099
1113
  /**
1100
- * The sheet's shipping address changed (redacted pre-authorization: city/state/postal/country only). An error in the answer that names a `field` (`city`, `state`, `postal_code`, `country`) marks that field in Apple Pay; Google Pay shows the message alone. PayPal fires it with the address the buyer picks, and an error naming a `field` refuses that part of the address inside PayPal.
1114
+ * The buyer chose a shipping address (redacted pre-authorization: city, state, postal code and country only; Apple Pay cuts a US ZIP code to five digits and drops the last three characters of a Canadian or UK postal code). Answer with the totals for the address and the selected shipping option: the first one until the buyer picks another. `shippingOptions` replaces the options (an empty list changes nothing). A picked option stays selected while the answer keeps its `id`; when the answer drops it, the first option becomes the selection without an `onShippingOptionChange`, so price that one. Every error in the answer stays on the address until a later answer for an address clears it: one that names a `field` (`city`, `state`, `postal_code`, `country`) marks that field in Apple Pay, and Google Pay shows the message alone. Pay is refused while an error stands on the address. Refuse an address you can't ship to with a `shipping_address_unserviceable` error and no `field`. On Apple Pay, Google Pay and PayPal, a handler that hasn't answered within 25 seconds fails the address, the way a throwing one does, and its later answer is ignored. PayPal fires it with the address the buyer picks, and an error naming a `field` refuses that part of the address inside PayPal.
1101
1115
  * Call `updateWith(…)` exactly once per event. A handler that throws or rejects before calling it fails that update right away.
1102
1116
  * Returns the unsubscribe function.
1103
1117
  */
1104
1118
  onShippingAddressChange(handler: (ev: ShippingAddressChangeEvent) => void): () => void;
1105
1119
  /**
1106
- * The buyer picked a shipping option. Amount-only contract: `updateWith` carries amount/lineItems/shippingOptions/errors. Apple Pay has no error slot for a shipping option: an answer with `errors` keeps the last accepted total, and the first error's message shows when the buyer taps Pay, until they pick an option your handler accepts. Google Pay shows the message when the option is picked.
1120
+ * The buyer picked a shipping option, or Apple Pay re-announced the selected one: once the address changes are all answered and none is waiting, Apple Pay fires it for the option still selected. It never fires after an answer that drops the selected option, which makes the first option the selection without an event, so every total you answer prices the selected option: the first one until the buyer picks another, the pick while your answers keep its `id`, and the first again once an answer drops it. Amount-only contract: `updateWith` carries amount/lineItems/shippingOptions/errors. An answer with `errors` refuses the option until the buyer picks one your handler accepts. Apple Pay has no error slot for a shipping option, so it keeps the last accepted total whatever else the answer carries, and the first error's message shows when the buyer taps Pay. Google Pay shows the message when the option is picked. On Apple Pay, Google Pay and PayPal, a handler that hasn't answered within 25 seconds refuses the option, the way a throwing one does, and its later answer is ignored.
1107
1121
  * Call `updateWith(…)` exactly once per event. A handler that throws or rejects before calling it fails that update right away.
1108
1122
  * Returns the unsubscribe function.
1109
1123
  */
1110
1124
  onShippingOptionChange(handler: (ev: ShippingOptionChangeEvent) => void): () => void;
1111
1125
  /**
1112
- * 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, `updateWith({})` to keep the current total, or `updateWith({ errors })` to refuse the card. Every event is answered exactly once: a handler that throws, rejects, or doesn't answer within 10 seconds refuses the card, so the buyer picks another one. PayPal fires it with each shipping address the buyer picks in PayPal, which is the address its token bills and taxes on, and a refusal there refuses that address inside PayPal.
1126
+ * The buyer selected a card, with its redacted billing address (city, state, postal code and country only): reprice the total for the address the charge taxes off. Apple Pay fires it when the buyer selects a card, and Google Pay when the sheet opens and each time the buyer switches cards. Answer `updateWith({ amount })` in minor units, `updateWith({})` to keep the current total, or `updateWith({ errors })` to refuse the card. Every event is answered exactly once: a handler that throws, rejects, or doesn't answer within 10 seconds refuses the card, so the buyer picks another one. On Apple Pay and Google Pay the same selection then fires `paymentMethodChange`, and the sheet updates once both are answered. PayPal fires it with each shipping address the buyer picks in PayPal, which is the address its token bills and taxes on, and a refusal there refuses that address inside PayPal.
1113
1127
  * Call `updateWith(…)` exactly once per event. A handler that throws or rejects before calling it fails that update right away.
1114
1128
  * Returns the unsubscribe function.
1115
1129
  */
1116
1130
  onBillingAddressChange(handler: (ev: BillingAddressChangeEvent) => void): () => void;
1117
1131
  /**
1118
- * The buyer typed, changed, or removed a code in the sheet's promo field (`requestPromoCode`). Answer `updateWith({ amount })` to apply the code at a new total, `updateWith({})` to apply it at the current total, or `updateWith({ error })` to refuse it in place. A removal arrives with `code` null and is answered the same way. A handler that throws, rejects, or doesn't answer within 10 seconds refuses the code.
1132
+ * The buyer selected a payment method: reprice the total for it, such as a surcharge on credit cards. Apple Pay fires it when the buyer selects a card, and Google Pay when the sheet opens and each time the buyer switches cards, each right after that card's `billingAddressChange`. `paymentMethod.type` is `card`. `paymentMethod.card` carries what the wallet tells about a card before the buyer authorizes: Apple Pay reports its `funding` (Apple usually withholds the network until then), and Google Pay its `network`. `paymentMethod.billingAddress` is the card's redacted billing address. Answer `updateWith({ amount, lineItems })` to reprice, `updateWith({})` to keep the current total, or `updateWith({ errors })` to refuse the method; `shippingOptions` is ignored. Apple Pay marks a refusal on the card's billing contact (on the named `field` when one is given) and holds its Pay button until the buyer picks another method. Google Pay shows the message on the card and refuses a Pay tap on it until the buyer picks a card you accept. A refused card leaves the totals as they were, whatever this answer or its `billingAddressChange` answer priced. Every event is answered exactly once: a handler that throws, rejects, or doesn't answer within 10 seconds refuses the method. Each sheet waits for your answer before the buyer can pay. PayPal never fires it.
1133
+ * Call `updateWith(…)` exactly once per event. A handler that throws or rejects before calling it fails that update right away.
1134
+ * Returns the unsubscribe function.
1135
+ */
1136
+ onPaymentMethodChange(handler: (ev: PaymentMethodChangeEvent) => void): () => void;
1137
+ /**
1138
+ * The buyer typed, changed, or removed a code in the sheet's promo field (`requestPromoCode`). Answer `updateWith({ amount })` to apply the code at a new total, `updateWith({})` to apply it at the current total, or `updateWith({ error })` to refuse it in place. A removal arrives with `code` null and is answered the same way. Replacing an applied code arrives as one event with the new code, never a removal first, and a refused new code leaves the applied one in place. When `shippingOptions` drops the selected option, the first one becomes the selection without an `onShippingOptionChange`, so price that one. `appliedDescription` captions the code in Google Pay; Apple Pay's coupon field has no caption, so put anything the buyer must see in a line item label. A handler that throws, rejects, or doesn't answer within 10 seconds refuses the code.
1119
1139
  * Call `updateWith(…)` exactly once per event. A handler that throws or rejects before calling it fails that update right away.
1120
1140
  * Returns the unsubscribe function.
1121
1141
  */
1122
1142
  onPromoCodeChange(handler: (ev: PromoCodeChangeEvent) => void): () => void;
1123
1143
  /**
1124
- * The sheet created a confirmation token. This is the same result that `show()` returns.
1144
+ * The buyer authorized the payment, and no confirmation token exists yet. Subscribe to approve or refuse it first: the sheet waits for your answer, and without a handler the token is created at once. The event carries the payer, the payment method (with its redacted billing address, and in `displayName` the wallet's own label for it, such as `Visa 1234`), the shipping address and option, and the total and line items the buyer authorized. Answer `respondWith({ approved: true })` to create the token, which `show()` and `onConfirmationToken` then deliver as usual. Answer `respondWith({ approved: false, message })` to refuse: no token is created, Apple Pay and Google Pay show `message` in the sheet, and the buyer can change something and pay again, or close the sheet. PayPal can't show your message, so a refusal there ends the attempt: `show()` rejects with `payment_request_refused`, and the buyer can press PayPal again. Every event is answered exactly once, and only `approved: true` creates a token: a handler that throws, rejects, or doesn't answer within 25 seconds refuses the payment, early enough for Apple Pay and Google Pay to show the refusal before their own 30-second limit.
1145
+ * Call `respondWith(…)` exactly once per event. A handler that throws or rejects before calling it fails that update right away.
1146
+ * Returns the unsubscribe function.
1147
+ */
1148
+ onPaymentAuthorization(handler: (ev: PaymentAuthorizationEvent) => void): () => void;
1149
+ /**
1150
+ * The sheet created a confirmation token, heard once the sheet has closed. This is the same result that `show()` returns.
1125
1151
  * Returns the unsubscribe function.
1126
1152
  */
1127
1153
  onConfirmationToken(handler: (ev: PaymentRequestResult) => void): () => void;
@@ -1143,7 +1169,7 @@ export interface PaymentsHandle {
1143
1169
  */
1144
1170
  create(name: "payment", options?: PaymentElementCreateOptions): PaymentElementHandle;
1145
1171
  /**
1146
- * 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.
1172
+ * Collects a billing or shipping address. Fields, order, and validation follow the selected country. Includes street autocomplete (full screen on phones) and methods to read or validate the address.
1147
1173
  * One per "mode": call once per "mode" value; a second "address" with the same "mode" throws. "mode" is fixed at create.
1148
1174
  */
1149
1175
  create(name: "address", options?: AddressElementCreateOptions): AddressElementHandle;
@@ -1161,11 +1187,11 @@ export interface PaymentsHandle {
1161
1187
  */
1162
1188
  create(name: "taxId", options?: TaxIdElementCreateOptions): TaxIdElementHandle;
1163
1189
  /**
1164
- * Whop's merchant-of-record notice: the Whop wordmark with links to the buyer terms and privacy policy. Mount it alongside every payment collection surface.
1190
+ * Whop's merchant-of-record notice: the buyer's agreement to Whop's Buyer Terms of Service and Privacy Policy, with the Whop wordmark. Required — the payment, card and card fields elements stay in their loading state until it is mounted, and payments cannot be confirmed without it.
1165
1191
  */
1166
1192
  create(name: "branding", options?: BrandingElementCreateOptions): BrandingElementHandle;
1167
1193
  /**
1168
- * 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(…)`.
1194
+ * 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. When the account offers in-page bank linking (`bank_debit.bank_connection` on its bank account payment method type), a bank account selection opens Plaid Link during it too, and the call resolves once the buyer has linked an account. That needs a whop.com page or a domain verified as a [payment method domain](/api-reference/beta/payment-method-domains/payment-method-domain), and a Content Security Policy that allows the Plaid hosts `contentSecurityPolicy()` returns. Otherwise the buyer links the account after submitting instead. If the buyer closes the sheet or Link, the call rejects with `payment_request_cancelled`: treat it as a cancel, not a payment error, and let the buyer pay again. Confirm the returned `confirmationToken` server-side, then call `WhopElements.payments.handleNextAction(…)`.
1169
1195
  * Runs on your page (host-side), not in the controller iframe.
1170
1196
  */
1171
1197
  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; }>;
@@ -1242,6 +1268,95 @@ export interface WalletAvailability {
1242
1268
  wallets?: { apple_pay?: WalletDetails | undefined; google_pay?: WalletDetails | undefined; paypal_express?: WalletDetails | undefined; } | undefined;
1243
1269
  }
1244
1270
 
1271
+ /**
1272
+ * Any API `icons` object (or slice of one) qualifies: the component only reads the requested shape's light/dark SVGs.
1273
+ * Declared from the app's `PaymentMethodIconVariants`, referenced by a host-capability surface.
1274
+ */
1275
+ export interface PaymentMethodIconVariants {
1276
+ light: { svg: string; };
1277
+ dark: { svg: string; };
1278
+ }
1279
+
1280
+ /**
1281
+ * Declared from the app's `PaymentMethodIcons`, referenced by a host-capability surface.
1282
+ */
1283
+ export interface PaymentMethodIcons {
1284
+ square?: PaymentMethodIconVariants | null | undefined;
1285
+ card?: PaymentMethodIconVariants | null | undefined;
1286
+ }
1287
+
1288
+ /**
1289
+ * Declared from the app's `PaymentElementPaymentMethod`, referenced by a host-capability surface.
1290
+ */
1291
+ export interface PaymentElementPaymentMethod {
1292
+ /**
1293
+ * The saved payment method the buyer picked, or `null` for a method the buyer is entering now or a balance.
1294
+ */
1295
+ id: string | null;
1296
+ /**
1297
+ * The payment method type: `card`, `klarna`, `apple_pay`, `balance`, and so on.
1298
+ */
1299
+ type: string;
1300
+ /**
1301
+ * The family the type belongs to, such as `card`, `wallet`, `bnpl` or `balance`.
1302
+ */
1303
+ category: string;
1304
+ /**
1305
+ * What to call the pick: a saved method's own label ("Visa •••• 4242", "Cash App $tag"), a balance's name ("Acme", "Personal Balance"), a card's network and last four digits as the buyer types it, or else the method's own name ("Klarna").
1306
+ */
1307
+ displayName: string;
1308
+ /**
1309
+ * The pick's icon art: a saved method's own icons, a typed card's network art, or else the method's icons. Always an icon set, with SVG and PNG renditions.
1310
+ */
1311
+ icons?: PaymentMethodIcons | undefined;
1312
+ /**
1313
+ * What is known about a balance pick beyond its type: `imageUrl` is the balance owner's image, a single raster image URL rather than an icon set, to show in place of `icons`. Absent for other methods, and for a balance whose owner has no image.
1314
+ */
1315
+ balance?: { imageUrl?: string | undefined; } | undefined;
1316
+ /**
1317
+ * What is known about a card pick: a saved card's details, or a typed card's as the buyer types. Absent for other methods.
1318
+ */
1319
+ card?: { network?: string | undefined; last4?: string | undefined; funding?: string | undefined; } | undefined;
1320
+ /**
1321
+ * Whether the method needs a phone in the billing details, including when `fields.phone` disables the element's own phone input.
1322
+ */
1323
+ requiresBillingPhone: boolean;
1324
+ /**
1325
+ * The lowercase two-letter country codes the method can pay from in the charge's currency.
1326
+ */
1327
+ countries: string[];
1328
+ }
1329
+
1330
+ /**
1331
+ * Declared from the app's `PaymentElementChangeEvent`, referenced by a host-capability surface.
1332
+ */
1333
+ export interface PaymentElementChangeEvent {
1334
+ /**
1335
+ * Whether the buyer selected a method and completed its card fields or required inputs. Use it to enable confirmation.
1336
+ */
1337
+ complete: boolean;
1338
+ /**
1339
+ * The selected payment method, or `null` while nothing is selected.
1340
+ */
1341
+ paymentMethod: PaymentElementPaymentMethod | null;
1342
+ /**
1343
+ * @deprecated Use `paymentMethod.type`.
1344
+ */
1345
+ type?: string | undefined;
1346
+ /**
1347
+ * @deprecated Whop prices its buyer service fee itself, so a page has no use for it. Removed in the next major.
1348
+ */
1349
+ supportsBuyerFee?: boolean | undefined;
1350
+ /**
1351
+ * @deprecated Use `paymentMethod.requiresBillingPhone`.
1352
+ */
1353
+ requiresBillingPhone?: boolean | undefined;
1354
+ /**
1355
+ * @deprecated Use `paymentMethod`. Absent when the buyer picks a saved method.
1356
+ */
1357
+ 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;
1358
+ }
1359
+
1245
1360
  /**
1246
1361
  * The slice of a matrix card network the fields need: identity plus the API-served square art.
1247
1362
  * Declared from the app's `CardNetworkArt`, referenced by a host-capability surface.
@@ -1251,6 +1366,16 @@ export interface CardNetworkArt {
1251
1366
  icons: { square: { light: { svg: string; }; dark: { svg: string; }; }; };
1252
1367
  }
1253
1368
 
1369
+ /**
1370
+ * Payment method filters in the API's `payment_method_configuration` format: `disabled` removes types, `enabled` restores offered types, and `include_platform_defaults: false` leaves only enabled types.
1371
+ * Declared from the app's `PaymentMethodConfigurationShape`, referenced by a host-capability surface.
1372
+ */
1373
+ export interface PaymentMethodConfigurationShape {
1374
+ enabled?: string[] | undefined;
1375
+ disabled?: string[] | undefined;
1376
+ include_platform_defaults?: boolean | undefined;
1377
+ }
1378
+
1254
1379
  /**
1255
1380
  * Declared from the app's `PaymentRequestLineItem`, referenced by a host-capability surface.
1256
1381
  */
@@ -1279,12 +1404,20 @@ export interface PaymentRequestShippingOption {
1279
1404
  * Declared from the app's `PaymentRequestAddress`, referenced by a host-capability surface.
1280
1405
  */
1281
1406
  export interface PaymentRequestAddress {
1407
+ /**
1408
+ * The name on the address.
1409
+ */
1410
+ name?: string | undefined;
1282
1411
  line1?: string | undefined;
1283
1412
  line2?: string | undefined;
1284
1413
  city?: string | undefined;
1285
1414
  state?: string | undefined;
1286
1415
  postal_code?: string | undefined;
1287
1416
  country?: string | undefined;
1417
+ /**
1418
+ * The same value as `name`.
1419
+ * @deprecated Use `name`.
1420
+ */
1288
1421
  recipient?: string | undefined;
1289
1422
  phone?: string | undefined;
1290
1423
  }
@@ -1298,7 +1431,17 @@ export interface PaymentRequestResult {
1298
1431
  */
1299
1432
  ctok: string;
1300
1433
  type: "apple_pay" | "google_pay" | "paypal_express";
1434
+ /**
1435
+ * `phone` is E.164 where it parsed against the contact's country, as given otherwise; `country` is the billing country every sheet collects.
1436
+ */
1301
1437
  payer: { email?: string | undefined; name?: string | undefined; phone?: string | undefined; country?: string | undefined; };
1438
+ /**
1439
+ * The full billing address the confirmation token carries, unlike the redacted one the change events carry; `null` when the wallet gave none. Apple Pay and Google Pay give the card's billing address. On PayPal it is the address the buyer picked in PayPal, the one its total was taxed on.
1440
+ */
1441
+ billing: { address: PaymentRequestAddress; } | null;
1442
+ /**
1443
+ * `null` unless `requestShipping` was set. `option` is the selected shipping option: the first offered one until the buyer picks another, and the first again when an answer replaced the options without the picked `id`. Apple Pay and Google Pay set it whenever options were offered, and PayPal never does.
1444
+ */
1302
1445
  shipping: { address?: PaymentRequestAddress | undefined; option?: PaymentRequestShippingOption | undefined; } | null;
1303
1446
  }
1304
1447
 
@@ -1306,12 +1449,15 @@ export interface PaymentRequestResult {
1306
1449
  * Declared from the app's `PaymentRequestError`, referenced by a host-capability surface.
1307
1450
  */
1308
1451
  export interface PaymentRequestError {
1309
- code?: "shipping_address_invalid" | "shipping_address_unserviceable" | "shipping_option_invalid" | "other" | undefined;
1452
+ /**
1453
+ * What a shipping answer refuses. An error in a `billingAddressChange` or `paymentMethodChange` answer refuses the card or method that event asked about, whatever its code.
1454
+ */
1455
+ code?: "other" | "shipping_address_invalid" | "shipping_address_unserviceable" | "shipping_option_invalid" | undefined;
1310
1456
  message: string;
1311
1457
  /**
1312
1458
  * The address field the error is about: one of the fields the redacted address carries. Apple Pay marks that field with the message, whatever the `code`; Google Pay shows the message alone. Omit it for an error about the whole address.
1313
1459
  */
1314
- field?: "state" | "city" | "postal_code" | "country" | undefined;
1460
+ field?: "state" | "country" | "city" | "postal_code" | undefined;
1315
1461
  }
1316
1462
 
1317
1463
  /**
@@ -1320,6 +1466,9 @@ export interface PaymentRequestError {
1320
1466
  export interface PaymentRequestUpdate {
1321
1467
  amount?: number | undefined;
1322
1468
  lineItems?: PaymentRequestLineItem[] | undefined;
1469
+ /**
1470
+ * Replaces the sheet's shipping options. The selected option stays selected while its `id` is still in the list; otherwise the first option becomes the selection, with no `shippingOptionChange`, so price it in the same answer. An empty list changes nothing: refuse an address you can't ship to with a `shipping_address_unserviceable` error instead.
1471
+ */
1323
1472
  shippingOptions?: PaymentRequestShippingOption[] | undefined;
1324
1473
  errors?: PaymentRequestError[] | undefined;
1325
1474
  }
@@ -1329,11 +1478,11 @@ export interface PaymentRequestUpdate {
1329
1478
  */
1330
1479
  export interface ShippingAddressChangeEvent {
1331
1480
  /**
1332
- * Vendor-normalized pre-authorization address. It includes only city, state, postal code, and country.
1481
+ * Vendor-normalized pre-authorization address. It includes only city, state, postal code, and country. Apple Pay cuts the postal code down: a US ZIP code to its first five digits, and a Canadian or UK postal code without its last three characters.
1333
1482
  */
1334
1483
  address: PaymentRequestAddress;
1335
1484
  /**
1336
- * Call this exactly once, or the sheet stalls until the vendor times it out.
1485
+ * Call this exactly once, within 25 seconds. On Apple Pay, Google Pay and PayPal a handler that hasn't answered by then fails the address the way a throwing one does, and its later answer is ignored.
1337
1486
  */
1338
1487
  updateWith: (update: PaymentRequestUpdate) => void;
1339
1488
  }
@@ -1346,6 +1495,9 @@ export interface ShippingOptionChangeEvent {
1346
1495
  * Always includes the selected `id`. It includes the full option when it matches one of yours.
1347
1496
  */
1348
1497
  option: { id: string; } & Partial<PaymentRequestShippingOption>;
1498
+ /**
1499
+ * Call this exactly once, within 25 seconds. On Apple Pay, Google Pay and PayPal a handler that hasn't answered by then refuses the option the way a merchant refusal does, and its later answer is ignored.
1500
+ */
1349
1501
  updateWith: (update: PaymentRequestUpdate) => void;
1350
1502
  }
1351
1503
 
@@ -1363,6 +1515,42 @@ export interface BillingAddressChangeEvent {
1363
1515
  updateWith: (update: PaymentRequestUpdate) => void;
1364
1516
  }
1365
1517
 
1518
+ /**
1519
+ * Declared from the app's `PaymentRequestPaymentMethod`, referenced by a host-capability surface.
1520
+ */
1521
+ export interface PaymentRequestPaymentMethod {
1522
+ /**
1523
+ * `card` on Apple Pay and Google Pay, which report only cards; `paypal` on PayPal.
1524
+ */
1525
+ type: string;
1526
+ /**
1527
+ * What the wallet tells about the card. Before the buyer authorizes, on `paymentMethodChange`, Apple Pay reports its funding, usually without the network, and Google Pay its network. At authorization Apple Pay and Google Pay report both.
1528
+ */
1529
+ card?: { network?: string | undefined; funding?: "credit" | "debit" | "prepaid" | "store" | undefined; } | undefined;
1530
+ /**
1531
+ * The card's redacted billing address (city, state, postal code and country only), which Apple Pay and Google Pay hand over with the card.
1532
+ */
1533
+ billingAddress?: PaymentRequestAddress | undefined;
1534
+ /**
1535
+ * The wallet's own label for the method, such as `Visa 1234`. Apple Pay and Google Pay set it only once the buyer authorizes, so only `paymentAuthorization` carries it. Show it, and don't parse it: the wallets promise no format.
1536
+ */
1537
+ displayName?: string | undefined;
1538
+ }
1539
+
1540
+ /**
1541
+ * Declared from the app's `PaymentMethodChangeEvent`, referenced by a host-capability surface.
1542
+ */
1543
+ export interface PaymentMethodChangeEvent {
1544
+ /**
1545
+ * The method the buyer selected, as the wallet describes it before authorization.
1546
+ */
1547
+ paymentMethod: PaymentRequestPaymentMethod;
1548
+ /**
1549
+ * Call this exactly once: `amount` and `lineItems` reprice the sheet for the method, `updateWith({})` keeps the total, and `errors` refuses the method. An event left unanswered for 10 seconds refuses the method.
1550
+ */
1551
+ updateWith: (update: PaymentRequestUpdate) => void;
1552
+ }
1553
+
1366
1554
  /**
1367
1555
  * Declared from the app's `PromoCodeUpdate`, referenced by a host-capability surface.
1368
1556
  */
@@ -1376,7 +1564,11 @@ export interface PromoCodeUpdate {
1376
1564
  */
1377
1565
  lineItems?: PaymentRequestLineItem[] | undefined;
1378
1566
  /**
1379
- * A caption for the applied code, where the sheet captions codes (Google Pay).
1567
+ * Replaces the sheet's shipping options under the code, such as a free-shipping code that drops a rate to zero. An option stays selected while its `id` is still in the list; otherwise the first option becomes the selection, with no `shippingOptionChange`. Send `amount` as well when the selected option's price changes, since the total doesn't follow on its own. An empty list changes nothing.
1568
+ */
1569
+ shippingOptions?: PaymentRequestShippingOption[] | undefined;
1570
+ /**
1571
+ * A caption shown beside the applied code in Google Pay. Apple Pay's coupon field has no caption, so put anything the buyer must see in a line item label.
1380
1572
  */
1381
1573
  appliedDescription?: string | undefined;
1382
1574
  /**
@@ -1390,11 +1582,59 @@ export interface PromoCodeUpdate {
1390
1582
  */
1391
1583
  export interface PromoCodeChangeEvent {
1392
1584
  /**
1393
- * The code now in the sheet's promo field, or null when the buyer removed it.
1585
+ * The code now in the sheet's promo field, or null when the buyer removed it. Replacing an applied code is one event with the new code, never a removal first.
1394
1586
  */
1395
1587
  code: string | null;
1396
1588
  /**
1397
- * Answer exactly once: `error` refuses the code and keeps the totals, and any other answer applies it. `amount` and `lineItems` reprice the sheet under the code, and `appliedDescription` captions the applied code where the sheet shows one (Google Pay). `updateWith({})` applies the code at the current total.
1589
+ * Answer exactly once: `error` refuses the code and keeps the totals, and any other answer applies it. `amount` and `lineItems` reprice the sheet under the code, `shippingOptions` replaces its shipping options (a free-shipping code), and `appliedDescription` captions the applied code where the sheet shows one (Google Pay). `updateWith({})` applies the code at the current total.
1398
1590
  */
1399
1591
  updateWith: (update: PromoCodeUpdate) => void;
1400
1592
  }
1593
+
1594
+ /**
1595
+ * Declared from the app's `PaymentAuthorizationResponse`, referenced by a host-capability surface.
1596
+ */
1597
+ export interface PaymentAuthorizationResponse {
1598
+ /**
1599
+ * `true` creates the confirmation token. `false` refuses the payment.
1600
+ */
1601
+ approved: boolean;
1602
+ /**
1603
+ * Shown to the buyer when you refuse, in the sheet that took the authorization.
1604
+ */
1605
+ message?: string | undefined;
1606
+ }
1607
+
1608
+ /**
1609
+ * Declared from the app's `PaymentAuthorizationEvent`, referenced by a host-capability surface.
1610
+ */
1611
+ export interface PaymentAuthorizationEvent {
1612
+ /**
1613
+ * The wallet the buyer authorized in.
1614
+ */
1615
+ type: "apple_pay" | "google_pay" | "paypal_express";
1616
+ /**
1617
+ * The payer, as the result will carry it.
1618
+ */
1619
+ payer: { email?: string | undefined; name?: string | undefined; phone?: string | undefined; country?: string | undefined; };
1620
+ /**
1621
+ * The method the buyer authorized. Its billing address is redacted to city, state, postal code and country, as `paymentMethodChange` carries it.
1622
+ */
1623
+ paymentMethod: PaymentRequestPaymentMethod;
1624
+ /**
1625
+ * `null` unless `requestShipping` was set. Otherwise the address and option the result will carry.
1626
+ */
1627
+ shipping: { address?: PaymentRequestAddress | undefined; option?: PaymentRequestShippingOption | undefined; } | null;
1628
+ /**
1629
+ * The total the buyer authorized, in minor units.
1630
+ */
1631
+ amount: number;
1632
+ /**
1633
+ * The line items the sheet showed under that total.
1634
+ */
1635
+ lineItems: PaymentRequestLineItem[];
1636
+ /**
1637
+ * Call this exactly once. `{ approved: true }` creates the confirmation token. Anything else refuses the payment, and no token is created.
1638
+ */
1639
+ respondWith: (response: PaymentAuthorizationResponse) => void;
1640
+ }