@base44-preview/sdk 0.8.63-pr.392.27e9c33 → 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", 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,72 +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;
304
- // What the app last passed to setDisabled().
305
- let disabled = 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;
306
259
  const notify = (callback) => {
307
260
  if (destroyed)
308
261
  return;
@@ -313,57 +266,53 @@ async function mountWix(element, scriptUrl, checkoutId, clientId, options, deps)
313
266
  console.error("[Base44 SDK] A mountCheckout() callback threw", error);
314
267
  }
315
268
  };
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;
281
+ notify(() => { var _a; return (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, error); });
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
+ };
316
297
  const button = document.createElement("button");
317
298
  button.type = "button";
318
- button.className = "base44-checkout-pay";
319
299
  button.textContent = "Pay";
320
- // Off until the element can take the payment.
321
- button.disabled = true;
322
- paymentElement.on("ready", () => {
323
- ready = true;
324
- if (!paying && !finished)
325
- button.disabled = disabled;
326
- });
327
- // The element fires ready again once it recovers.
328
- paymentElement.on("loaderror", () => {
329
- ready = false;
330
- button.disabled = true;
331
- });
332
- const box = document.createElement("div");
333
- element.appendChild(box);
334
- try {
335
- await paymentElement.mount(box);
336
- }
337
- catch (error) {
338
- box.remove();
339
- paymentElement.destroy();
340
- throw error;
341
- }
300
+ button.setAttribute("data-base44-checkout", "paddle");
342
301
  const onClick = () => {
343
- if (!ready || paying || finished || disabled)
302
+ if (paid || completing || open || button.disabled)
344
303
  return;
345
- paying = true;
346
- button.disabled = true;
347
- // The executor runs now, so confirmPayment() is called inside the click, before any await.
348
- new Promise((resolve) => resolve(paymentElement.confirmPayment()))
349
- .then(async ({ status }) => {
350
- if (status !== "succeeded") {
351
- notify(() => { var _a; return (_a = options.onCancel) === null || _a === void 0 ? void 0 : _a.call(options); });
352
- return;
353
- }
354
- finished = true;
355
- // Runs even after destroy(), so a paid order is still completed.
356
- const result = await deps.completeCheckout(checkoutId);
357
- notify(() => { var _a; return (_a = options.onComplete) === null || _a === void 0 ? void 0 : _a.call(options, result); });
358
- })
359
- .catch((error) => {
360
- finished = true;
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 } } : {}),
310
+ });
311
+ }
312
+ catch (error) {
313
+ open = false;
361
314
  notify(() => { var _a; return (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, error); });
362
- })
363
- .finally(() => {
364
- paying = false;
365
- button.disabled = !ready || finished || disabled;
366
- });
315
+ }
367
316
  };
368
317
  button.addEventListener("click", onClick);
369
318
  element.appendChild(button);
@@ -374,13 +323,12 @@ async function mountWix(element, scriptUrl, checkoutId, clientId, options, deps)
374
323
  destroyed = true;
375
324
  button.removeEventListener("click", onClick);
376
325
  button.remove();
377
- box.remove();
378
- paymentElement.destroy();
326
+ if (open)
327
+ Paddle.Checkout.close();
379
328
  },
380
- setDisabled(value) {
381
- disabled = value;
382
- if (ready && !paying && !finished)
383
- button.disabled = value;
329
+ setDisabled(disabled) {
330
+ if (!completing && !paid)
331
+ button.disabled = disabled;
384
332
  },
385
333
  };
386
334
  }
@@ -406,7 +354,7 @@ function onClickCheckoutId(spec, button) {
406
354
  export async function preloadCheckout(provider, deps) {
407
355
  if (typeof window === "undefined" || typeof document === "undefined")
408
356
  return;
409
- const read = () => (provider === "paypal" ? browserGlobals().paypal : browserGlobals().Stripe);
357
+ const read = () => provider === "paypal" ? browserGlobals().paypal : provider === "paddle" ? browserGlobals().Paddle : browserGlobals().Stripe;
410
358
  try {
411
359
  if (!read()) {
412
360
  await deps.loadScript(await scriptUrlFor(provider, deps));
@@ -439,11 +387,8 @@ export async function mountCheckout(element, checkout, options, deps) {
439
387
  return mountStripe(element, await scriptUrlFor("stripe", deps), embedded, deps);
440
388
  case "paypal":
441
389
  return mountPayPal(element, await scriptUrlFor("paypal", deps), checkout.currency, embedded, checkout.checkout_id, options, deps);
442
- case "wix":
443
- if (!embedded.client_id) {
444
- throw new Error("This Base44 Payments checkout has no client ID to render with");
445
- }
446
- 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);
447
392
  default:
448
393
  throw new Error(`Embedded checkout isn't supported for provider ${embedded.provider}`);
449
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
  *
@@ -227,6 +233,10 @@ export interface Purchase {
227
233
  metadata?: Record<string, string> | null;
228
234
  /** ID of the subscription, for recurring purchases. */
229
235
  subscription_id?: string | null;
236
+ /** Current state of the subscription, for Base44 Payments subscription purchases: `active`, `paused` or `canceled`. `null` while the provider retries a renewal, or when the state couldn't be read. */
237
+ subscription_status?: "active" | "paused" | "canceled" | null;
238
+ /** When the paid period ends, as an ISO 8601 date, for an `active` Base44 Payments subscription. After a cancel at period end it's when access ends. `null` otherwise. */
239
+ paid_until?: string | null;
230
240
  /** Where the order ships, whether your app or the provider collected the address. Always `null` unless you call with the service role. Save it on your order record. */
231
241
  shipping_address?: ShippingAddress | null;
232
242
  /** Shipping fee in minor units, when the checkout charged one. */
@@ -325,17 +335,17 @@ export type PaymentsErrorCode = "forbidden" | "unauthenticated" | "not_found" |
325
335
  */
326
336
  export interface MountCheckoutOptions {
327
337
  /**
328
- * 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.
329
339
  *
330
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).
331
341
  */
332
342
  onComplete?: (result: CompleteCheckoutResult) => void;
333
- /** 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 button stays mounted so the buyer can try again. */
343
+ /** Called when the buyer closes the PayPal or Paddle window without paying. The button stays mounted so the buyer can try again. */
334
344
  onCancel?: () => void;
335
345
  /**
336
- * Called when a PayPal or Base44 Payments checkout fails after it's mounted. PayPal's button stays mounted so the buyer can try again. The Base44 Payments button stays off, 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.
337
347
  *
338
- * 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.
339
349
  */
340
350
  onError?: (error: unknown) => void;
341
351
  }
@@ -380,7 +390,7 @@ export interface PayPalCheckoutOnClick {
380
390
  export interface CheckoutMount {
381
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. */
382
392
  destroy: () => void;
383
- /** Grays out the PayPal or Base44 Payments 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. The Base44 Payments button also stays off after the payment element rejects a payment. Stripe ignores it. */
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. */
384
394
  setDisabled: (disabled: boolean) => void;
385
395
  }
386
396
  /**
@@ -400,16 +410,16 @@ export interface CheckoutMount {
400
410
  * | | Stripe | PayPal | Base44 Payments |
401
411
  * | :- | :- | :- | :- |
402
412
  * | Redirect checkout | Yes | No | Yes |
403
- * | Embedded checkout | Yes | Yes, required | Yes |
404
- * | Refunds | Yes | Yes | No |
405
- * | Subscription cancellation | Yes, now or at period end | Yes, now only | No |
406
- * | Subscription pause and resume | Yes | Yes | No |
413
+ * | Embedded checkout | Yes | Yes, required | No |
414
+ * | Refunds | Yes | Yes | Yes |
415
+ * | Subscription cancellation | Yes, now or at period end | Yes, now only | Yes, now or at period end |
416
+ * | Subscription pause and resume | Yes | Yes | Yes |
407
417
  *
408
418
  * ## Authentication modes
409
419
  *
410
420
  * This module is available to use with a client in all authentication modes:
411
421
  *
412
- * - **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.
413
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.
414
424
  *
415
425
  * @groupDescription Methods
@@ -432,7 +442,7 @@ export interface PaymentsModule {
432
442
  * base44.payments.preloadCheckout('paypal');
433
443
  * ```
434
444
  */
435
- preloadCheckout(provider: "paypal" | "stripe"): Promise<void>;
445
+ preloadCheckout(provider: "paypal" | "stripe" | "paddle"): Promise<void>;
436
446
  /**
437
447
  * Renders an embedded checkout inside an element on the page.
438
448
  *
@@ -441,9 +451,8 @@ export interface PaymentsModule {
441
451
  * The SDK loads the provider's library and renders the checkout for you:
442
452
  * - PayPal: Renders a PayPal button. When the buyer approves the payment, the SDK calls {@linkcode completeCheckout | completeCheckout()} and then `onComplete`.
443
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.
444
- * - Base44 Payments: Renders the Wix Payment Element and a **Pay** button below it. Style the button with its `base44-checkout-pay` class. When the payment succeeds, the SDK calls {@linkcode completeCheckout | completeCheckout()} and then `onComplete`.
445
454
  *
446
- * For PayPal and Stripe, to make the checkout appear faster, load the library ahead of time with [`preloadCheckout()`](#preloadcheckout) when the page opens.
455
+ * To make the checkout appear faster, load the library ahead of time with [`preloadCheckout()`](#preloadcheckout) when the page opens.
447
456
  *
448
457
  * Requires a browser environment and can't be used in the backend. Rejects when the checkout isn't embedded, when an on-click PayPal checkout is mounted before the app's PayPal can take payments, when the payments config can't be fetched or has no valid script URL for the provider, when the provider's library fails to load, or when PayPal isn't available for the checkout's currency.
449
458
  *
@@ -517,11 +526,11 @@ export interface PaymentsModule {
517
526
  */
518
527
  mountCheckout(element: CheckoutElement, checkout: MountableCheckout | PayPalCheckoutOnClick, options?: MountCheckoutOptions): Promise<CheckoutMount>;
519
528
  /**
520
- * Completes a PayPal or embedded Base44 Payments checkout after the buyer pays.
529
+ * Completes a PayPal checkout after the buyer approves it.
521
530
  *
522
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.
523
532
  *
524
- * 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).
525
534
  *
526
535
  * To complete the checkout from a backend function instead, use [`completeCheckout()`](#service-role-methods) with the service role.
527
536
  *
@@ -652,11 +661,11 @@ export interface ServiceRolePaymentsModule {
652
661
  */
653
662
  createCheckout(params: CreateCheckoutParams): Promise<CreateCheckoutResult>;
654
663
  /**
655
- * 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.
656
665
  *
657
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.
658
667
  *
659
- * 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).
660
669
  *
661
670
  * @param checkoutId - The `checkout_id` from {@linkcode createCheckout | createCheckout()}.
662
671
  * @returns Promise resolving to the checkout's payment status.
@@ -715,8 +724,6 @@ export interface ServiceRolePaymentsModule {
715
724
  *
716
725
  * Retrying with the same `idempotency_key` and `amount` returns the original refund instead of refunding twice. When the call rejects with [`refund_failed`](#paymentserrorcode), the outcome is unknown, so retry it with the same values.
717
726
  *
718
- * Not supported for Base44 Payments.
719
- *
720
727
  * @param params - The payment, amount, and idempotency key.
721
728
  * @returns Promise resolving to the refund.
722
729
  *
@@ -737,7 +744,7 @@ export interface ServiceRolePaymentsModule {
737
744
  /**
738
745
  * Cancels a subscription, now or at the end of the current billing period.
739
746
  *
740
- * Not supported for Base44 Payments. PayPal supports canceling now only.
747
+ * Stripe and Base44 Payments can cancel now or at the end of the period. PayPal can only cancel immediately, so `at_period_end` isn't supported there.
741
748
  *
742
749
  * @param subscriptionId - The `subscription_id` of the purchase.
743
750
  * @param options - When to cancel.
@@ -755,8 +762,6 @@ export interface ServiceRolePaymentsModule {
755
762
  /**
756
763
  * Pauses a subscription's billing.
757
764
  *
758
- * Not supported for Base44 Payments.
759
- *
760
765
  * @param subscriptionId - The `subscription_id` of the purchase.
761
766
  * @returns Promise resolving to the subscription's state.
762
767
  *
@@ -770,8 +775,6 @@ export interface ServiceRolePaymentsModule {
770
775
  /**
771
776
  * Resumes a paused subscription's billing.
772
777
  *
773
- * Not supported for Base44 Payments.
774
- *
775
778
  * @param subscriptionId - The `subscription_id` of the purchase.
776
779
  * @returns Promise resolving to the subscription's state.
777
780
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.63-pr.392.27e9c33",
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",