Skip to content

feat(payments): preloadCheckout() loads the provider's script before mounting - #357

Merged
naor-gal merged 1 commit into
mainfrom
feat/payments-preload-checkout
Nov 1, 2026
Merged

naor-gal merged 1 commit into
mainfrom
feat/payments-preload-checkout

Conversation

@naor-gal

Copy link
Copy Markdown
Contributor

Summary

Adds base44.payments.preloadCheckout(provider). It fetches the payments config and loads the provider's checkout script (PayPal or Stripe) ahead of time, so a later mountCheckout() skips both and renders sooner.

Today the PayPal button appears only after a serial chain: the app creates the checkout, then mountCheckout() fetches the config, downloads PayPal's script, creates the PayPal instance, checks eligibility and renders. The config and script don't depend on the checkout, so an app can start them when the checkout form opens, while the buyer is still typing.

  • Never rejects and does nothing outside a browser, so apps can fire and forget it. A failed preload is retried by mountCheckout(), which reports the error as before.
  • Reuses the module's cached config fetch and the per-URL script cache, so the preload and the mount share one request and one script tag.
  • Validates the script URL against the same host allow-list as mountCheckout().
  • Additive only, no change to mountCheckout().

Testing

  • vitest run tests/unit: 412 passed, including 3 new preloadCheckout tests (single config fetch and script tag across calls, invalid script URL loads nothing, failed config fetch still resolves).
  • npm run test:types: passes, with a type test for the provider union.

🤖 Generated with Claude Code

…mounting

mountCheckout() fetches the payments config and loads the provider's script
only after the checkout exists, so the PayPal button waits for both on top of
order creation. preloadCheckout() starts them when the checkout form opens.
It never rejects: mountCheckout() retries and reports any failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/sdk@0.8.57-pr.357.4227057

Prefer not to change any import paths? Install using npm alias so your code still imports @base44/sdk:

npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.57-pr.357.4227057"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/sdk": "npm:@base44-preview/sdk@0.8.57-pr.357.4227057"
  }
}

Preview published to npm registry — try new features instantly!

@github-actions github-actions Bot added the docs-draft PR has auto-drafted documentation suggestions label Oct 29, 2026

@guyofeck guyofeck left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does the new type is internal?

@naor-gal
naor-gal requested a review from guyofeck October 29, 2026 10:08
@naor-gal
naor-gal merged commit 4e964c3 into main Nov 1, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-draft PR has auto-drafted documentation suggestions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants