@whop/elements 1.0.0-beta.4 → 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/checkout.d.cts +48 -9
- package/checkout.d.ts +48 -9
- package/dashboard.d.cts +328 -0
- package/dashboard.d.ts +328 -0
- package/index.d.cts +7 -2
- package/index.d.ts +7 -2
- package/package.json +10 -2
- package/payments.d.cts +29 -163
- package/payments.d.ts +29 -163
- package/verifications.d.cts +1 -1
- package/verifications.d.ts +1 -1
- package/wallet.d.cts +4 -4
- package/wallet.d.ts +4 -4
package/dashboard.d.ts
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for `whop.dashboard.create()`: the controller's props plus its `on<Event>` callbacks. In React, these are the `<Dashboard>` component's props.
|
|
3
|
+
* @example
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { loadWhop } from "@whop/elements";
|
|
6
|
+
*
|
|
7
|
+
* const whop = (await loadWhop())({ locale: "en" });
|
|
8
|
+
* const dashboard = whop.dashboard.create({}); // options: props + on<Event> callbacks
|
|
9
|
+
* ```
|
|
10
|
+
* @see https://docs.whop.com/elements/latest/dashboard/overview
|
|
11
|
+
*/
|
|
12
|
+
export interface DashboardOptions {
|
|
13
|
+
/**
|
|
14
|
+
* A scoped token every surface under this handle reads with. Mint one token for the whole handle on your server with `POST /api/v1/access_tokens`, and set a fresh one with `update({ accessToken })` before it expires. Reading payments needs `payment:basic:read`; buyer emails additionally need `member:email:read`, the customer journey `member:basic:read`, the tracking column `shipment:basic:read`, and the product and plan names on a payment `access_pass:basic:read` and `plan:basic:read`. Omitted, the reads carry the viewer's own session, which only answers same-origin.
|
|
15
|
+
*/
|
|
16
|
+
accessToken?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Account ID, prefixed `biz_`, whose payments these surfaces read.
|
|
19
|
+
*/
|
|
20
|
+
accountId: string;
|
|
21
|
+
/**
|
|
22
|
+
* Runs when the grouped loading state changes. The value is `true` while any mounted element is still loading.
|
|
23
|
+
*/
|
|
24
|
+
onLoadingChange?: ((loading: boolean) => void);
|
|
25
|
+
/**
|
|
26
|
+
* Set `false` to turn off Whop's built-in usage analytics for this handle and its elements. The analytics identity is never threaded to its frames. A reserved option, not element data.
|
|
27
|
+
*/
|
|
28
|
+
analytics?: false;
|
|
29
|
+
/**
|
|
30
|
+
* Visual customization for this group's elements. Overrides the global `WhopElements({ appearance })`. Change it live with `update({ appearance })`.
|
|
31
|
+
*/
|
|
32
|
+
appearance?: import("./_framework.js").Appearance;
|
|
33
|
+
/**
|
|
34
|
+
* Locale for this group's element UI text. Set it to one of the app's built locales to override the global configuration. Any other value falls back to the default locale.
|
|
35
|
+
*/
|
|
36
|
+
locale?: import("./_framework.js").WhopElementsLocale;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Consumer props for the "paymentsTable" element. Set at create (or as `<PaymentsTableElement />` JSX props), and updatable live via `update()`.
|
|
41
|
+
* @see https://docs.whop.com/elements/latest/dashboard/paymentsTable
|
|
42
|
+
*/
|
|
43
|
+
export interface PaymentsTableElementProps {
|
|
44
|
+
/**
|
|
45
|
+
* Show the header action menu, Export button, and table settings button.
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
showActions?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Show the three-dot action menu on each payment row.
|
|
51
|
+
* @default true
|
|
52
|
+
*/
|
|
53
|
+
showRowActions?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Show the six payment status boxes above the filters.
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
showStatusTabs?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Show the tracking column and filter for physical-product accounts. Tracking data requires `shipment:basic:read`.
|
|
61
|
+
* @default true
|
|
62
|
+
*/
|
|
63
|
+
showTracking?: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The live handle for a mounted "paymentsTable" element. Returned by `create("paymentsTable")`; in React, the component's `ref`.
|
|
68
|
+
* @see https://docs.whop.com/elements/latest/dashboard/paymentsTable
|
|
69
|
+
*/
|
|
70
|
+
export interface PaymentsTableElementHandle {
|
|
71
|
+
/**
|
|
72
|
+
* Reload payments after a refund or another change.
|
|
73
|
+
*/
|
|
74
|
+
refresh: () => Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Mounts the element in `target` and starts loading. React components mount themselves.
|
|
77
|
+
*/
|
|
78
|
+
mount: (target: string | HTMLElement) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
|
|
81
|
+
*/
|
|
82
|
+
destroy: () => void;
|
|
83
|
+
/**
|
|
84
|
+
* Merges new props into the mounted element. In React, change the component props instead.
|
|
85
|
+
*/
|
|
86
|
+
update: (options: Partial<PaymentsTableElementProps>) => void;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Options for `create("paymentsTable")`: the consumer props plus event callbacks and lifecycle hooks.
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* const paymentsTable = dashboard.create("paymentsTable", {}); // this interface: props + on<Event> callbacks
|
|
94
|
+
* paymentsTable.mount("#dashboard-paymentsTable");
|
|
95
|
+
* ```
|
|
96
|
+
* @see https://docs.whop.com/elements/latest/dashboard/paymentsTable
|
|
97
|
+
*/
|
|
98
|
+
export interface PaymentsTableElementCreateOptions {
|
|
99
|
+
/**
|
|
100
|
+
* Show the header action menu, Export button, and table settings button.
|
|
101
|
+
* @default true
|
|
102
|
+
*/
|
|
103
|
+
showActions?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Show the three-dot action menu on each payment row.
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
showRowActions?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Show the six payment status boxes above the filters.
|
|
111
|
+
* @default true
|
|
112
|
+
*/
|
|
113
|
+
showStatusTabs?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Show the tracking column and filter for physical-product accounts. Tracking data requires `shipment:basic:read`.
|
|
116
|
+
* @default true
|
|
117
|
+
*/
|
|
118
|
+
showTracking?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Open payment details in your application.
|
|
121
|
+
*/
|
|
122
|
+
onPaymentSelected?: ((payload: { paymentId: string; }) => void);
|
|
123
|
+
/**
|
|
124
|
+
* Open the invoice in your application.
|
|
125
|
+
*/
|
|
126
|
+
onInvoiceRequested?: ((payload: { paymentId: string; }) => void);
|
|
127
|
+
/**
|
|
128
|
+
* Open the buyer in your application.
|
|
129
|
+
*/
|
|
130
|
+
onUserSelected?: ((payload: { userId: string; }) => void);
|
|
131
|
+
/**
|
|
132
|
+
* The viewer requested a refund. Your application must confirm and authorize it server-side. Refund controls are enabled only when this callback is provided.
|
|
133
|
+
*/
|
|
134
|
+
onRefundRequested?: ((payload: { paymentIds: string[]; }) => void);
|
|
135
|
+
/**
|
|
136
|
+
* Open the account’s payment settings in your application.
|
|
137
|
+
*/
|
|
138
|
+
onSettingsRequested?: ((payload: Record<string, never>) => void);
|
|
139
|
+
/**
|
|
140
|
+
* Runs after the loading skeleton first paints and before `onReady`.
|
|
141
|
+
*/
|
|
142
|
+
onLoaderStart?: (() => void);
|
|
143
|
+
/**
|
|
144
|
+
* Runs after the element's first complete paint.
|
|
145
|
+
*/
|
|
146
|
+
onReady?: (() => void);
|
|
147
|
+
/**
|
|
148
|
+
* Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
|
|
149
|
+
*/
|
|
150
|
+
onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Consumer props for the "paymentDetail" element. Set at create (or as `<PaymentDetailElement />` JSX props), and updatable live via `update()`.
|
|
155
|
+
* @see https://docs.whop.com/elements/latest/dashboard/paymentDetail
|
|
156
|
+
*/
|
|
157
|
+
export interface PaymentDetailElementProps {
|
|
158
|
+
/**
|
|
159
|
+
* Show the top-right Refund button and action menu. Mutating actions require event handlers.
|
|
160
|
+
* @default true
|
|
161
|
+
*/
|
|
162
|
+
showActions?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* The payment to display, prefixed pay_. Required to load a payment.
|
|
165
|
+
* @default ""
|
|
166
|
+
*/
|
|
167
|
+
paymentId?: string;
|
|
168
|
+
/**
|
|
169
|
+
* Show the payment amount, fees, and net amount.
|
|
170
|
+
* @default true
|
|
171
|
+
*/
|
|
172
|
+
showBreakdown?: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Show the payment activity timeline.
|
|
175
|
+
* @default true
|
|
176
|
+
*/
|
|
177
|
+
showActivity?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Show customer name, username, email, phone, and billing address when permitted.
|
|
180
|
+
* @default true
|
|
181
|
+
*/
|
|
182
|
+
showCustomer?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Show product, plan, payment method, and payment identifiers.
|
|
185
|
+
* @default true
|
|
186
|
+
*/
|
|
187
|
+
showDetails?: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Show the customer journey. Reads the account-scoped Events API only while visible.
|
|
190
|
+
* @default true
|
|
191
|
+
*/
|
|
192
|
+
showJourney?: boolean;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The live handle for a mounted "paymentDetail" element. Returned by `create("paymentDetail")`; in React, the component's `ref`.
|
|
197
|
+
* @see https://docs.whop.com/elements/latest/dashboard/paymentDetail
|
|
198
|
+
*/
|
|
199
|
+
export interface PaymentDetailElementHandle {
|
|
200
|
+
/**
|
|
201
|
+
* Reload the payment and its fees after a host action completes.
|
|
202
|
+
*/
|
|
203
|
+
refresh: () => Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Mounts the element in `target` and starts loading. React components mount themselves.
|
|
206
|
+
*/
|
|
207
|
+
mount: (target: string | HTMLElement) => void;
|
|
208
|
+
/**
|
|
209
|
+
* Removes the element and releases its frame and subscriptions. You can call it more than once. React removes the element automatically.
|
|
210
|
+
*/
|
|
211
|
+
destroy: () => void;
|
|
212
|
+
/**
|
|
213
|
+
* Merges new props into the mounted element. In React, change the component props instead.
|
|
214
|
+
*/
|
|
215
|
+
update: (options: Partial<PaymentDetailElementProps>) => void;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Options for `create("paymentDetail")`: the consumer props plus event callbacks and lifecycle hooks.
|
|
220
|
+
* @example
|
|
221
|
+
* ```ts
|
|
222
|
+
* const paymentDetail = dashboard.create("paymentDetail", {}); // this interface: props + on<Event> callbacks
|
|
223
|
+
* paymentDetail.mount("#dashboard-paymentDetail");
|
|
224
|
+
* ```
|
|
225
|
+
* @see https://docs.whop.com/elements/latest/dashboard/paymentDetail
|
|
226
|
+
*/
|
|
227
|
+
export interface PaymentDetailElementCreateOptions {
|
|
228
|
+
/**
|
|
229
|
+
* Show the top-right Refund button and action menu. Mutating actions require event handlers.
|
|
230
|
+
* @default true
|
|
231
|
+
*/
|
|
232
|
+
showActions?: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* The payment to display, prefixed pay_. Required to load a payment.
|
|
235
|
+
* @default ""
|
|
236
|
+
*/
|
|
237
|
+
paymentId?: string;
|
|
238
|
+
/**
|
|
239
|
+
* Show the payment amount, fees, and net amount.
|
|
240
|
+
* @default true
|
|
241
|
+
*/
|
|
242
|
+
showBreakdown?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Show the payment activity timeline.
|
|
245
|
+
* @default true
|
|
246
|
+
*/
|
|
247
|
+
showActivity?: boolean;
|
|
248
|
+
/**
|
|
249
|
+
* Show customer name, username, email, phone, and billing address when permitted.
|
|
250
|
+
* @default true
|
|
251
|
+
*/
|
|
252
|
+
showCustomer?: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Show product, plan, payment method, and payment identifiers.
|
|
255
|
+
* @default true
|
|
256
|
+
*/
|
|
257
|
+
showDetails?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Show the customer journey. Reads the account-scoped Events API only while visible.
|
|
260
|
+
* @default true
|
|
261
|
+
*/
|
|
262
|
+
showJourney?: boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Confirm and authorize a refund in your application. Enabled only when refundable and a handler is provided.
|
|
265
|
+
*/
|
|
266
|
+
onRefundRequested?: ((payload: { paymentId: string; }) => void);
|
|
267
|
+
/**
|
|
268
|
+
* Confirm and authorize another charge attempt in your application.
|
|
269
|
+
*/
|
|
270
|
+
onRetryRequested?: ((payload: { paymentId: string; }) => void);
|
|
271
|
+
/**
|
|
272
|
+
* Confirm and authorize voiding this payment in your application.
|
|
273
|
+
*/
|
|
274
|
+
onVoidRequested?: ((payload: { paymentId: string; }) => void);
|
|
275
|
+
/**
|
|
276
|
+
* View or download the invoice in your application.
|
|
277
|
+
*/
|
|
278
|
+
onInvoiceRequested?: ((payload: { paymentId: string; }) => void);
|
|
279
|
+
/**
|
|
280
|
+
* Open the customer in your application.
|
|
281
|
+
*/
|
|
282
|
+
onCustomerSelected?: ((payload: { userId: string; memberId: string | null; }) => void);
|
|
283
|
+
/**
|
|
284
|
+
* Open your customer messaging UI.
|
|
285
|
+
*/
|
|
286
|
+
onMessageRequested?: ((payload: { userId: string; }) => void);
|
|
287
|
+
/**
|
|
288
|
+
* Runs after the loading skeleton first paints and before `onReady`.
|
|
289
|
+
*/
|
|
290
|
+
onLoaderStart?: (() => void);
|
|
291
|
+
/**
|
|
292
|
+
* Runs after the element's first complete paint.
|
|
293
|
+
*/
|
|
294
|
+
onReady?: (() => void);
|
|
295
|
+
/**
|
|
296
|
+
* Runs when the element fails to load or crashes. The fallback remains visible. Use `code` for programmatic handling. `sourceKey` identifies a failed host-state source.
|
|
297
|
+
*/
|
|
298
|
+
onError?: ((e: { message: string; code?: string | undefined; sourceKey?: string | undefined; }) => void);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* The Dashboard handle, returned by `whop.dashboard.create()` (React: `useDashboard()`). Mounts the elements and carries the controller's actions.
|
|
303
|
+
* @see https://docs.whop.com/elements/latest/dashboard/overview
|
|
304
|
+
*/
|
|
305
|
+
export interface DashboardHandle {
|
|
306
|
+
/**
|
|
307
|
+
* The dashboard payments table with status cards, search, filters, sorting, row selection, CSV export, column settings, and pagination. Reads all payment pages to compute complete counts and filter locally; intended for accounts with modest payment histories. Customer details and refunds are handed to your application through events.
|
|
308
|
+
*/
|
|
309
|
+
create(name: "paymentsTable", options?: PaymentsTableElementCreateOptions): PaymentsTableElementHandle;
|
|
310
|
+
/**
|
|
311
|
+
* A payment detail page with the dashboard breakdown, activity, customer, details, and customer journey. Each section can be hidden. Reads payment:basic:read; customer email needs member:email:read and journey needs member:basic:read. Action events let your application confirm and authorize changes; this element never refunds, retries, or voids a payment itself.
|
|
312
|
+
*/
|
|
313
|
+
create(name: "paymentDetail", options?: PaymentDetailElementCreateOptions): PaymentDetailElementHandle;
|
|
314
|
+
/**
|
|
315
|
+
* Merges new handle options into every mounted element. In React, change the namespace props instead.
|
|
316
|
+
*/
|
|
317
|
+
update(options: Partial<DashboardOptions>): void;
|
|
318
|
+
/**
|
|
319
|
+
* Destroys every element and sub-controller this handle created, removes the controller frame, and releases its subscriptions. You can call it more than once, but a destroyed handle refuses any other call — create a new handle to start over. React removes the group automatically when the provider unmounts.
|
|
320
|
+
*/
|
|
321
|
+
destroy(): void;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Dashboard's static actions, callable with nothing mounted: `whop.dashboard.<method>()` (React: `useWhop().dashboard.<method>()`).
|
|
326
|
+
* @see https://docs.whop.com/elements/latest/dashboard/overview
|
|
327
|
+
*/
|
|
328
|
+
export interface DashboardStatics {}
|
package/index.d.cts
CHANGED
|
@@ -6,6 +6,7 @@ import type { AdsHandle, AdsOptions, AdsStatics } from "./ads.js";
|
|
|
6
6
|
import type { TrackingHandle, TrackingOptions, TrackingStatics } from "./tracking.js";
|
|
7
7
|
import type { WalletHandle, WalletOptions, WalletStatics } from "./wallet.js";
|
|
8
8
|
import type { WebsitesHandle, WebsitesOptions, WebsitesStatics } from "./websites.js";
|
|
9
|
+
import type { DashboardHandle, DashboardOptions, DashboardStatics } from "./dashboard.js";
|
|
9
10
|
|
|
10
11
|
/** Global configuration for `WhopElements(config)`, inherited by every namespace handle (`appearance`, `locale`, …). */
|
|
11
12
|
export interface WhopGlobalConfig extends FrameworkGlobals {}
|
|
@@ -13,7 +14,7 @@ export interface WhopGlobalConfig extends FrameworkGlobals {}
|
|
|
13
14
|
/** The configured instance: one accessor per namespace, each carrying `create()` plus that namespace's static actions. */
|
|
14
15
|
export interface Whop {
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Collect a payment from a `plan_` ID or inline currency and amount, or save a payment method without charging with `mode: "setup"`. Mount PaymentElement, CardElement, or CardFields, then call `payments.createConfirmationToken` with billing details. Wallet selections open their sheet automatically. Confirm the token server-side, then pass the payment's or setup intent's `client_secret` to `handleNextAction` for any pending step.
|
|
17
18
|
*/
|
|
18
19
|
payments: { create(options: PaymentsOptions): PaymentsHandle } & PaymentsStatics;
|
|
19
20
|
/**
|
|
@@ -21,7 +22,7 @@ export interface Whop {
|
|
|
21
22
|
*/
|
|
22
23
|
verifications: { create(options: VerificationsOptions): VerificationsHandle } & VerificationsStatics;
|
|
23
24
|
/**
|
|
24
|
-
* Drives a full hosted checkout for one
|
|
25
|
+
* Drives a full hosted checkout for one or more plans — itemized price summary, promo codes, the currency the buyer pays in, and the whole payment collection surface (the payments elements, composed inside) — against the Whop checkout sessions API. Mount it with `items`, a single `plan`, or a `checkoutConfiguration` you authored and the element opens the checkout session itself; the session credential never leaves the element. A setup-mode checkout configuration mounts the same element as a payment-method save: nothing is charged, the buyer’s method is stored for you to charge later, and the finished checkout redirects with `setup_intent_id`. The buyer pays inside the element, and a finished checkout redirects the current tab to `returnUrl`, including the page that contains the element. Fulfill from webhooks rather than a browser callback. Without a `returnUrl`, the buyer rests on the element’s own success face. The element automatically drives an off-site payment step, such as 3DS or a bank page. On whop.com, it brings the buyer back into the restored checkout; in an embed, the buyer returns to the same `returnUrl`. A failed payment reopens the same checkout with the reason shown, so the buyer can pay again. Every option is set at creation: the element mints a checkout session from these values when it mounts. Changing one later with `update()` or new React props fails instead of changing the existing order. Mount a new checkout to change what is being purchased.
|
|
25
26
|
*/
|
|
26
27
|
checkout: { create(options: CheckoutOptions): CheckoutHandle } & CheckoutStatics;
|
|
27
28
|
/**
|
|
@@ -40,6 +41,10 @@ export interface Whop {
|
|
|
40
41
|
* An account's websites: every site built on whop.site plus every domain the Whop Pixel reports, with traffic and attributed revenue per domain. Mount `websites` and it lists them with visitors, page views, sales, revenue, trend, and most-viewed pages. Mount `pixel-setup` alongside it and a site whose pixel the wizard just proved live gets a waiting row automatically, because its first events take a few minutes to reach the stats API and the site would otherwise look lost — you wire nothing up for that, and the row is kept on your page so it is still there if the merchant reloads. Reading stats is privileged, so it needs an `accessToken` — except inside Whop's own app, where the viewer's session carries the read.
|
|
41
42
|
*/
|
|
42
43
|
websites: { create(options: WebsitesOptions): WebsitesHandle } & WebsitesStatics;
|
|
44
|
+
/**
|
|
45
|
+
* An account's own payment records, embedded on your site. Scope it to an account with `accountId`, then mount `paymentsTable` for the account's payments and `paymentDetail` for one payment. Both read with the same credential, so two surfaces side by side always show the same account.
|
|
46
|
+
*/
|
|
47
|
+
dashboard: { create(options: DashboardOptions): DashboardHandle } & DashboardStatics;
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
/** The global `window.WhopElements`. Call it with the global config to get a `Whop` instance. */
|
package/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { AdsHandle, AdsOptions, AdsStatics } from "./ads.js";
|
|
|
6
6
|
import type { TrackingHandle, TrackingOptions, TrackingStatics } from "./tracking.js";
|
|
7
7
|
import type { WalletHandle, WalletOptions, WalletStatics } from "./wallet.js";
|
|
8
8
|
import type { WebsitesHandle, WebsitesOptions, WebsitesStatics } from "./websites.js";
|
|
9
|
+
import type { DashboardHandle, DashboardOptions, DashboardStatics } from "./dashboard.js";
|
|
9
10
|
|
|
10
11
|
/** Global configuration for `WhopElements(config)`, inherited by every namespace handle (`appearance`, `locale`, …). */
|
|
11
12
|
export interface WhopGlobalConfig extends FrameworkGlobals {}
|
|
@@ -13,7 +14,7 @@ export interface WhopGlobalConfig extends FrameworkGlobals {}
|
|
|
13
14
|
/** The configured instance: one accessor per namespace, each carrying `create()` plus that namespace's static actions. */
|
|
14
15
|
export interface Whop {
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Collect a payment from a `plan_` ID or inline currency and amount, or save a payment method without charging with `mode: "setup"`. Mount PaymentElement, CardElement, or CardFields, then call `payments.createConfirmationToken` with billing details. Wallet selections open their sheet automatically. Confirm the token server-side, then pass the payment's or setup intent's `client_secret` to `handleNextAction` for any pending step.
|
|
17
18
|
*/
|
|
18
19
|
payments: { create(options: PaymentsOptions): PaymentsHandle } & PaymentsStatics;
|
|
19
20
|
/**
|
|
@@ -21,7 +22,7 @@ export interface Whop {
|
|
|
21
22
|
*/
|
|
22
23
|
verifications: { create(options: VerificationsOptions): VerificationsHandle } & VerificationsStatics;
|
|
23
24
|
/**
|
|
24
|
-
* Drives a full hosted checkout for one
|
|
25
|
+
* Drives a full hosted checkout for one or more plans — itemized price summary, promo codes, the currency the buyer pays in, and the whole payment collection surface (the payments elements, composed inside) — against the Whop checkout sessions API. Mount it with `items`, a single `plan`, or a `checkoutConfiguration` you authored and the element opens the checkout session itself; the session credential never leaves the element. A setup-mode checkout configuration mounts the same element as a payment-method save: nothing is charged, the buyer’s method is stored for you to charge later, and the finished checkout redirects with `setup_intent_id`. The buyer pays inside the element, and a finished checkout redirects the current tab to `returnUrl`, including the page that contains the element. Fulfill from webhooks rather than a browser callback. Without a `returnUrl`, the buyer rests on the element’s own success face. The element automatically drives an off-site payment step, such as 3DS or a bank page. On whop.com, it brings the buyer back into the restored checkout; in an embed, the buyer returns to the same `returnUrl`. A failed payment reopens the same checkout with the reason shown, so the buyer can pay again. Every option is set at creation: the element mints a checkout session from these values when it mounts. Changing one later with `update()` or new React props fails instead of changing the existing order. Mount a new checkout to change what is being purchased.
|
|
25
26
|
*/
|
|
26
27
|
checkout: { create(options: CheckoutOptions): CheckoutHandle } & CheckoutStatics;
|
|
27
28
|
/**
|
|
@@ -40,6 +41,10 @@ export interface Whop {
|
|
|
40
41
|
* An account's websites: every site built on whop.site plus every domain the Whop Pixel reports, with traffic and attributed revenue per domain. Mount `websites` and it lists them with visitors, page views, sales, revenue, trend, and most-viewed pages. Mount `pixel-setup` alongside it and a site whose pixel the wizard just proved live gets a waiting row automatically, because its first events take a few minutes to reach the stats API and the site would otherwise look lost — you wire nothing up for that, and the row is kept on your page so it is still there if the merchant reloads. Reading stats is privileged, so it needs an `accessToken` — except inside Whop's own app, where the viewer's session carries the read.
|
|
41
42
|
*/
|
|
42
43
|
websites: { create(options: WebsitesOptions): WebsitesHandle } & WebsitesStatics;
|
|
44
|
+
/**
|
|
45
|
+
* An account's own payment records, embedded on your site. Scope it to an account with `accountId`, then mount `paymentsTable` for the account's payments and `paymentDetail` for one payment. Both read with the same credential, so two surfaces side by side always show the same account.
|
|
46
|
+
*/
|
|
47
|
+
dashboard: { create(options: DashboardOptions): DashboardHandle } & DashboardStatics;
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
/** The global `window.WhopElements`. Call it with the global config to get a `Whop` instance. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whop/elements",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
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",
|
|
@@ -87,7 +87,15 @@
|
|
|
87
87
|
"require": {
|
|
88
88
|
"types": "./websites.d.cts"
|
|
89
89
|
}
|
|
90
|
+
},
|
|
91
|
+
"./dashboard": {
|
|
92
|
+
"import": {
|
|
93
|
+
"types": "./dashboard.d.ts"
|
|
94
|
+
},
|
|
95
|
+
"require": {
|
|
96
|
+
"types": "./dashboard.d.cts"
|
|
97
|
+
}
|
|
90
98
|
}
|
|
91
99
|
},
|
|
92
|
-
"whopElementsApiHash": "
|
|
100
|
+
"whopElementsApiHash": "b06bb1fdc85f1e9ccbd1186c186a6a1b106a8f59293e7ee7a7f6275f81ba3cd0"
|
|
93
101
|
}
|