@base44-preview/sdk 0.8.63-pr.391.2760310 → 0.8.63-pr.392.27e9c33
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, 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, WixEmbeddedCheckout, 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";
|
|
@@ -97,17 +97,6 @@ export interface AiGatewayModuleConfig {
|
|
|
97
97
|
* request options, the model list, and limits, see
|
|
98
98
|
* [Generate music with the AI Gateway](/developers/references/sdk/getting-started/ai-gateway-music).
|
|
99
99
|
*
|
|
100
|
-
* ## 3D models
|
|
101
|
-
*
|
|
102
|
-
* The gateway also serves a 3D model endpoint, `/3d-models`, so you can turn a
|
|
103
|
-
* text prompt or an image of one object into a textured 3D model. OpenAI has no
|
|
104
|
-
* 3D endpoint, so the request format is Base44's own. 3D generation is
|
|
105
|
-
* synchronous. The request returns the stored GLB file's `url` once the model is
|
|
106
|
-
* ready, which usually takes one to three minutes. Pass `'automatic'` or pin
|
|
107
|
-
* `'hunyuan_3d_v3_1_pro'`, which `automatic` always uses. For request options,
|
|
108
|
-
* the model list, and limits, see
|
|
109
|
-
* [Generate 3D models with the AI Gateway](/developers/references/sdk/getting-started/ai-gateway-3d-models).
|
|
110
|
-
*
|
|
111
100
|
* ## Structured evaluations
|
|
112
101
|
*
|
|
113
102
|
* The `typesafe` provider runs the `jev` evaluation model through
|
|
@@ -13,6 +13,9 @@ export interface PaymentsCheckoutConfig {
|
|
|
13
13
|
stripe?: {
|
|
14
14
|
script_url?: string;
|
|
15
15
|
};
|
|
16
|
+
wix?: {
|
|
17
|
+
script_url?: string;
|
|
18
|
+
};
|
|
16
19
|
}
|
|
17
20
|
type PayPalButtonConfig = Pick<PayPalEmbeddedCheckout, "client_id" | "merchant_id" | "partner_attribution_id">;
|
|
18
21
|
/** @internal */
|
|
@@ -2,6 +2,7 @@
|
|
|
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
6
|
};
|
|
6
7
|
async function scriptUrlFor(provider, deps) {
|
|
7
8
|
var _a, _b;
|
|
@@ -19,7 +20,7 @@ async function scriptUrlFor(provider, deps) {
|
|
|
19
20
|
url.username !== "" ||
|
|
20
21
|
url.password !== "" ||
|
|
21
22
|
!ALLOWED_SCRIPT_HOSTS[provider].includes(url.hostname)) {
|
|
22
|
-
const name =
|
|
23
|
+
const name = { paypal: "PayPal", stripe: "Stripe", wix: "Wix" }[provider];
|
|
23
24
|
throw new Error(`The payments config has no valid ${name} script URL`);
|
|
24
25
|
}
|
|
25
26
|
return url.href;
|
|
@@ -236,6 +237,153 @@ checkout, options, deps) {
|
|
|
236
237
|
},
|
|
237
238
|
};
|
|
238
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}`);
|
|
253
|
+
}
|
|
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
|
+
}
|
|
269
|
+
}
|
|
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
|
+
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;
|
|
306
|
+
const notify = (callback) => {
|
|
307
|
+
if (destroyed)
|
|
308
|
+
return;
|
|
309
|
+
try {
|
|
310
|
+
callback();
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
console.error("[Base44 SDK] A mountCheckout() callback threw", error);
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
const button = document.createElement("button");
|
|
317
|
+
button.type = "button";
|
|
318
|
+
button.className = "base44-checkout-pay";
|
|
319
|
+
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
|
+
}
|
|
342
|
+
const onClick = () => {
|
|
343
|
+
if (!ready || paying || finished || disabled)
|
|
344
|
+
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;
|
|
361
|
+
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
|
+
});
|
|
367
|
+
};
|
|
368
|
+
button.addEventListener("click", onClick);
|
|
369
|
+
element.appendChild(button);
|
|
370
|
+
return {
|
|
371
|
+
destroy() {
|
|
372
|
+
if (destroyed)
|
|
373
|
+
return;
|
|
374
|
+
destroyed = true;
|
|
375
|
+
button.removeEventListener("click", onClick);
|
|
376
|
+
button.remove();
|
|
377
|
+
box.remove();
|
|
378
|
+
paymentElement.destroy();
|
|
379
|
+
},
|
|
380
|
+
setDisabled(value) {
|
|
381
|
+
disabled = value;
|
|
382
|
+
if (ready && !paying && !finished)
|
|
383
|
+
button.disabled = value;
|
|
384
|
+
},
|
|
385
|
+
};
|
|
386
|
+
}
|
|
239
387
|
/** The new checkout's id, refused unless it is the checkout the button was drawn for. */
|
|
240
388
|
function onClickCheckoutId(spec, button) {
|
|
241
389
|
return async () => {
|
|
@@ -291,6 +439,11 @@ export async function mountCheckout(element, checkout, options, deps) {
|
|
|
291
439
|
return mountStripe(element, await scriptUrlFor("stripe", deps), embedded, deps);
|
|
292
440
|
case "paypal":
|
|
293
441
|
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);
|
|
294
447
|
default:
|
|
295
448
|
throw new Error(`Embedded checkout isn't supported for provider ${embedded.provider}`);
|
|
296
449
|
}
|
|
@@ -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'`. */
|
|
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).
|
|
@@ -146,10 +146,19 @@ export interface PayPalEmbeddedCheckout {
|
|
|
146
146
|
/** Whether the checkout is a one-time payment or a subscription. */
|
|
147
147
|
intent: "capture" | "subscription";
|
|
148
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Data that the Wix Payment Element needs to render, for Base44 Payments.
|
|
151
|
+
*/
|
|
152
|
+
export interface WixEmbeddedCheckout {
|
|
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;
|
|
157
|
+
}
|
|
149
158
|
/**
|
|
150
159
|
* Data that an embedded checkout needs to render, by provider.
|
|
151
160
|
*/
|
|
152
|
-
export type EmbeddedCheckout = StripeEmbeddedCheckout | PayPalEmbeddedCheckout;
|
|
161
|
+
export type EmbeddedCheckout = StripeEmbeddedCheckout | PayPalEmbeddedCheckout | WixEmbeddedCheckout;
|
|
153
162
|
/**
|
|
154
163
|
* Result of [`createCheckout()`](#createcheckout).
|
|
155
164
|
*
|
|
@@ -316,17 +325,17 @@ export type PaymentsErrorCode = "forbidden" | "unauthenticated" | "not_found" |
|
|
|
316
325
|
*/
|
|
317
326
|
export interface MountCheckoutOptions {
|
|
318
327
|
/**
|
|
319
|
-
* Called after the buyer approves a PayPal payment and the SDK completes the checkout. Use it to update the page, not to grant access.
|
|
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.
|
|
320
329
|
*
|
|
321
330
|
* 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).
|
|
322
331
|
*/
|
|
323
332
|
onComplete?: (result: CompleteCheckoutResult) => void;
|
|
324
|
-
/** Called when the buyer closes the PayPal window without paying. The button stays mounted so the buyer can try again. */
|
|
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. */
|
|
325
334
|
onCancel?: () => void;
|
|
326
335
|
/**
|
|
327
|
-
* Called when a PayPal checkout fails after it's mounted,
|
|
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.
|
|
328
337
|
*
|
|
329
|
-
* The error is a `Base44Error` when completing the checkout fails, or
|
|
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.
|
|
330
339
|
*/
|
|
331
340
|
onError?: (error: unknown) => void;
|
|
332
341
|
}
|
|
@@ -371,7 +380,7 @@ export interface PayPalCheckoutOnClick {
|
|
|
371
380
|
export interface CheckoutMount {
|
|
372
381
|
/** 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. */
|
|
373
382
|
destroy: () => void;
|
|
374
|
-
/** Grays out PayPal
|
|
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. */
|
|
375
384
|
setDisabled: (disabled: boolean) => void;
|
|
376
385
|
}
|
|
377
386
|
/**
|
|
@@ -391,7 +400,7 @@ export interface CheckoutMount {
|
|
|
391
400
|
* | | Stripe | PayPal | Base44 Payments |
|
|
392
401
|
* | :- | :- | :- | :- |
|
|
393
402
|
* | Redirect checkout | Yes | No | Yes |
|
|
394
|
-
* | Embedded checkout | Yes | Yes, required |
|
|
403
|
+
* | Embedded checkout | Yes | Yes, required | Yes |
|
|
395
404
|
* | Refunds | Yes | Yes | No |
|
|
396
405
|
* | Subscription cancellation | Yes, now or at period end | Yes, now only | No |
|
|
397
406
|
* | Subscription pause and resume | Yes | Yes | No |
|
|
@@ -400,7 +409,7 @@ export interface CheckoutMount {
|
|
|
400
409
|
*
|
|
401
410
|
* This module is available to use with a client in all authentication modes:
|
|
402
411
|
*
|
|
403
|
-
* - **Anonymous or user authentication** (`base44.payments`): Preloads and mounts embedded checkouts, completes PayPal checkouts, and lists the current user's own purchases.
|
|
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.
|
|
404
413
|
* - **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.
|
|
405
414
|
*
|
|
406
415
|
* @groupDescription Methods
|
|
@@ -432,8 +441,9 @@ export interface PaymentsModule {
|
|
|
432
441
|
* The SDK loads the provider's library and renders the checkout for you:
|
|
433
442
|
* - PayPal: Renders a PayPal button. When the buyer approves the payment, the SDK calls {@linkcode completeCheckout | completeCheckout()} and then `onComplete`.
|
|
434
443
|
* - 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`.
|
|
435
445
|
*
|
|
436
|
-
*
|
|
446
|
+
* For PayPal and Stripe, to make the checkout appear faster, load the library ahead of time with [`preloadCheckout()`](#preloadcheckout) when the page opens.
|
|
437
447
|
*
|
|
438
448
|
* 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.
|
|
439
449
|
*
|
|
@@ -507,11 +517,11 @@ export interface PaymentsModule {
|
|
|
507
517
|
*/
|
|
508
518
|
mountCheckout(element: CheckoutElement, checkout: MountableCheckout | PayPalCheckoutOnClick, options?: MountCheckoutOptions): Promise<CheckoutMount>;
|
|
509
519
|
/**
|
|
510
|
-
* Completes a PayPal checkout after the buyer
|
|
520
|
+
* Completes a PayPal or embedded Base44 Payments checkout after the buyer pays.
|
|
511
521
|
*
|
|
512
522
|
* 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.
|
|
513
523
|
*
|
|
514
|
-
* Only PayPal checkouts need completing. Other
|
|
524
|
+
* Only PayPal and embedded Base44 Payments checkouts need completing. Other checkouts reject with [`complete_not_supported`](#paymentserrorcode).
|
|
515
525
|
*
|
|
516
526
|
* To complete the checkout from a backend function instead, use [`completeCheckout()`](#service-role-methods) with the service role.
|
|
517
527
|
*
|
|
@@ -642,11 +652,11 @@ export interface ServiceRolePaymentsModule {
|
|
|
642
652
|
*/
|
|
643
653
|
createCheckout(params: CreateCheckoutParams): Promise<CreateCheckoutResult>;
|
|
644
654
|
/**
|
|
645
|
-
* Completes a PayPal checkout from a backend function, after the buyer
|
|
655
|
+
* Completes a PayPal or embedded Base44 Payments checkout from a backend function, after the buyer pays.
|
|
646
656
|
*
|
|
647
657
|
* 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.
|
|
648
658
|
*
|
|
649
|
-
* Only PayPal checkouts need completing. Other
|
|
659
|
+
* Only PayPal and embedded Base44 Payments checkouts need completing. Other checkouts reject with [`complete_not_supported`](#paymentserrorcode).
|
|
650
660
|
*
|
|
651
661
|
* @param checkoutId - The `checkout_id` from {@linkcode createCheckout | createCheckout()}.
|
|
652
662
|
* @returns Promise resolving to the checkout's payment status.
|