Skip to content

feat(payments): add payments module with embedded checkout - #323

Merged
naor-gal merged 3 commits into
mainfrom
feat/payments-module
Oct 14, 2026
Merged

naor-gal merged 3 commits into
mainfrom
feat/payments-module

Conversation

@naor-gal

@naor-gal naor-gal commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds base44.payments (browser) with completeCheckout(), listPurchases() and mountCheckout().
  • Adds base44.asServiceRole.payments (backend functions) with createCheckout(), completeCheckout(), listPurchases(), refund(), cancelSubscription(), pauseSubscription() and resumeSubscription().
  • The service-only methods aren't on the user module type, so calling them from the browser fails at compile time. This follows the ConnectorsModule / UserConnectorsModule split.
  • Request and response fields use the API's snake_case names unchanged, like the other modules. Failed requests reject with the existing Base44Error, with code from the API's error envelope.
  • mountCheckout() renders an embedded checkout in any framework, with no new dependencies. It fetches GET /payments/config once per client and loads the script URL that config names for the provider. Before loading, it requires https: and an exact provider host (www.paypal.com or www.sandbox.paypal.com for PayPal, js.stripe.com for Stripe), and rejects anything else without adding a script tag.
    • PayPal: loads PayPal JS SDK v6 and renders a <paypal-button>. On approve it calls completeCheckout(). A declined payment goes to onError, and the button stays so the buyer can re-approve the same order.
    • Stripe: loads Stripe.js and mounts Embedded Checkout. Mounts run in order, and a new one replaces the previous one, since Stripe allows one per page.
  • Docs: JSDoc for every public type and method, a provider support table, and the error codes, purchase statuses and recurring frequencies on the payments reference page. A separate service-role-payments page holds the service-role methods. Also adds a README entry.

Notes

  • Browser callbacks can be faked, so the docs tell apps to grant access only after their backend confirms the purchase, for example with listPurchases() in a backend function.
  • Base44Client gains a required payments member and asServiceRole gains payments, the same as earlier module additions. Code that builds that type by hand needs the new members.
  • The public element type is the structural CheckoutElement, so the SDK's types don't need the DOM library in backend code.

Test plan

  • npm run lint
  • npm test -w @base44/sdk: 378 tests, including new unit tests (HTTP routes, error envelope, config caching and URL checks, mount lifecycle) and type tests
  • npm run build -w @base44/sdk
  • npm run create-docs (packages/sdk): payments and service-role-payments pages generate cleanly
  • Manual, PayPal sandbox: created an embedded checkout, mounted it, approved as a sandbox buyer, and completeCheckout() returned paid
  • Manual, PayPal sandbox: re-approved the same order from the mounted button, and capture succeeded
  • Reviewer: spot-check the generated payments.mdx page in mintlify-docs

🤖 Generated with Claude Code

Adds `base44.payments` and `base44.asServiceRole.payments` for the
Payments API: checkouts, PayPal checkout completion, purchase lookup,
refunds, and subscription cancel, pause and resume.

`mountCheckout()` renders an embedded checkout in any framework. It
loads PayPal JS SDK v6 or Stripe.js v3 on demand, with no new
dependencies.

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

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/sdk@0.8.53-pr.323.0c3777e

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.53-pr.323.0c3777e"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/sdk": "npm:@base44-preview/sdk@0.8.53-pr.323.0c3777e"
  }
}

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 12, 2026
naor-gal and others added 2 commits October 13, 2026 14:52
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SDK no longer hard-codes PayPal or Stripe script URLs or PayPal
environments. mountCheckout() fetches GET /payments/config once per
client and loads the URL it names, after checking it is https on the
provider's own host.

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

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available! (@base44/platform)


Install this PR's preview build with npm:

npm i @base44-preview/platform@0.1.0-pr.323.0c3777e

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

npm i "@base44/platform@npm:@base44-preview/platform@0.1.0-pr.323.0c3777e"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/platform": "npm:@base44-preview/platform@0.1.0-pr.323.0c3777e"
  }
}

Preview published to npm registry — try new features instantly!

@naor-gal
naor-gal merged commit 212b924 into main Oct 14, 2026
8 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