@whop/elements 1.4.0 → 1.6.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/package.json +2 -2
- package/payments.d.cts +126 -10
- package/payments.d.ts +126 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whop/elements",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Whop Elements — vanilla-js loader + types. Loads the hosted SDK and exposes the typed WhopElements factory.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"checkout",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
|
-
"whopElementsApiHash": "
|
|
100
|
+
"whopElementsApiHash": "f11e64fefcafa5eff8df4bbd6a2afbf830f2e718599e49ab8b4a16b111de7565"
|
|
101
101
|
}
|
package/payments.d.cts
CHANGED
|
@@ -350,10 +350,15 @@ export interface AddressElementProps {
|
|
|
350
350
|
*/
|
|
351
351
|
defaultValues?: { name?: string | undefined; address?: { name?: string | undefined; first_name?: string | undefined; last_name?: string | undefined; organization?: string | undefined; organization_type?: "business" | "individual" | undefined; line1?: string | undefined; line2?: string | undefined; city?: string | undefined; state?: string | undefined; postal_code?: string | undefined; country?: string | undefined; } | undefined; };
|
|
352
352
|
/**
|
|
353
|
-
* `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
|
|
353
|
+
* `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border. `wrap` keeps `full`'s separate fields and also puts city, state and postal code side by side. Those and the pairs `full` already sets side by side (first and last name, organization) fit as many to a row as the width allows and wrap as it narrows.
|
|
354
354
|
* @default "full"
|
|
355
355
|
*/
|
|
356
|
-
layout?: "full" | "compact";
|
|
356
|
+
layout?: "full" | "compact" | "wrap";
|
|
357
|
+
/**
|
|
358
|
+
* `above` (default) keeps each label outside its field: above it in the `full` layout, as its placeholder in `compact`. `floating` uses each label as the placeholder of its field, in either layout, then shows a small label above the typed text once the field has a value.
|
|
359
|
+
* @default "above"
|
|
360
|
+
*/
|
|
361
|
+
labelMode?: "above" | "floating";
|
|
357
362
|
/**
|
|
358
363
|
* `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`.
|
|
359
364
|
* @default "full"
|
|
@@ -378,6 +383,11 @@ export interface AddressElementProps {
|
|
|
378
383
|
* @default true
|
|
379
384
|
*/
|
|
380
385
|
autocomplete?: boolean;
|
|
386
|
+
/**
|
|
387
|
+
* Shows every address field from the start. By default (`false`) the form opens with the street address and reveals the rest once the buyer picks a suggestion, types an address, or chooses to enter it manually.
|
|
388
|
+
* @default false
|
|
389
|
+
*/
|
|
390
|
+
expanded?: boolean;
|
|
381
391
|
/**
|
|
382
392
|
* Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
|
|
383
393
|
*/
|
|
@@ -446,10 +456,15 @@ export interface AddressElementCreateOptions {
|
|
|
446
456
|
*/
|
|
447
457
|
defaultValues?: { name?: string | undefined; address?: { name?: string | undefined; first_name?: string | undefined; last_name?: string | undefined; organization?: string | undefined; organization_type?: "business" | "individual" | undefined; line1?: string | undefined; line2?: string | undefined; city?: string | undefined; state?: string | undefined; postal_code?: string | undefined; country?: string | undefined; } | undefined; };
|
|
448
458
|
/**
|
|
449
|
-
* `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
|
|
459
|
+
* `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border. `wrap` keeps `full`'s separate fields and also puts city, state and postal code side by side. Those and the pairs `full` already sets side by side (first and last name, organization) fit as many to a row as the width allows and wrap as it narrows.
|
|
450
460
|
* @default "full"
|
|
451
461
|
*/
|
|
452
|
-
layout?: "full" | "compact";
|
|
462
|
+
layout?: "full" | "compact" | "wrap";
|
|
463
|
+
/**
|
|
464
|
+
* `above` (default) keeps each label outside its field: above it in the `full` layout, as its placeholder in `compact`. `floating` uses each label as the placeholder of its field, in either layout, then shows a small label above the typed text once the field has a value.
|
|
465
|
+
* @default "above"
|
|
466
|
+
*/
|
|
467
|
+
labelMode?: "above" | "floating";
|
|
453
468
|
/**
|
|
454
469
|
* `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`.
|
|
455
470
|
* @default "full"
|
|
@@ -474,6 +489,11 @@ export interface AddressElementCreateOptions {
|
|
|
474
489
|
* @default true
|
|
475
490
|
*/
|
|
476
491
|
autocomplete?: boolean;
|
|
492
|
+
/**
|
|
493
|
+
* Shows every address field from the start. By default (`false`) the form opens with the street address and reveals the rest once the buyer picks a suggestion, types an address, or chooses to enter it manually.
|
|
494
|
+
* @default false
|
|
495
|
+
*/
|
|
496
|
+
expanded?: boolean;
|
|
477
497
|
/**
|
|
478
498
|
* Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
|
|
479
499
|
*/
|
|
@@ -575,13 +595,18 @@ export interface EmailElementProps {
|
|
|
575
595
|
* @default true
|
|
576
596
|
*/
|
|
577
597
|
label?: boolean;
|
|
598
|
+
/**
|
|
599
|
+
* `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
|
+
* @default "above"
|
|
601
|
+
*/
|
|
602
|
+
labelMode?: "above" | "floating";
|
|
578
603
|
/**
|
|
579
604
|
* Seed value applied once at mount.
|
|
580
605
|
* @default ""
|
|
581
606
|
*/
|
|
582
607
|
defaultValue?: string;
|
|
583
608
|
/**
|
|
584
|
-
* Placeholder text for the email input. Empty (default) renders `you@example.com`.
|
|
609
|
+
* Placeholder text for the email input. Empty (default) renders `you@example.com`. With floating labels the label text is the placeholder instead.
|
|
585
610
|
* @default ""
|
|
586
611
|
*/
|
|
587
612
|
placeholder?: string;
|
|
@@ -621,13 +646,18 @@ export interface EmailElementCreateOptions {
|
|
|
621
646
|
* @default true
|
|
622
647
|
*/
|
|
623
648
|
label?: boolean;
|
|
649
|
+
/**
|
|
650
|
+
* `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
|
+
* @default "above"
|
|
652
|
+
*/
|
|
653
|
+
labelMode?: "above" | "floating";
|
|
624
654
|
/**
|
|
625
655
|
* Seed value applied once at mount.
|
|
626
656
|
* @default ""
|
|
627
657
|
*/
|
|
628
658
|
defaultValue?: string;
|
|
629
659
|
/**
|
|
630
|
-
* Placeholder text for the email input. Empty (default) renders `you@example.com`.
|
|
660
|
+
* Placeholder text for the email input. Empty (default) renders `you@example.com`. With floating labels the label text is the placeholder instead.
|
|
631
661
|
* @default ""
|
|
632
662
|
*/
|
|
633
663
|
placeholder?: string;
|
|
@@ -997,6 +1027,7 @@ export interface PaymentRequestResourceOptions {
|
|
|
997
1027
|
currency: string;
|
|
998
1028
|
/**
|
|
999
1029
|
* Payment amount in minor units.
|
|
1030
|
+
* Change it later with `update()`.
|
|
1000
1031
|
*/
|
|
1001
1032
|
amount: number;
|
|
1002
1033
|
/**
|
|
@@ -1018,16 +1049,31 @@ export interface PaymentRequestResourceOptions {
|
|
|
1018
1049
|
* @default false
|
|
1019
1050
|
*/
|
|
1020
1051
|
requestShipping?: boolean;
|
|
1052
|
+
/**
|
|
1053
|
+
* Offer the sheet's own promo code field and answer `onPromoCodeChange`. Apple Pay shows the field on devices that support Apple Pay version 12 (iOS 15 and macOS 12); Google Pay shows it where the account's Google Pay setup allows offers. Other devices open the sheet without it.
|
|
1054
|
+
* @default false
|
|
1055
|
+
*/
|
|
1056
|
+
requestPromoCode?: boolean;
|
|
1057
|
+
/**
|
|
1058
|
+
* A promo code already applied to the charge, prefilled into the sheet so the buyer can see or remove it.
|
|
1059
|
+
*/
|
|
1060
|
+
appliedPromoCode?: string;
|
|
1061
|
+
/**
|
|
1062
|
+
* What `appliedPromoCode` does, shown next to the code where the sheet captions applied codes (Google Pay).
|
|
1063
|
+
*/
|
|
1064
|
+
appliedPromoDescription?: string;
|
|
1021
1065
|
/**
|
|
1022
1066
|
* Account ISO 3166-1 alpha-2 country code for the Apple Pay sheet. Omit it to use the account's published registration country. The sheet defaults to `US` when neither is available.
|
|
1023
1067
|
*/
|
|
1024
1068
|
countryCode?: string;
|
|
1025
1069
|
/**
|
|
1026
1070
|
* Line items the sheet lists under the total.
|
|
1071
|
+
* Change it later with `update()`.
|
|
1027
1072
|
*/
|
|
1028
1073
|
lineItems?: PaymentRequestLineItem[];
|
|
1029
1074
|
/**
|
|
1030
1075
|
* Shipping options the sheet offers when `requestShipping` is set. Display-only — update `amount` from your change handler.
|
|
1076
|
+
* Change it later with `update()`.
|
|
1031
1077
|
*/
|
|
1032
1078
|
shippingOptions?: PaymentRequestShippingOption[];
|
|
1033
1079
|
}
|
|
@@ -1038,14 +1084,18 @@ export interface PaymentRequestResourceOptions {
|
|
|
1038
1084
|
*/
|
|
1039
1085
|
export interface PaymentRequestResource {
|
|
1040
1086
|
/**
|
|
1041
|
-
* 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, 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`. This primes `show()`. Always await it first.
|
|
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.
|
|
1042
1088
|
*/
|
|
1043
|
-
canMakePayment: () => Promise<WalletAvailability>;
|
|
1089
|
+
canMakePayment: (filter?: { types?: ("apple_pay" | "google_pay" | "paypal_express")[] | undefined; } | undefined) => Promise<WalletAvailability>;
|
|
1044
1090
|
/**
|
|
1045
|
-
* Open the selected wallet after awaiting `canMakePayment()`, synchronously in the press: Apple requires session creation within the gesture stack, and PayPal opens its window there — a pop-up on desktop, PayPal's in-page window when the pop-up is blocked and on mobile. Pass `email` when your page already collected one — the wallet takes it and never asks for a second. With `requestPayerEmail: false`, passing one is required, and the wallet refuses to open without it because confirmation tokens require an email.
|
|
1091
|
+
* Open the selected wallet after awaiting `canMakePayment()`, synchronously in the press: Apple requires session creation within the gesture stack, and PayPal opens its window there — a pop-up on desktop, PayPal's in-page window when the pop-up is blocked and on mobile. Pass `email` when your page already collected one — the wallet takes it and never asks for a second. With `requestPayerEmail: false`, passing one is required, and the wallet refuses to open without it because confirmation tokens require an email. While the sheet is open, `update()` throws: answer the change events to change it.
|
|
1046
1092
|
* Call synchronously during user activation. Await prerequisites first because browsers revoke activation across asynchronous steps.
|
|
1047
1093
|
*/
|
|
1048
1094
|
show: (type: "apple_pay" | "google_pay" | "paypal_express", provided?: { email?: string | undefined; } | undefined) => Promise<PaymentRequestResult>;
|
|
1095
|
+
/**
|
|
1096
|
+
* Change `amount`, `lineItems` and `shippingOptions` on this instance. Every other option is fixed at `create()`: create a new instance to change it.
|
|
1097
|
+
*/
|
|
1098
|
+
update: (patch: { amount?: number | undefined; lineItems?: PaymentRequestLineItem[] | undefined; shippingOptions?: PaymentRequestShippingOption[] | undefined; }) => void;
|
|
1049
1099
|
/**
|
|
1050
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.
|
|
1051
1101
|
* Call `updateWith(…)` exactly once per event. A handler that throws or rejects before calling it fails that update right away.
|
|
@@ -1064,6 +1114,12 @@ export interface PaymentRequestResource {
|
|
|
1064
1114
|
* Returns the unsubscribe function.
|
|
1065
1115
|
*/
|
|
1066
1116
|
onBillingAddressChange(handler: (ev: BillingAddressChangeEvent) => void): () => void;
|
|
1117
|
+
/**
|
|
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.
|
|
1119
|
+
* Call `updateWith(…)` exactly once per event. A handler that throws or rejects before calling it fails that update right away.
|
|
1120
|
+
* Returns the unsubscribe function.
|
|
1121
|
+
*/
|
|
1122
|
+
onPromoCodeChange(handler: (ev: PromoCodeChangeEvent) => void): () => void;
|
|
1067
1123
|
/**
|
|
1068
1124
|
* The sheet created a confirmation token. This is the same result that `show()` returns.
|
|
1069
1125
|
* Returns the unsubscribe function.
|
|
@@ -1144,6 +1200,30 @@ export interface PaymentsStatics {
|
|
|
1144
1200
|
paymentRequest: { create(options: PaymentRequestResourceOptions): PaymentRequestResource };
|
|
1145
1201
|
}
|
|
1146
1202
|
|
|
1203
|
+
/**
|
|
1204
|
+
* Declared from the app's `WalletButtonArt`, referenced by a host-capability surface.
|
|
1205
|
+
*/
|
|
1206
|
+
export interface WalletButtonArt {
|
|
1207
|
+
/**
|
|
1208
|
+
* For light pages.
|
|
1209
|
+
*/
|
|
1210
|
+
light: { color: string; image: string; };
|
|
1211
|
+
/**
|
|
1212
|
+
* For dark pages.
|
|
1213
|
+
*/
|
|
1214
|
+
dark: { color: string; image: string; };
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
/**
|
|
1218
|
+
* Declared from the app's `WalletDetails`, referenced by a host-capability surface.
|
|
1219
|
+
*/
|
|
1220
|
+
export interface WalletDetails {
|
|
1221
|
+
/**
|
|
1222
|
+
* The wallet's official button art. Absent when none is published.
|
|
1223
|
+
*/
|
|
1224
|
+
button?: WalletButtonArt | undefined;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1147
1227
|
/**
|
|
1148
1228
|
* Host-probed wallet availability after checking offered methods, device capability, and Google Pay origin approval.
|
|
1149
1229
|
* Declared from the app's `WalletAvailability`, referenced by a host-capability surface.
|
|
@@ -1156,6 +1236,10 @@ export interface WalletAvailability {
|
|
|
1156
1236
|
* The wallets ranked by which sheet is native to this browser — Apple Pay first on WebKit, Google Pay first everywhere else, PayPal last — so express buttons can stack best-first. Absent on consumer-stated availability (previews) and on wires that predate it. An inline union, not payment-request's WalletSheetType: that module already imports this one.
|
|
1157
1237
|
*/
|
|
1158
1238
|
order?: ("apple_pay" | "google_pay" | "paypal_express")[] | undefined;
|
|
1239
|
+
/**
|
|
1240
|
+
* Each available wallet's details, keyed by wallet type. Absent on consumer-stated availability (previews).
|
|
1241
|
+
*/
|
|
1242
|
+
wallets?: { apple_pay?: WalletDetails | undefined; google_pay?: WalletDetails | undefined; paypal_express?: WalletDetails | undefined; } | undefined;
|
|
1159
1243
|
}
|
|
1160
1244
|
|
|
1161
1245
|
/**
|
|
@@ -1274,7 +1358,39 @@ export interface BillingAddressChangeEvent {
|
|
|
1274
1358
|
*/
|
|
1275
1359
|
address: PaymentRequestAddress;
|
|
1276
1360
|
/**
|
|
1277
|
-
* Call this exactly once. An event left unanswered
|
|
1361
|
+
* Call this exactly once. An event left unanswered for 10 seconds refuses the card, and the buyer picks another one.
|
|
1278
1362
|
*/
|
|
1279
1363
|
updateWith: (update: PaymentRequestUpdate) => void;
|
|
1280
1364
|
}
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* Declared from the app's `PromoCodeUpdate`, referenced by a host-capability surface.
|
|
1368
|
+
*/
|
|
1369
|
+
export interface PromoCodeUpdate {
|
|
1370
|
+
/**
|
|
1371
|
+
* The total under the code, in minor units.
|
|
1372
|
+
*/
|
|
1373
|
+
amount?: number | undefined;
|
|
1374
|
+
/**
|
|
1375
|
+
* A caption for the applied code, where the sheet captions codes (Google Pay).
|
|
1376
|
+
*/
|
|
1377
|
+
appliedDescription?: string | undefined;
|
|
1378
|
+
/**
|
|
1379
|
+
* Refuses the code. The sheet shows `message` next to its promo field.
|
|
1380
|
+
*/
|
|
1381
|
+
error?: { message: string; } | undefined;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* Declared from the app's `PromoCodeChangeEvent`, referenced by a host-capability surface.
|
|
1386
|
+
*/
|
|
1387
|
+
export interface PromoCodeChangeEvent {
|
|
1388
|
+
/**
|
|
1389
|
+
* The code now in the sheet's promo field, or null when the buyer removed it.
|
|
1390
|
+
*/
|
|
1391
|
+
code: string | null;
|
|
1392
|
+
/**
|
|
1393
|
+
* Answer exactly once: `error` refuses the code and keeps the totals, and any other answer applies it. `amount` reprices 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.
|
|
1394
|
+
*/
|
|
1395
|
+
updateWith: (update: PromoCodeUpdate) => void;
|
|
1396
|
+
}
|
package/payments.d.ts
CHANGED
|
@@ -350,10 +350,15 @@ export interface AddressElementProps {
|
|
|
350
350
|
*/
|
|
351
351
|
defaultValues?: { name?: string | undefined; address?: { name?: string | undefined; first_name?: string | undefined; last_name?: string | undefined; organization?: string | undefined; organization_type?: "business" | "individual" | undefined; line1?: string | undefined; line2?: string | undefined; city?: string | undefined; state?: string | undefined; postal_code?: string | undefined; country?: string | undefined; } | undefined; };
|
|
352
352
|
/**
|
|
353
|
-
* `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
|
|
353
|
+
* `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border. `wrap` keeps `full`'s separate fields and also puts city, state and postal code side by side. Those and the pairs `full` already sets side by side (first and last name, organization) fit as many to a row as the width allows and wrap as it narrows.
|
|
354
354
|
* @default "full"
|
|
355
355
|
*/
|
|
356
|
-
layout?: "full" | "compact";
|
|
356
|
+
layout?: "full" | "compact" | "wrap";
|
|
357
|
+
/**
|
|
358
|
+
* `above` (default) keeps each label outside its field: above it in the `full` layout, as its placeholder in `compact`. `floating` uses each label as the placeholder of its field, in either layout, then shows a small label above the typed text once the field has a value.
|
|
359
|
+
* @default "above"
|
|
360
|
+
*/
|
|
361
|
+
labelMode?: "above" | "floating";
|
|
357
362
|
/**
|
|
358
363
|
* `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`.
|
|
359
364
|
* @default "full"
|
|
@@ -378,6 +383,11 @@ export interface AddressElementProps {
|
|
|
378
383
|
* @default true
|
|
379
384
|
*/
|
|
380
385
|
autocomplete?: boolean;
|
|
386
|
+
/**
|
|
387
|
+
* Shows every address field from the start. By default (`false`) the form opens with the street address and reveals the rest once the buyer picks a suggestion, types an address, or chooses to enter it manually.
|
|
388
|
+
* @default false
|
|
389
|
+
*/
|
|
390
|
+
expanded?: boolean;
|
|
381
391
|
/**
|
|
382
392
|
* Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
|
|
383
393
|
*/
|
|
@@ -446,10 +456,15 @@ export interface AddressElementCreateOptions {
|
|
|
446
456
|
*/
|
|
447
457
|
defaultValues?: { name?: string | undefined; address?: { name?: string | undefined; first_name?: string | undefined; last_name?: string | undefined; organization?: string | undefined; organization_type?: "business" | "individual" | undefined; line1?: string | undefined; line2?: string | undefined; city?: string | undefined; state?: string | undefined; postal_code?: string | undefined; country?: string | undefined; } | undefined; };
|
|
448
458
|
/**
|
|
449
|
-
* `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border.
|
|
459
|
+
* `full` (default) stacks labeled fields. `compact` groups placeholder-labeled fields within one border. `wrap` keeps `full`'s separate fields and also puts city, state and postal code side by side. Those and the pairs `full` already sets side by side (first and last name, organization) fit as many to a row as the width allows and wrap as it narrows.
|
|
450
460
|
* @default "full"
|
|
451
461
|
*/
|
|
452
|
-
layout?: "full" | "compact";
|
|
462
|
+
layout?: "full" | "compact" | "wrap";
|
|
463
|
+
/**
|
|
464
|
+
* `above` (default) keeps each label outside its field: above it in the `full` layout, as its placeholder in `compact`. `floating` uses each label as the placeholder of its field, in either layout, then shows a small label above the typed text once the field has a value.
|
|
465
|
+
* @default "above"
|
|
466
|
+
*/
|
|
467
|
+
labelMode?: "above" | "floating";
|
|
453
468
|
/**
|
|
454
469
|
* `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`.
|
|
455
470
|
* @default "full"
|
|
@@ -474,6 +489,11 @@ export interface AddressElementCreateOptions {
|
|
|
474
489
|
* @default true
|
|
475
490
|
*/
|
|
476
491
|
autocomplete?: boolean;
|
|
492
|
+
/**
|
|
493
|
+
* Shows every address field from the start. By default (`false`) the form opens with the street address and reveals the rest once the buyer picks a suggestion, types an address, or chooses to enter it manually.
|
|
494
|
+
* @default false
|
|
495
|
+
*/
|
|
496
|
+
expanded?: boolean;
|
|
477
497
|
/**
|
|
478
498
|
* Additional fields rendered with the address form. Values are validated and emitted in the separate `custom` map.
|
|
479
499
|
*/
|
|
@@ -575,13 +595,18 @@ export interface EmailElementProps {
|
|
|
575
595
|
* @default true
|
|
576
596
|
*/
|
|
577
597
|
label?: boolean;
|
|
598
|
+
/**
|
|
599
|
+
* `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
|
+
* @default "above"
|
|
601
|
+
*/
|
|
602
|
+
labelMode?: "above" | "floating";
|
|
578
603
|
/**
|
|
579
604
|
* Seed value applied once at mount.
|
|
580
605
|
* @default ""
|
|
581
606
|
*/
|
|
582
607
|
defaultValue?: string;
|
|
583
608
|
/**
|
|
584
|
-
* Placeholder text for the email input. Empty (default) renders `you@example.com`.
|
|
609
|
+
* Placeholder text for the email input. Empty (default) renders `you@example.com`. With floating labels the label text is the placeholder instead.
|
|
585
610
|
* @default ""
|
|
586
611
|
*/
|
|
587
612
|
placeholder?: string;
|
|
@@ -621,13 +646,18 @@ export interface EmailElementCreateOptions {
|
|
|
621
646
|
* @default true
|
|
622
647
|
*/
|
|
623
648
|
label?: boolean;
|
|
649
|
+
/**
|
|
650
|
+
* `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
|
+
* @default "above"
|
|
652
|
+
*/
|
|
653
|
+
labelMode?: "above" | "floating";
|
|
624
654
|
/**
|
|
625
655
|
* Seed value applied once at mount.
|
|
626
656
|
* @default ""
|
|
627
657
|
*/
|
|
628
658
|
defaultValue?: string;
|
|
629
659
|
/**
|
|
630
|
-
* Placeholder text for the email input. Empty (default) renders `you@example.com`.
|
|
660
|
+
* Placeholder text for the email input. Empty (default) renders `you@example.com`. With floating labels the label text is the placeholder instead.
|
|
631
661
|
* @default ""
|
|
632
662
|
*/
|
|
633
663
|
placeholder?: string;
|
|
@@ -997,6 +1027,7 @@ export interface PaymentRequestResourceOptions {
|
|
|
997
1027
|
currency: string;
|
|
998
1028
|
/**
|
|
999
1029
|
* Payment amount in minor units.
|
|
1030
|
+
* Change it later with `update()`.
|
|
1000
1031
|
*/
|
|
1001
1032
|
amount: number;
|
|
1002
1033
|
/**
|
|
@@ -1018,16 +1049,31 @@ export interface PaymentRequestResourceOptions {
|
|
|
1018
1049
|
* @default false
|
|
1019
1050
|
*/
|
|
1020
1051
|
requestShipping?: boolean;
|
|
1052
|
+
/**
|
|
1053
|
+
* Offer the sheet's own promo code field and answer `onPromoCodeChange`. Apple Pay shows the field on devices that support Apple Pay version 12 (iOS 15 and macOS 12); Google Pay shows it where the account's Google Pay setup allows offers. Other devices open the sheet without it.
|
|
1054
|
+
* @default false
|
|
1055
|
+
*/
|
|
1056
|
+
requestPromoCode?: boolean;
|
|
1057
|
+
/**
|
|
1058
|
+
* A promo code already applied to the charge, prefilled into the sheet so the buyer can see or remove it.
|
|
1059
|
+
*/
|
|
1060
|
+
appliedPromoCode?: string;
|
|
1061
|
+
/**
|
|
1062
|
+
* What `appliedPromoCode` does, shown next to the code where the sheet captions applied codes (Google Pay).
|
|
1063
|
+
*/
|
|
1064
|
+
appliedPromoDescription?: string;
|
|
1021
1065
|
/**
|
|
1022
1066
|
* Account ISO 3166-1 alpha-2 country code for the Apple Pay sheet. Omit it to use the account's published registration country. The sheet defaults to `US` when neither is available.
|
|
1023
1067
|
*/
|
|
1024
1068
|
countryCode?: string;
|
|
1025
1069
|
/**
|
|
1026
1070
|
* Line items the sheet lists under the total.
|
|
1071
|
+
* Change it later with `update()`.
|
|
1027
1072
|
*/
|
|
1028
1073
|
lineItems?: PaymentRequestLineItem[];
|
|
1029
1074
|
/**
|
|
1030
1075
|
* Shipping options the sheet offers when `requestShipping` is set. Display-only — update `amount` from your change handler.
|
|
1076
|
+
* Change it later with `update()`.
|
|
1031
1077
|
*/
|
|
1032
1078
|
shippingOptions?: PaymentRequestShippingOption[];
|
|
1033
1079
|
}
|
|
@@ -1038,14 +1084,18 @@ export interface PaymentRequestResourceOptions {
|
|
|
1038
1084
|
*/
|
|
1039
1085
|
export interface PaymentRequestResource {
|
|
1040
1086
|
/**
|
|
1041
|
-
* 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, 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`. This primes `show()`. Always await it first.
|
|
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.
|
|
1042
1088
|
*/
|
|
1043
|
-
canMakePayment: () => Promise<WalletAvailability>;
|
|
1089
|
+
canMakePayment: (filter?: { types?: ("apple_pay" | "google_pay" | "paypal_express")[] | undefined; } | undefined) => Promise<WalletAvailability>;
|
|
1044
1090
|
/**
|
|
1045
|
-
* Open the selected wallet after awaiting `canMakePayment()`, synchronously in the press: Apple requires session creation within the gesture stack, and PayPal opens its window there — a pop-up on desktop, PayPal's in-page window when the pop-up is blocked and on mobile. Pass `email` when your page already collected one — the wallet takes it and never asks for a second. With `requestPayerEmail: false`, passing one is required, and the wallet refuses to open without it because confirmation tokens require an email.
|
|
1091
|
+
* Open the selected wallet after awaiting `canMakePayment()`, synchronously in the press: Apple requires session creation within the gesture stack, and PayPal opens its window there — a pop-up on desktop, PayPal's in-page window when the pop-up is blocked and on mobile. Pass `email` when your page already collected one — the wallet takes it and never asks for a second. With `requestPayerEmail: false`, passing one is required, and the wallet refuses to open without it because confirmation tokens require an email. While the sheet is open, `update()` throws: answer the change events to change it.
|
|
1046
1092
|
* Call synchronously during user activation. Await prerequisites first because browsers revoke activation across asynchronous steps.
|
|
1047
1093
|
*/
|
|
1048
1094
|
show: (type: "apple_pay" | "google_pay" | "paypal_express", provided?: { email?: string | undefined; } | undefined) => Promise<PaymentRequestResult>;
|
|
1095
|
+
/**
|
|
1096
|
+
* Change `amount`, `lineItems` and `shippingOptions` on this instance. Every other option is fixed at `create()`: create a new instance to change it.
|
|
1097
|
+
*/
|
|
1098
|
+
update: (patch: { amount?: number | undefined; lineItems?: PaymentRequestLineItem[] | undefined; shippingOptions?: PaymentRequestShippingOption[] | undefined; }) => void;
|
|
1049
1099
|
/**
|
|
1050
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.
|
|
1051
1101
|
* Call `updateWith(…)` exactly once per event. A handler that throws or rejects before calling it fails that update right away.
|
|
@@ -1064,6 +1114,12 @@ export interface PaymentRequestResource {
|
|
|
1064
1114
|
* Returns the unsubscribe function.
|
|
1065
1115
|
*/
|
|
1066
1116
|
onBillingAddressChange(handler: (ev: BillingAddressChangeEvent) => void): () => void;
|
|
1117
|
+
/**
|
|
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.
|
|
1119
|
+
* Call `updateWith(…)` exactly once per event. A handler that throws or rejects before calling it fails that update right away.
|
|
1120
|
+
* Returns the unsubscribe function.
|
|
1121
|
+
*/
|
|
1122
|
+
onPromoCodeChange(handler: (ev: PromoCodeChangeEvent) => void): () => void;
|
|
1067
1123
|
/**
|
|
1068
1124
|
* The sheet created a confirmation token. This is the same result that `show()` returns.
|
|
1069
1125
|
* Returns the unsubscribe function.
|
|
@@ -1144,6 +1200,30 @@ export interface PaymentsStatics {
|
|
|
1144
1200
|
paymentRequest: { create(options: PaymentRequestResourceOptions): PaymentRequestResource };
|
|
1145
1201
|
}
|
|
1146
1202
|
|
|
1203
|
+
/**
|
|
1204
|
+
* Declared from the app's `WalletButtonArt`, referenced by a host-capability surface.
|
|
1205
|
+
*/
|
|
1206
|
+
export interface WalletButtonArt {
|
|
1207
|
+
/**
|
|
1208
|
+
* For light pages.
|
|
1209
|
+
*/
|
|
1210
|
+
light: { color: string; image: string; };
|
|
1211
|
+
/**
|
|
1212
|
+
* For dark pages.
|
|
1213
|
+
*/
|
|
1214
|
+
dark: { color: string; image: string; };
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
/**
|
|
1218
|
+
* Declared from the app's `WalletDetails`, referenced by a host-capability surface.
|
|
1219
|
+
*/
|
|
1220
|
+
export interface WalletDetails {
|
|
1221
|
+
/**
|
|
1222
|
+
* The wallet's official button art. Absent when none is published.
|
|
1223
|
+
*/
|
|
1224
|
+
button?: WalletButtonArt | undefined;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1147
1227
|
/**
|
|
1148
1228
|
* Host-probed wallet availability after checking offered methods, device capability, and Google Pay origin approval.
|
|
1149
1229
|
* Declared from the app's `WalletAvailability`, referenced by a host-capability surface.
|
|
@@ -1156,6 +1236,10 @@ export interface WalletAvailability {
|
|
|
1156
1236
|
* The wallets ranked by which sheet is native to this browser — Apple Pay first on WebKit, Google Pay first everywhere else, PayPal last — so express buttons can stack best-first. Absent on consumer-stated availability (previews) and on wires that predate it. An inline union, not payment-request's WalletSheetType: that module already imports this one.
|
|
1157
1237
|
*/
|
|
1158
1238
|
order?: ("apple_pay" | "google_pay" | "paypal_express")[] | undefined;
|
|
1239
|
+
/**
|
|
1240
|
+
* Each available wallet's details, keyed by wallet type. Absent on consumer-stated availability (previews).
|
|
1241
|
+
*/
|
|
1242
|
+
wallets?: { apple_pay?: WalletDetails | undefined; google_pay?: WalletDetails | undefined; paypal_express?: WalletDetails | undefined; } | undefined;
|
|
1159
1243
|
}
|
|
1160
1244
|
|
|
1161
1245
|
/**
|
|
@@ -1274,7 +1358,39 @@ export interface BillingAddressChangeEvent {
|
|
|
1274
1358
|
*/
|
|
1275
1359
|
address: PaymentRequestAddress;
|
|
1276
1360
|
/**
|
|
1277
|
-
* Call this exactly once. An event left unanswered
|
|
1361
|
+
* Call this exactly once. An event left unanswered for 10 seconds refuses the card, and the buyer picks another one.
|
|
1278
1362
|
*/
|
|
1279
1363
|
updateWith: (update: PaymentRequestUpdate) => void;
|
|
1280
1364
|
}
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* Declared from the app's `PromoCodeUpdate`, referenced by a host-capability surface.
|
|
1368
|
+
*/
|
|
1369
|
+
export interface PromoCodeUpdate {
|
|
1370
|
+
/**
|
|
1371
|
+
* The total under the code, in minor units.
|
|
1372
|
+
*/
|
|
1373
|
+
amount?: number | undefined;
|
|
1374
|
+
/**
|
|
1375
|
+
* A caption for the applied code, where the sheet captions codes (Google Pay).
|
|
1376
|
+
*/
|
|
1377
|
+
appliedDescription?: string | undefined;
|
|
1378
|
+
/**
|
|
1379
|
+
* Refuses the code. The sheet shows `message` next to its promo field.
|
|
1380
|
+
*/
|
|
1381
|
+
error?: { message: string; } | undefined;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* Declared from the app's `PromoCodeChangeEvent`, referenced by a host-capability surface.
|
|
1386
|
+
*/
|
|
1387
|
+
export interface PromoCodeChangeEvent {
|
|
1388
|
+
/**
|
|
1389
|
+
* The code now in the sheet's promo field, or null when the buyer removed it.
|
|
1390
|
+
*/
|
|
1391
|
+
code: string | null;
|
|
1392
|
+
/**
|
|
1393
|
+
* Answer exactly once: `error` refuses the code and keeps the totals, and any other answer applies it. `amount` reprices 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.
|
|
1394
|
+
*/
|
|
1395
|
+
updateWith: (update: PromoCodeUpdate) => void;
|
|
1396
|
+
}
|