@base44-preview/sdk 0.8.59-pr.371.9b61876 → 0.8.59-pr.371.d7ccde1
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.
|
@@ -361,7 +361,7 @@ export interface PayPalCheckoutOnClick {
|
|
|
361
361
|
/** Whether the checkout is a one-time payment or a subscription. */
|
|
362
362
|
intent: "capture" | "subscription";
|
|
363
363
|
/**
|
|
364
|
-
* Creates the checkout when the buyer clicks, usually by calling the backend function that calls
|
|
364
|
+
* Creates the checkout when the buyer clicks, usually by calling the backend function that calls [`createCheckout()`](#createcheckout). Resolve with its result. It must be an embedded PayPal checkout with the same `currency` and `intent` you set here, or `onError` receives an error. Reject to stop, for example when a required form field is empty. PayPal's window then closes and `onError` receives the error.
|
|
365
365
|
*/
|
|
366
366
|
createCheckout: () => Promise<MountableCheckout>;
|
|
367
367
|
}
|
|
@@ -371,7 +371,7 @@ export interface PayPalCheckoutOnClick {
|
|
|
371
371
|
export interface CheckoutMount {
|
|
372
372
|
/** 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
373
|
destroy: () => void;
|
|
374
|
-
/**
|
|
374
|
+
/** Grays out PayPal'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. */
|
|
375
375
|
setDisabled: (disabled: boolean) => void;
|
|
376
376
|
}
|
|
377
377
|
/**
|
|
@@ -425,7 +425,7 @@ export interface PaymentsModule {
|
|
|
425
425
|
/**
|
|
426
426
|
* Renders an embedded checkout inside an element on the page.
|
|
427
427
|
*
|
|
428
|
-
* Pass the result of a {@linkcode ServiceRolePaymentsModule.createCheckout | createCheckout()} call made with `presentation: 'embedded'`. Because only the service role can create checkouts, create it in a backend function and return the result to the page.
|
|
428
|
+
* Pass the result of a {@linkcode ServiceRolePaymentsModule.createCheckout | createCheckout()} call made with `presentation: 'embedded'`. Because only the service role can create checkouts, create it in a backend function and return the result to the page. For PayPal, you can instead pass a {@linkcode PayPalCheckoutOnClick} to show the button before any checkout exists. The SDK creates the checkout only when the buyer clicks the button, so visitors who don't buy don't leave unused checkouts behind.
|
|
429
429
|
*
|
|
430
430
|
* The SDK loads the provider's library and renders the checkout for you:
|
|
431
431
|
* - PayPal: Renders a PayPal button. When the buyer approves the payment, the SDK calls {@linkcode completeCheckout | completeCheckout()} and then `onComplete`.
|
|
@@ -433,8 +433,6 @@ export interface PaymentsModule {
|
|
|
433
433
|
*
|
|
434
434
|
* To make the checkout appear faster, load the library ahead of time with [`preloadCheckout()`](#preloadcheckout) when the page opens.
|
|
435
435
|
*
|
|
436
|
-
* For PayPal, pass a {@linkcode PayPalCheckoutOnClick} instead of a created checkout to show PayPal's button right away and create the checkout only when the buyer clicks it. The buyer clicks once, and page views create no orders.
|
|
437
|
-
*
|
|
438
436
|
* 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
437
|
*
|
|
440
438
|
* The checkout's callbacks run in the buyer's browser, where they can be faked. Grant access to what the buyer paid for only after your backend confirms the purchase, for example with [`listPurchases()`](#service-role-methods) in a backend function.
|
|
@@ -465,7 +463,7 @@ export interface PaymentsModule {
|
|
|
465
463
|
*
|
|
466
464
|
* @example
|
|
467
465
|
* ```typescript
|
|
468
|
-
* //
|
|
466
|
+
* // Create a PayPal checkout on click
|
|
469
467
|
* const mount = await base44.payments.mountCheckout(
|
|
470
468
|
* document.getElementById('paypal')!,
|
|
471
469
|
* {
|
|
@@ -478,7 +476,7 @@ export interface PaymentsModule {
|
|
|
478
476
|
* { onComplete: ({ checkout_id }) => confirmPurchase(checkout_id) }
|
|
479
477
|
* );
|
|
480
478
|
*
|
|
481
|
-
* //
|
|
479
|
+
* // Gray out the button until the shipping form is valid
|
|
482
480
|
* mount.setDisabled(!formIsValid);
|
|
483
481
|
* ```
|
|
484
482
|
*
|