Repository navigation
feat(payments-sdk): add opt-in preview feature flag - #2737
Conversation
Rename the embeddable end-user SDK from "LLM SDK" to "Payments SDK" and the docs feature page to "Embeddable Payments", clarifying it is a payments + end-user sessions product (not an AI client SDK like the OpenAI SDK). Gate the feature as preview/opt-in via a new DB-only project.paymentsSdkEnabled flag. The dashboard shows a read-only preview until it is enabled, and the projects API rejects enabling end-user settings unless opted in. Add redirects so renamed pages don't 404: - docs: /features/llm-sdk -> /features/embeddable-payments - ui blog: /blog/embeddable-ai-credits-stripe-for-ai -> /blog/embeddable-payments-sdk Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GUABgidv5iUJEeew7gPrVc
WalkthroughAdds a ChangesPayments SDK preview flag and rebrand
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 383b8d0706
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1 @@ | |||
| ALTER TABLE "project" ADD COLUMN "payments_sdk_enabled" boolean DEFAULT false NOT NULL; | |||
There was a problem hiding this comment.
Backfill projects already using the SDK
For any project that already had end_user_enabled = true before this migration, this initializes payments_sdk_enabled to false. The new dashboard/API gate then treats those live SDK projects as preview-only/read-only and PATCH /projects/{id} rejects changes to markup/origins, so existing users lose the ability to manage their Payments SDK settings unless someone manually flips the new flag. Backfill from existing end_user_enabled rows or otherwise preserve those projects during the migration.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d72f63de3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| preview and enabled on an opt-in basis. The settings below are | ||
| read-only until it is enabled for your project — contact us to get |
There was a problem hiding this comment.
Disable revoke controls in preview mode
When paymentsSdkEnabled is false, this banner tells admins the SDK settings are read-only, and the save/create controls are disabled, but existing platform keys below can still be revoked because the Revoke button and deleteSecret path are not gated by isPreview. For projects that already have platform keys but are now in preview mode, an admin can still perform a destructive change from a page that claims it is read-only; either disable revocation in preview or make the exception explicit.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c138784011
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // The Payments SDK is a preview feature that must be opted into directly in | ||
| // the database. Until then the dashboard only renders a preview, so reject | ||
| // any attempt to enable end-user settings through the API. | ||
| if (isUpdatingEndUserSettings && !project.paymentsSdkEnabled) { |
There was a problem hiding this comment.
Gate platform-key APIs on the preview flag
This server-side preview check only covers PATCH /projects/{id}. I checked the platform-key route in apps/api/src/routes/keys-api.ts: POST /keys/platform goes through assertPlatformKeyAdminAccess, which verifies ownership/role but never reads project.paymentsSdkEnabled, so an owner/admin can still create Payments SDK platform secrets for a preview-disabled project by calling the API directly; on projects that already have endUserEnabled=true, those keys can be used to mint sessions. Put the same preview guard in the platform-key API/shared access check instead of relying on the dashboard button being disabled.
Useful? React with 👍 / 👎.
…way-payments-sdk-l60gt2
…way-payments-sdk-l60gt2
Summary
Introduces an opt-in preview feature flag for the Payments SDK (embeddable end-user payments functionality). This allows the feature to be gradually rolled out to users while maintaining backward compatibility.
Key Changes
payments_sdk_enabledboolean column to theprojecttable (defaults tofalse) via the generated migration underpackages/db/migrations.apps/api/src/routes/projects.tsandapps/api/src/routes/organization.tsto include the newpayments_sdk_enabledfield.PATCH /projects/{id}rejects attempts to enable end-user settings whenpaymentsSdkEnabledisfalse.POST /keys/platformnow gates platform-key (SDK platform secret) minting on the same flag via arequirePaymentsSdkPreviewoption on the sharedassertPlatformKeyAdminAccesscheck. Previously an owner/admin could mint Payments SDK platform secrets for a preview-disabled project by calling the API directly (the dashboard button being disabled was the only guard); on projects withendUserEnabled=truethose keys could then mint sessions. Listing and revoking existing keys remain allowed.sdk-settings.tsxwith explanatory commentdashboard-sidebar.tsxsdk/page.tsxTests
apps/api/src/routes/keys-api.spec.ts: the test project now opts into the preview, and a new case asserts thatPOST /keys/platformreturns403(and mints no key) whenpaymentsSdkEnabledisfalse.https://claude.ai/code/session_01GUABgidv5iUJEeew7gPrVc
Summary by CodeRabbit
New Features
Bug Fixes
Documentation