@base44-preview/sdk 0.8.63-pr.392.a02dae3 → 0.8.63-pr.393.32eac0e

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/dist/index.d.ts CHANGED
@@ -15,7 +15,7 @@ export type { AppModule, AppPublicSettings, AppPublicSettingsResponse, } from ".
15
15
  export type { McpModule, McpConsentAction, McpConsentInfo, McpConsentResponse, McpConsentTool, } from "./modules/mcp.types.js";
16
16
  export type { ActorsModule, ActorClient, ActorRef, Connection, ActorSubscription, ActorConnectOptions, ActorNameRegistry, ActorRegistry, ActorConnectable, ActorMethods, ServiceRoleActorRef, ServiceRoleActorsModule, } from "./modules/actors.types.js";
17
17
  export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
18
- export type { PaymentsModule, ServiceRolePaymentsModule, PaymentsErrorCode, PaymentsRecurringFrequency, CheckoutBuyer, CheckoutFreeTrial, CheckoutItem, CheckoutItemRecurring, CheckoutPresentation, CheckoutShipping, CheckoutElement, CheckoutMount, MountableCheckout, CreateCheckoutParams, CreateCheckoutResult, CompleteCheckoutResult, EmbeddedCheckout, PayPalCheckoutOnClick, PayPalEmbeddedCheckout, StripeEmbeddedCheckout, WixEmbeddedCheckout, MountCheckoutOptions, ListPurchasesParams, ServiceRoleListPurchasesParams, ListPurchasesResult, Purchase, PurchaseItem, PurchaseStatus, RefundParams, ShippingAddress, RefundResult, CancelSubscriptionOptions, SubscriptionResult, } from "./modules/payments.types.js";
18
+ export type { PaymentsModule, ServiceRolePaymentsModule, PaymentsErrorCode, PaymentsRecurringFrequency, CheckoutBuyer, CheckoutFreeTrial, CheckoutItem, CheckoutItemRecurring, CheckoutPresentation, CheckoutShipping, CheckoutElement, CheckoutMount, MountableCheckout, CreateCheckoutParams, CreateCheckoutResult, CompleteCheckoutResult, EmbeddedCheckout, PayPalCheckoutOnClick, PayPalEmbeddedCheckout, StripeEmbeddedCheckout, MountCheckoutOptions, ListPurchasesParams, ServiceRoleListPurchasesParams, ListPurchasesResult, Purchase, PurchaseItem, PurchaseStatus, RefundParams, ShippingAddress, RefundResult, CancelSubscriptionOptions, SubscriptionResult, } from "./modules/payments.types.js";
19
19
  export type { BrowserModule, BrowserSession, BrowserSessionOptions, } from "./modules/browser.types.js";
20
20
  export type { VoiceModule, VoiceSession, VoiceSessionMessage, VoiceSessionOptions, } from "./modules/voice.types.js";
21
21
  export { Actor, type Conn, type ActorConnectionIdentity, ActorError, type ActorCallIdentity, type ActorCallContext, } from "./actor.js";
@@ -1,4 +1,5 @@
1
1
  import type { CheckoutElement, CheckoutMount, CompleteCheckoutResult, MountableCheckout, MountCheckoutOptions, PayPalCheckoutOnClick, PayPalEmbeddedCheckout } from "./payments.types.js";
2
+ type ScriptProvider = "paypal" | "stripe" | "paddle";
2
3
  /** @internal */
3
4
  export type LoadScript = (src: string) => Promise<void>;
4
5
  /**
@@ -13,7 +14,7 @@ export interface PaymentsCheckoutConfig {
13
14
  stripe?: {
14
15
  script_url?: string;
15
16
  };
16
- wix?: {
17
+ paddle?: {
17
18
  script_url?: string;
18
19
  };
19
20
  }
@@ -33,7 +34,7 @@ export declare const loadScript: LoadScript;
33
34
  * Fetches the payments config and loads the provider's script ahead of mountCheckout().
34
35
  * @internal
35
36
  */
36
- export declare function preloadCheckout(provider: "paypal" | "stripe" | "wix", deps: Pick<MountCheckoutDeps, "getConfig" | "loadScript">): Promise<void>;
37
+ export declare function preloadCheckout(provider: ScriptProvider, deps: Pick<MountCheckoutDeps, "getConfig" | "loadScript">): Promise<void>;
37
38
  /**
38
39
  * Mounts the embedded checkout that createCheckout() returned.
39
40
  * @internal
@@ -2,8 +2,9 @@
2
2
  const ALLOWED_SCRIPT_HOSTS = {
3
3
  paypal: ["www.paypal.com", "www.sandbox.paypal.com"],
4
4
  stripe: ["js.stripe.com"],
5
- wix: ["tpa.wixapps.net"],
5
+ paddle: ["cdn.paddle.com"],
6
6
  };
7
+ const PROVIDER_NAMES = { paypal: "PayPal", stripe: "Stripe", paddle: "Paddle" };
7
8
  async function scriptUrlFor(provider, deps) {
8
9
  var _a, _b;
9
10
  const value = (_b = (_a = (await deps.getConfig())) === null || _a === void 0 ? void 0 : _a[provider]) === null || _b === void 0 ? void 0 : _b.script_url;
@@ -20,8 +21,7 @@ async function scriptUrlFor(provider, deps) {
20
21
  url.username !== "" ||
21
22
  url.password !== "" ||
22
23
  !ALLOWED_SCRIPT_HOSTS[provider].includes(url.hostname)) {
23
- const name = { paypal: "PayPal", stripe: "Stripe", wix: "Wix" }[provider];
24
- throw new Error(`The payments config has no valid ${name} script URL`);
24
+ throw new Error(`The payments config has no valid ${PROVIDER_NAMES[provider]} script URL`);
25
25
  }
26
26
  return url.href;
27
27
  }
@@ -237,70 +237,25 @@ checkout, options, deps) {
237
237
  },
238
238
  };
239
239
  }
240
- const WIX_TOKEN_URL = "https://www.wixapis.com/oauth2/token";
241
- // Renewed this long before it expires, as the Payment Element does.
242
- const WIX_TOKEN_MARGIN_MS = 60000;
243
- // One visitor per client ID for the page, so remounts and other checkouts reuse its token.
244
- const wixVisitors = new Map();
245
- async function requestWixTokens(body) {
246
- const response = await fetch(WIX_TOKEN_URL, {
247
- method: "POST",
248
- headers: { "Content-Type": "application/json" },
249
- body: JSON.stringify(body),
250
- });
251
- if (!response.ok) {
252
- throw new Error(`The Wix ${body.grantType} token request failed with status ${response.status}`);
240
+ // Paddle.js takes one token per page and reports every checkout's events to the callback set then.
241
+ let paddleToken = null;
242
+ let onPaddleEvent = null;
243
+ async function mountPaddle(element, scriptUrl, embedded, checkoutId, options, deps) {
244
+ const Paddle = await loadGlobal(scriptUrl, () => browserGlobals().Paddle, deps.loadScript);
245
+ if (paddleToken === null) {
246
+ if (embedded.environment === "sandbox")
247
+ Paddle.Environment.set("sandbox");
248
+ Paddle.Initialize({ token: embedded.client_token, eventCallback: (event) => onPaddleEvent === null || onPaddleEvent === void 0 ? void 0 : onPaddleEvent(event) });
249
+ paddleToken = embedded.client_token;
253
250
  }
254
- const data = (await response.json());
255
- return {
256
- accessToken: data.access_token,
257
- refreshToken: data.refresh_token,
258
- expiresAt: Date.now() + data.expires_in * 1000,
259
- };
260
- }
261
- async function renewWixTokens(clientId, tokens) {
262
- if (tokens) {
263
- try {
264
- return await requestWixTokens({ refresh_token: tokens.refreshToken, grantType: "refresh_token" });
265
- }
266
- catch (_a) {
267
- // The refresh token expired or was revoked, so a new visitor is minted.
268
- }
251
+ else if (paddleToken !== embedded.client_token) {
252
+ throw new Error("Paddle is already set up on this page for another seller. Reload the page to check out.");
269
253
  }
270
- return requestWixTokens({ clientId, grantType: "anonymous" });
271
- }
272
- /** Gives the Payment Element an anonymous visitor's access token for the client. */
273
- function wixVisitorAccessToken(clientId) {
274
- return async ({ renew = false } = {}) => {
275
- var _a, _b;
276
- const visitor = (_a = wixVisitors.get(clientId)) !== null && _a !== void 0 ? _a : {};
277
- wixVisitors.set(clientId, visitor);
278
- // Expired now, so other callers wait for the renewed token instead of getting this one.
279
- if (renew && visitor.tokens)
280
- visitor.tokens = { ...visitor.tokens, expiresAt: 0 };
281
- const { tokens } = visitor;
282
- if (tokens && tokens.expiresAt - WIX_TOKEN_MARGIN_MS > Date.now()) {
283
- return tokens.accessToken;
284
- }
285
- (_b = visitor.pending) !== null && _b !== void 0 ? _b : (visitor.pending = renewWixTokens(clientId, tokens)
286
- .then((renewed) => (visitor.tokens = renewed))
287
- .finally(() => (visitor.pending = undefined)));
288
- return (await visitor.pending).accessToken;
289
- };
290
- }
291
- async function mountWix(element, scriptUrl, checkoutId, clientId, options, deps) {
292
- var _a;
293
- const wpe = await loadGlobal(scriptUrl, () => browserGlobals().wpe, deps.loadScript);
294
- const locale = (((_a = document.documentElement) === null || _a === void 0 ? void 0 : _a.lang) || navigator.language || "en").split("-")[0];
295
- const getAccessToken = wixVisitorAccessToken(clientId);
296
- const paymentElement = wpe({ getAccessToken, locale }).create("checkout", {
297
- intentId: checkoutId,
298
- });
299
254
  let destroyed = false;
300
- let ready = false;
301
- let paying = false;
302
- // Set once a payment succeeds or the element rejects one: either way it refuses another.
303
- let finished = false;
255
+ let open = false;
256
+ let completing = false;
257
+ // Set once the payment goes through: the transaction is paid, so the button stays off.
258
+ let paid = false;
304
259
  const notify = (callback) => {
305
260
  if (destroyed)
306
261
  return;
@@ -311,59 +266,70 @@ async function mountWix(element, scriptUrl, checkoutId, clientId, options, deps)
311
266
  console.error("[Base44 SDK] A mountCheckout() callback threw", error);
312
267
  }
313
268
  };
314
- paymentElement.on("ready", () => {
315
- ready = true;
316
- notify(() => { var _a; return (_a = options.onReadyChange) === null || _a === void 0 ? void 0 : _a.call(options, true); });
317
- });
318
- // The element fires ready again once it recovers.
319
- paymentElement.on("loaderror", () => {
320
- ready = false;
321
- notify(() => { var _a; return (_a = options.onReadyChange) === null || _a === void 0 ? void 0 : _a.call(options, false); });
322
- });
323
- const box = document.createElement("div");
324
- element.appendChild(box);
325
- try {
326
- await paymentElement.mount(box);
327
- }
328
- catch (error) {
329
- box.remove();
330
- paymentElement.destroy();
331
- throw error;
332
- }
333
- return {
334
- pay() {
335
- if (destroyed || !ready || paying || finished)
336
- return Promise.resolve();
337
- paying = true;
338
- // The executor runs now, so confirmPayment() is called inside the app's click, before any await.
339
- return new Promise((resolve) => resolve(paymentElement.confirmPayment()))
340
- .then(async ({ status }) => {
341
- if (status !== "succeeded") {
342
- notify(() => { var _a; return (_a = options.onCancel) === null || _a === void 0 ? void 0 : _a.call(options); });
343
- return;
344
- }
345
- finished = true;
346
- // Runs even after destroy(), so a paid order is still completed.
347
- const result = await deps.completeCheckout(checkoutId);
348
- notify(() => { var _a; return (_a = options.onComplete) === null || _a === void 0 ? void 0 : _a.call(options, result); });
349
- })
350
- .catch((error) => {
351
- finished = true;
269
+ const handle = async (event) => {
270
+ if (event.name === "checkout.completed") {
271
+ completing = true;
272
+ button.disabled = true;
273
+ let result;
274
+ try {
275
+ // Paddle charged inside its own window; this asks the backend, which reads Paddle, whether it did.
276
+ result = await deps.completeCheckout(checkoutId);
277
+ }
278
+ catch (error) {
279
+ completing = false;
280
+ button.disabled = false;
352
281
  notify(() => { var _a; return (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, error); });
353
- })
354
- .finally(() => {
355
- paying = false;
282
+ return;
283
+ }
284
+ completing = false;
285
+ paid = true;
286
+ notify(() => { var _a; return (_a = options.onComplete) === null || _a === void 0 ? void 0 : _a.call(options, result); });
287
+ }
288
+ else if (event.name === "checkout.closed") {
289
+ open = false;
290
+ if (!paid && !completing)
291
+ notify(() => { var _a; return (_a = options.onCancel) === null || _a === void 0 ? void 0 : _a.call(options); });
292
+ }
293
+ else if (event.name === "checkout.error") {
294
+ notify(() => { var _a, _b; return (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, (_b = event.error) !== null && _b !== void 0 ? _b : event); });
295
+ }
296
+ };
297
+ const button = document.createElement("button");
298
+ button.type = "button";
299
+ button.textContent = "Pay";
300
+ button.setAttribute("data-base44-checkout", "paddle");
301
+ const onClick = () => {
302
+ if (paid || completing || open || button.disabled)
303
+ return;
304
+ open = true;
305
+ onPaddleEvent = (event) => void handle(event);
306
+ try {
307
+ Paddle.Checkout.open({
308
+ transactionId: embedded.transaction_id,
309
+ ...(embedded.customer_email ? { customer: { email: embedded.customer_email } } : {}),
356
310
  });
357
- },
311
+ }
312
+ catch (error) {
313
+ open = false;
314
+ notify(() => { var _a; return (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, error); });
315
+ }
316
+ };
317
+ button.addEventListener("click", onClick);
318
+ element.appendChild(button);
319
+ return {
358
320
  destroy() {
359
321
  if (destroyed)
360
322
  return;
361
323
  destroyed = true;
362
- box.remove();
363
- paymentElement.destroy();
324
+ button.removeEventListener("click", onClick);
325
+ button.remove();
326
+ if (open)
327
+ Paddle.Checkout.close();
328
+ },
329
+ setDisabled(disabled) {
330
+ if (!completing && !paid)
331
+ button.disabled = disabled;
364
332
  },
365
- // The app owns the Pay button, so it disables its own.
366
- setDisabled: () => undefined,
367
333
  };
368
334
  }
369
335
  /** The new checkout's id, refused unless it is the checkout the button was drawn for. */
@@ -388,7 +354,7 @@ function onClickCheckoutId(spec, button) {
388
354
  export async function preloadCheckout(provider, deps) {
389
355
  if (typeof window === "undefined" || typeof document === "undefined")
390
356
  return;
391
- const read = () => ({ paypal: browserGlobals().paypal, stripe: browserGlobals().Stripe, wix: browserGlobals().wpe })[provider];
357
+ const read = () => provider === "paypal" ? browserGlobals().paypal : provider === "paddle" ? browserGlobals().Paddle : browserGlobals().Stripe;
392
358
  try {
393
359
  if (!read()) {
394
360
  await deps.loadScript(await scriptUrlFor(provider, deps));
@@ -421,11 +387,8 @@ export async function mountCheckout(element, checkout, options, deps) {
421
387
  return mountStripe(element, await scriptUrlFor("stripe", deps), embedded, deps);
422
388
  case "paypal":
423
389
  return mountPayPal(element, await scriptUrlFor("paypal", deps), checkout.currency, embedded, checkout.checkout_id, options, deps);
424
- case "wix":
425
- if (!embedded.client_id) {
426
- throw new Error("This Base44 Payments checkout has no client ID to render with");
427
- }
428
- return mountWix(element, await scriptUrlFor("wix", deps), checkout.checkout_id, embedded.client_id, options, deps);
390
+ case "paddle":
391
+ return mountPaddle(element, await scriptUrlFor("paddle", deps), embedded, checkout.checkout_id, options, deps);
429
392
  default:
430
393
  throw new Error(`Embedded checkout isn't supported for provider ${embedded.provider}`);
431
394
  }
@@ -111,7 +111,7 @@ export interface CreateCheckoutParams {
111
111
  metadata?: Record<string, string>;
112
112
  /** Key that makes retries return the same checkout instead of creating another, 1 to 200 characters. Not supported for Base44 Payments or PayPal subscriptions. */
113
113
  idempotency_key?: string;
114
- /** How the buyer pays. Defaults to `'redirect'`. PayPal apps must pass `'embedded'`. */
114
+ /** How the buyer pays. Defaults to `'redirect'`. PayPal apps must pass `'embedded'`, and Base44 Payments supports only `'redirect'`. */
115
115
  presentation?: CheckoutPresentation;
116
116
  /**
117
117
  * Shipping address and fee. Allowed only when at least one item is `shippable`. Supported for PayPal one-time checkouts only. Other providers and subscriptions reject it with [`invalid_request`](#paymentserrorcode).
@@ -147,18 +147,24 @@ export interface PayPalEmbeddedCheckout {
147
147
  intent: "capture" | "subscription";
148
148
  }
149
149
  /**
150
- * Data that the Wix Payment Element needs to render, for Base44 Payments.
150
+ * Data that Paddle's checkout needs to open.
151
151
  */
152
- export interface WixEmbeddedCheckout {
152
+ export interface PaddleEmbeddedCheckout {
153
153
  /** Payment provider. */
154
- provider: "wix";
155
- /** Client ID the payment element signs in with. May be absent, so don't rely on it. */
156
- client_id?: string;
154
+ provider: "paddle";
155
+ /** Paddle client-side token of the app's seller account. Public by design. */
156
+ client_token: string;
157
+ /** ID of the Paddle transaction the buyer pays. */
158
+ transaction_id: string;
159
+ /** Paddle environment the transaction lives in. */
160
+ environment: "sandbox" | "production";
161
+ /** Buyer email to prefill, when the checkout named one. */
162
+ customer_email?: string | null;
157
163
  }
158
164
  /**
159
165
  * Data that an embedded checkout needs to render, by provider.
160
166
  */
161
- export type EmbeddedCheckout = StripeEmbeddedCheckout | PayPalEmbeddedCheckout | WixEmbeddedCheckout;
167
+ export type EmbeddedCheckout = StripeEmbeddedCheckout | PayPalEmbeddedCheckout | PaddleEmbeddedCheckout;
162
168
  /**
163
169
  * Result of [`createCheckout()`](#createcheckout).
164
170
  *
@@ -329,23 +335,19 @@ export type PaymentsErrorCode = "forbidden" | "unauthenticated" | "not_found" |
329
335
  */
330
336
  export interface MountCheckoutOptions {
331
337
  /**
332
- * Called after the buyer approves a PayPal payment, or pays with Base44 Payments, and the SDK completes the checkout. Use it to update the page, not to grant access.
338
+ * Called after the buyer approves a PayPal payment, or pays in Paddle's checkout, and the SDK completes the checkout. Use it to update the page, not to grant access.
333
339
  *
334
340
  * Stripe doesn't call this. After a Stripe payment, the buyer returns to the checkout's `success_path` with a `session_id` query parameter. That parameter is the `checkout_id`. Show the result there with [`listPurchases()`](#listpurchases).
335
341
  */
336
342
  onComplete?: (result: CompleteCheckoutResult) => void;
337
- /** Called when the buyer closes the PayPal window without paying, or when a Base44 Payments payment doesn't go through, a declined one included. The buyer can try again: PayPal's button stays mounted, and for Base44 Payments call `pay()` again. */
343
+ /** Called when the buyer closes the PayPal or Paddle window without paying. The button stays mounted so the buyer can try again. */
338
344
  onCancel?: () => void;
339
345
  /**
340
- * Called when a PayPal or Base44 Payments checkout fails after it's mounted. PayPal's button stays mounted so the buyer can try again. For Base44 Payments, `pay()` does nothing after this, since the payment element refuses another payment, so create a new checkout and mount it. For PayPal this includes a declined payment with the [`payment_declined`](#paymentserrorcode) code. If it keeps failing with `payment_declined`, create a new checkout and mount it. A declined Base44 Payments payment calls `onCancel` instead. Stripe shows its own errors inside the checkout.
346
+ * Called when a PayPal checkout fails after it's mounted, including a declined payment with the [`payment_declined`](#paymentserrorcode) code. The button stays mounted so the buyer can try again. If it keeps failing with `payment_declined`, create a new checkout and mount it. Stripe shows its own errors inside the checkout.
341
347
  *
342
- * The error is a `Base44Error` when completing the checkout fails, or the provider's own error object when the PayPal window or the Wix Payment Element fails.
348
+ * The error is a `Base44Error` when completing the checkout fails, or PayPal's own error object when the PayPal window fails.
343
349
  */
344
350
  onError?: (error: unknown) => void;
345
- /**
346
- * Base44 Payments only. Called with `true` when the payment element can take a payment, and with `false` if it stops loading. It can be called again with `true` once the element recovers. Enable your Pay button only while it's ready.
347
- */
348
- onReadyChange?: (ready: boolean) => void;
349
351
  }
350
352
  /**
351
353
  * An element on the page to render the checkout in, such as the result of `document.getElementById()`.
@@ -388,16 +390,8 @@ export interface PayPalCheckoutOnClick {
388
390
  export interface CheckoutMount {
389
391
  /** Removes the checkout from the page. Call it when the component that holds it unmounts. For Stripe, mounting another checkout destroys this one for you. */
390
392
  destroy: () => void;
391
- /** Grays out the PayPal button and ignores clicks, for example until a required form is filled in. After a payment completes the button stays off, so `setDisabled(false)` can't start a second payment. Stripe and Base44 Payments ignore it: Base44 Payments uses your own button, so disable that instead. */
393
+ /** Grays out PayPal's or Paddle's button and ignores clicks, for example until a required form is filled in. After a payment completes the button stays off, so `setDisabled(false)` can't start a second payment. Stripe ignores it. */
392
394
  setDisabled: (disabled: boolean) => void;
393
- /**
394
- * Base44 Payments only. Pays with what the buyer entered in the payment element. Call it from your own Pay button's click handler, synchronously and before any `await`, so the payment can open any window it needs.
395
- *
396
- * When the payment succeeds, the SDK calls {@linkcode PaymentsModule.completeCheckout | completeCheckout()} and then `onComplete`. Otherwise it calls `onCancel` or `onError`. It does nothing while the element isn't ready, while a payment is in progress, or after a payment succeeded or failed, so a second click can't charge twice.
397
- *
398
- * @returns Promise resolving once the payment and its callbacks finish. It never rejects.
399
- */
400
- pay?: () => Promise<void>;
401
395
  }
402
396
  /**
403
397
  * Payments module for accepting one-time payments and subscriptions in your app through its connected payment provider.
@@ -416,7 +410,7 @@ export interface CheckoutMount {
416
410
  * | | Stripe | PayPal | Base44 Payments |
417
411
  * | :- | :- | :- | :- |
418
412
  * | Redirect checkout | Yes | No | Yes |
419
- * | Embedded checkout | Yes | Yes, required | Yes |
413
+ * | Embedded checkout | Yes | Yes, required | No |
420
414
  * | Refunds | Yes | Yes | Yes |
421
415
  * | Subscription cancellation | Yes, now or at period end | Yes, now only | Yes, now or at period end |
422
416
  * | Subscription pause and resume | Yes | Yes | Yes |
@@ -425,7 +419,7 @@ export interface CheckoutMount {
425
419
  *
426
420
  * This module is available to use with a client in all authentication modes:
427
421
  *
428
- * - **Anonymous or user authentication** (`base44.payments`): Preloads and mounts embedded checkouts, completes PayPal and embedded Base44 Payments checkouts, and lists the current user's own purchases.
422
+ * - **Anonymous or user authentication** (`base44.payments`): Preloads and mounts embedded checkouts, completes PayPal checkouts, and lists the current user's own purchases.
429
423
  * - **Service role authentication** (`base44.asServiceRole.payments`): Creates checkouts, lists any purchase, refunds payments, and changes subscriptions. Use the [service role methods](#service-role-methods) in backend functions.
430
424
  *
431
425
  * @groupDescription Methods
@@ -433,13 +427,13 @@ export interface CheckoutMount {
433
427
  */
434
428
  export interface PaymentsModule {
435
429
  /**
436
- * Starts downloading the provider's JavaScript library, Stripe.js, the PayPal JavaScript SDK or the Wix Payment Element, before you mount a checkout, so the checkout appears faster.
430
+ * Starts downloading the provider's JavaScript library, Stripe.js or the PayPal JavaScript SDK, before you mount a checkout, so the checkout appears faster.
437
431
  *
438
432
  * Call it when the checkout page or form opens, while the buyer is still filling it in. {@linkcode mountCheckout | mountCheckout()} needs the library to render the checkout, and downloads it itself if you didn't preload it.
439
433
  *
440
434
  * It never rejects, so you don't need to await it or catch errors. If the library can't load, `mountCheckout()` tries again and rejects with the error. Loading the library requires a browser environment and is skipped in the backend.
441
435
  *
442
- * @param provider - The provider the app is connected to. Use `'wix'` for Base44 Payments.
436
+ * @param provider - The provider the app is connected to.
443
437
  * @returns Promise resolving once the library has loaded or failed to load.
444
438
  *
445
439
  * @example
@@ -448,7 +442,7 @@ export interface PaymentsModule {
448
442
  * base44.payments.preloadCheckout('paypal');
449
443
  * ```
450
444
  */
451
- preloadCheckout(provider: "paypal" | "stripe" | "wix"): Promise<void>;
445
+ preloadCheckout(provider: "paypal" | "stripe" | "paddle"): Promise<void>;
452
446
  /**
453
447
  * Renders an embedded checkout inside an element on the page.
454
448
  *
@@ -457,7 +451,6 @@ export interface PaymentsModule {
457
451
  * The SDK loads the provider's library and renders the checkout for you:
458
452
  * - PayPal: Renders a PayPal button. When the buyer approves the payment, the SDK calls {@linkcode completeCheckout | completeCheckout()} and then `onComplete`.
459
453
  * - Stripe: Mounts Stripe Embedded Checkout. After paying, the buyer returns to the checkout's `success_path`. Stripe allows one embedded checkout per page, so mounting another Stripe checkout destroys the previous one.
460
- * - Base44 Payments: Renders the Wix Payment Element, with no button of its own. Add your own Pay button, enable it while `onReadyChange` reports the element is ready, and call the mount's `pay()` from its click handler. When the payment succeeds, the SDK calls {@linkcode completeCheckout | completeCheckout()} and then `onComplete`.
461
454
  *
462
455
  * To make the checkout appear faster, load the library ahead of time with [`preloadCheckout()`](#preloadcheckout) when the page opens.
463
456
  *
@@ -509,27 +502,6 @@ export interface PaymentsModule {
509
502
  * ```
510
503
  *
511
504
  * @example
512
- * ```typescript
513
- * // Base44 Payments with your own Pay button
514
- * const payButton = document.getElementById('pay') as HTMLButtonElement;
515
- * payButton.disabled = true;
516
- * const mount = await base44.payments.mountCheckout(
517
- * document.getElementById('checkout')!,
518
- * checkout,
519
- * {
520
- * onReadyChange: (ready) => (payButton.disabled = !ready),
521
- * onComplete: () => navigate('/thank-you'),
522
- * onCancel: () => (payButton.disabled = false),
523
- * }
524
- * );
525
- *
526
- * payButton.addEventListener('click', () => {
527
- * payButton.disabled = true;
528
- * mount.pay?.();
529
- * });
530
- * ```
531
- *
532
- * @example
533
505
  * ```tsx
534
506
  * // React component
535
507
  * function Checkout({ checkout }: { checkout: CreateCheckoutResult }) {
@@ -554,11 +526,11 @@ export interface PaymentsModule {
554
526
  */
555
527
  mountCheckout(element: CheckoutElement, checkout: MountableCheckout | PayPalCheckoutOnClick, options?: MountCheckoutOptions): Promise<CheckoutMount>;
556
528
  /**
557
- * Completes a PayPal or embedded Base44 Payments checkout after the buyer pays.
529
+ * Completes a PayPal checkout after the buyer approves it.
558
530
  *
559
531
  * When you use {@linkcode mountCheckout | mountCheckout()}, it calls this for you. Call it directly only if you render your own PayPal button. Calling it again for the same checkout returns the same result.
560
532
  *
561
- * Only PayPal and embedded Base44 Payments checkouts need completing. Other checkouts reject with [`complete_not_supported`](#paymentserrorcode).
533
+ * Only PayPal checkouts need completing. Other providers reject with [`complete_not_supported`](#paymentserrorcode).
562
534
  *
563
535
  * To complete the checkout from a backend function instead, use [`completeCheckout()`](#service-role-methods) with the service role.
564
536
  *
@@ -689,11 +661,11 @@ export interface ServiceRolePaymentsModule {
689
661
  */
690
662
  createCheckout(params: CreateCheckoutParams): Promise<CreateCheckoutResult>;
691
663
  /**
692
- * Completes a PayPal or embedded Base44 Payments checkout from a backend function, after the buyer pays.
664
+ * Completes a PayPal checkout from a backend function, after the buyer approves it.
693
665
  *
694
666
  * Use it when you render your own PayPal button and its `onApprove` handler sends the checkout ID to your backend. Calling it again for the same checkout returns the same result.
695
667
  *
696
- * Only PayPal and embedded Base44 Payments checkouts need completing. Other checkouts reject with [`complete_not_supported`](#paymentserrorcode).
668
+ * Only PayPal checkouts need completing. Other providers reject with [`complete_not_supported`](#paymentserrorcode).
697
669
  *
698
670
  * @param checkoutId - The `checkout_id` from {@linkcode createCheckout | createCheckout()}.
699
671
  * @returns Promise resolving to the checkout's payment status.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.63-pr.392.a02dae3",
3
+ "version": "0.8.63-pr.393.32eac0e",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",