Skip to content

Conversation

@panteliselef
Copy link
Member

@panteliselef panteliselef commented Oct 28, 2025

Description

Passing orgId should not be part of the public signature.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Billing API updated to adjust how organization IDs are handled for payment method operations.
  • Behavior Changes

    • Retrieving payment methods now accepts optional parameters (simpler call pattern).
  • Breaking Changes

    • PayPal gateway removed — Stripe is the only supported payment gateway.

@changeset-bot
Copy link

changeset-bot bot commented Oct 28, 2025

🦋 Changeset detected

Latest commit: 706eac3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@clerk/clerk-js Minor
@clerk/shared Minor
@clerk/types Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/elements Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/vue Patch
@clerk/localizations Patch
@clerk/themes Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Oct 28, 2025 10:12pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Walkthrough

Billing methods were changed to surface or handle orgId at the call-site level: the types package removes the WithOptionalOrgType wrapper and narrows gateways to 'stripe', while the clerk-js implementation extracts an optional orgId from params and embeds it in request paths; getPaymentMethods params are now optional.

Changes

Cohort / File(s) Summary
Changeset
\.changeset/great-bees-fix.md
Records minor bumps for packages and adds changelog entry removing unnecessary orgId from BillingPayerMethods.
Type definitions
packages/types/src/billing.ts
Removes WithOptionalOrgType usage from billing parameter types, makes getPaymentMethods param optional, narrows PaymentGateway to 'stripe', and updates InitializePaymentMethodParams / AddPaymentMethodParams to omit orgId.
Payment method implementation
packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
Adds a local WithOptionalOrgType generic, changes signatures to accept params with optional orgId, extracts orgId from params to build request path, passes remaining fields in request body, and makes getPaymentMethods accept optional params with default {}.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant BillingModule as payment-source-methods
    participant API

    Client->>BillingModule: initializePaymentMethod(params{..., orgId?})
    Note right of BillingModule: extract orgId if present<br/>build path including orgId<br/>send request body without orgId
    BillingModule->>API: POST /billing/{orgId?}/payment-methods (body: params w/o orgId)
    API-->>BillingModule: 200 OK
    BillingModule-->>Client: response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check param extraction and path construction in payment-source-methods.ts
  • Verify types in packages/types/src/billing.ts match implementation changes
  • Confirm narrowing of PaymentGateway to 'stripe' doesn't break callers

Poem

🐇 I hopped through types and paths today,

pulled orgId gently away.
Stripe hums softly, requests now neat,
params trimmed tidy, code skips a beat.
🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "fix(clerk-js, types): Remove orgId from BillingPayerMethods interface" is clear and specific, accurately capturing the primary change across both packages. The raw summary confirms that the main modifications involve removing the Exclude<..., 'orgId'> pattern from BillingPayerMethods interface method signatures (in packages/types/src/billing.ts) and refactoring parameter handling (in payment-source-methods.ts) to explicitly manage the optional orgId parameter rather than excluding it. The title directly references the key files affected (clerk-js, types), the interface being modified (BillingPayerMethods), and the specific change (removal of orgId), which aligns well with what a reviewer would expect when scanning commit history.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch elef/bill-1333-fix-omission-of-orgid-in-params

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1b5dd75 and 706eac3.

📒 Files selected for processing (1)
  • .changeset/great-bees-fix.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/great-bees-fix.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
.changeset/great-bees-fix.md (1)

1-7: ✓ Changeset format and wording are correct.

The file follows proper Changesets format with appropriate version bumps (minor for all three packages) and the changelog entry correctly uses "unnecessary" (addressing the prior review feedback). The description is clear and includes the feature context ("[Billing Beta]").


Comment @coderabbitai help to get the list of available commands and usage tips.

Comment on lines +16 to +18
type WithOptionalOrgType<T> = T & {
orgId?: string;
};
Copy link
Member Author

Choose a reason for hiding this comment

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

This is an internal concern, and should not affect the public API

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/clerk-js/src/core/modules/billing/payment-source-methods.ts (2)

20-30: Remove or justify the as any cast.

Line 26 uses as any which bypasses TypeScript's type checking. After destructuring orgId, rest should match InitializePaymentMethodParams (i.e., { gateway: PaymentGateway }). The cast appears unnecessary and violates the coding guideline against any types.

Apply this diff:

 export const initializePaymentMethod = async (params: WithOptionalOrgType<InitializePaymentMethodParams>) => {
   const { orgId, ...rest } = params;
   const json = (
     await BaseResource._fetch({
       path: Billing.path(`${PAYMENT_METHODS_PATH}/initialize`, { orgId }),
       method: 'POST',
-      body: rest as any,
+      body: rest,
     })
   )?.response as unknown as BillingInitializedPaymentMethodJSON;
   return new BillingInitializedPaymentMethod(json);
 };

32-43: Remove or justify the as any cast.

Line 39 uses as any which bypasses TypeScript's type checking. After destructuring orgId, rest should match AddPaymentMethodParams (i.e., { gateway: PaymentGateway; paymentToken: string }). The cast appears unnecessary and violates the coding guideline against any types.

Apply this diff:

 export const addPaymentMethod = async (params: WithOptionalOrgType<AddPaymentMethodParams>) => {
   const { orgId, ...rest } = params;

   const json = (
     await BaseResource._fetch({
       path: Billing.path(PAYMENT_METHODS_PATH, { orgId }),
       method: 'POST',
-      body: rest as any,
+      body: rest,
     })
   )?.response as unknown as BillingPaymentMethodJSON;
   return new BillingPaymentMethod(json);
 };
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 439427e and 1b5dd75.

📒 Files selected for processing (3)
  • .changeset/great-bees-fix.md (1 hunks)
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts (3 hunks)
  • packages/types/src/billing.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/great-bees-fix.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/types/src/billing.ts
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/types/src/billing.ts
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/types/src/billing.ts
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/types/src/billing.ts
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/types/src/billing.ts
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/types/src/billing.ts
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
🧬 Code graph analysis (2)
packages/types/src/billing.ts (1)
packages/types/src/pagination.ts (1)
  • ClerkPaginationParams (36-47)
packages/clerk-js/src/core/modules/billing/payment-source-methods.ts (1)
packages/types/src/billing.ts (3)
  • InitializePaymentMethodParams (239-244)
  • AddPaymentMethodParams (249-258)
  • GetPaymentMethodsParams (227-227)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (6)
packages/types/src/billing.ts (5)

92-102: LGTM! Clean interface simplification.

The removal of Exclude<..., 'orgId'> wrappers and direct use of parameter types is a good simplification. Making getPaymentMethods params optional also improves the API ergonomics.


227-227: LGTM! Consistent with orgId removal.

Simplifying from WithOptionalOrgType<ClerkPaginationParams> to ClerkPaginationParams aligns with the PR's goal.


239-244: LGTM! Parameter type simplified correctly.

The removal of WithOptionalOrgType wrapper from InitializePaymentMethodParams is consistent with the PR's objective.


249-258: LGTM! Parameter type simplified correctly.

The removal of WithOptionalOrgType wrapper from AddPaymentMethodParams is consistent with the PR's objective.


234-234: PayPal support was never implemented — removal is acceptable.

The search found zero references to 'paypal' in the entire codebase, confirming it was only a planned but never-implemented feature. Since PaymentGateway is marked @experimental in a public beta API that explicitly states "the API is subject to change," removing the unused type option is legitimate code cleanup rather than a problematic breaking change.

packages/clerk-js/src/core/modules/billing/payment-source-methods.ts (1)

45-59: LGTM! Clean implementation with proper optional parameter handling.

The use of params ?? {} provides a clean default, and the orgId extraction pattern is consistent with the other methods. No type safety issues here.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 28, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7087

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7087

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7087

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7087

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7087

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7087

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7087

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@7087

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7087

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7087

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7087

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7087

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7087

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7087

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@7087

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7087

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7087

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7087

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7087

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7087

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7087

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7087

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7087

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7087

commit: 706eac3

@panteliselef panteliselef self-assigned this Oct 28, 2025
@panteliselef panteliselef merged commit 7dfbf3a into main Oct 28, 2025
103 of 105 checks passed
@panteliselef panteliselef deleted the elef/bill-1333-fix-omission-of-orgid-in-params branch October 28, 2025 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants