Skip to content

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Oct 9, 2025

Description

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

  • Refactor

    • Renamed “Payment Sources” to “Payment Methods” across the app (Checkout, Payment management, User and Organization Billing pages).
    • Updated add/remove flows, row displays, test-payment option, and selection controls to use payment method terminology and data bindings consistently.
  • Tests

    • Updated fixtures and assertions to reflect the new payment method naming.

Copy link

vercel bot commented Oct 9, 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 9, 2025 4:04pm

Copy link

changeset-bot bot commented Oct 9, 2025

🦋 Changeset detected

Latest commit: 34a99d1

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

Copy link
Contributor

coderabbitai bot commented Oct 9, 2025

Walkthrough

Renames "payment source(s)" to "payment method(s)" across core billing mapping, UI components, contexts, and tests. Updates imports, props, contexts, component names, and exports; switches billing pages to render PaymentMethods and adjusts getPaymentMethods data destructuring and revalidation naming.

Changes

Cohort / File(s) Summary
Core billing mapping
packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
getPaymentMethods now destructures { data } and maps over data (payment methods) instead of paymentSources.
Checkout module & tests
packages/clerk-js/src/core/modules/checkout/__tests__/manager.test.ts, packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx, packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
Replace paymentSourcepaymentMethod in mocks, state, props, rendering, and tests; rename helper/components and export PayWithTestPaymentMethod.
PaymentMethods component suite
packages/clerk-js/src/ui/components/PaymentMethods/*
packages/clerk-js/src/ui/components/PaymentMethods/AddPaymentMethod.tsx, .../PaymentMethodRow.tsx, .../PaymentMethods.tsx, .../TestPaymentMethod.tsx, .../index.ts
Rename AddPaymentSource→AddPaymentMethod, PaymentSourceRow→PaymentMethodRow, TestPaymentSource→TestPaymentMethod; update contexts, hooks, props, JSX, and add new re-exports.
Remove legacy PaymentSources exports
packages/clerk-js/src/ui/components/PaymentSources/index.ts
Remove re-exports for AddPaymentSource, PaymentSources, PaymentSourceRow.
Billing pages update
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx, packages/clerk-js/src/ui/components/UserProfile/BillingPage.tsx
Replace rendered PaymentSources with PaymentMethods.
Plans context revalidation rename
packages/clerk-js/src/ui/contexts/components/Plans.tsx
Rename revalidatePaymentSourcesrevalidatePaymentMethods and update usage and deps.
Misc / meta
.changeset/wet-cameras-sneeze.md
Non-functional whitespace/format change (no runtime effect).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant CF as CheckoutForm
  participant PM as usePaymentMethods
  participant API as Billing API

  U->>CF: Open checkout page
  CF->>PM: request payment methods
  PM->>API: GET /payment_methods
  API-->>PM: { data: [PaymentMethod...] }
  PM-->>CF: paymentMethods
  CF->>U: Render payment method options
  U->>CF: Select existing method or add new
  alt existing
    CF->>API: submit with payment_method_id
  else add new
    CF->>CF: AddPaymentMethod flow (form → submit)
    CF->>API: create & submit
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I hop through code with whiskers bright,
Renaming sources to methods tonight.
Props aligned and tests now hum,
A carrot patch — the changes done.
Rabbit cheers: merge it, goodnight! 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title uses the conventional commit prefix and clearly states that the PR’s primary change is renaming “payment source” to “payment method” internally, matching the bulk of the refactor described in the diff. It is concise, specific to the refactor scope, and avoids extraneous details or noise. This makes it easy for reviewers and future maintainers to understand the core purpose at a glance.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ 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-1264-internal-renaming

📜 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 1b0eeb0 and 34a99d1.

📒 Files selected for processing (1)
  • .changeset/wet-cameras-sneeze.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/wet-cameras-sneeze.md

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

@panteliselef panteliselef marked this pull request as ready for review October 9, 2025 15:30
@panteliselef panteliselef requested a review from a team October 9, 2025 15:30
@panteliselef panteliselef self-assigned this Oct 9, 2025
@panteliselef panteliselef force-pushed the elef/bill-1264-internal-renaming branch 2 times, most recently from d5d26ff to 1b0eeb0 Compare October 9, 2025 15:39
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: 0

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/ui/components/Checkout/__tests__/Checkout.test.tsx (1)

369-369: Update missed reference to paymentSource.

Line 369 still uses paymentSource: undefined instead of paymentMethod: undefined. This should be updated to maintain consistency with the rest of the codebase.

Apply this diff:

-      paymentSource: undefined,
+      paymentMethod: undefined,
packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx (1)

107-190: Rename lingering paymentSource identifiers
Found non-i18n occurrences still using paymentSource—update them to paymentMethod:

  • packages/shared/src/react/hooks/useCheckout.ts: initial state property (paymentSource: null)
  • packages/clerk-js/src/ui/components/Checkout/tests/Checkout.test.tsx: test prop (paymentSource: undefined)
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx: formatting placeholder ({ paymentSource: ref.current })
🧹 Nitpick comments (6)
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx (4)

217-220: Guard against undefined data from usePaymentMethods

Default paymentMethods to an empty array to avoid .length on undefined during loading.

As per coding guidelines

-  const { data: paymentMethods } = usePaymentMethods();
+  const { data: paymentMethods = [] } = usePaymentMethods();

236-244: Localize the SegmentedControl aria-label

Avoid hard-coded strings; use localization for a11y labels.

As per coding guidelines

-<SegmentedControl.Root
-  aria-label='Payment method source'
+<SegmentedControl.Root
+  aria-label={t(localizationKeys('commerce.checkout.paymentMethodSource'))}
   value={paymentMethodSource}
   onChange={value => setPaymentMethodSource(value as PaymentMethodSource)}
   size='lg'
   fullWidth
>

Add useLocalizations and t:

-import { __experimental_useCheckout as useCheckout } from '@clerk/shared/react';
+import { __experimental_useCheckout as useCheckout, useLocalizations } from '@clerk/shared/react';
 const CheckoutFormElementsInternal = () => {
   const { checkout } = useCheckout();
+  const { t } = useLocalizations();

381-397: Avoid duplicating label logic; localize labels

Option labels are hand-built and not localized. Prefer rendering a shared label (e.g., reuse PaymentMethodRow or extract a helper used by both the select and the row) and localize payment type/card brand.

As per coding guidelines

Also applies to: 433-433


415-417: Rename local var for clarity

Use domain-consistent naming to avoid confusion.

-              const paymentMethod = paymentMethods.find(source => source.id === option.value);
-              setSelectedPaymentMethod(paymentMethod);
+              const method = paymentMethods.find(m => m.id === option.value);
+              setSelectedPaymentMethod(method);
packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx (2)

27-33: Remove redundant return in async function

onAddPaymentMethodSuccess is async; return Promise.resolve() is unnecessary.

-    close();
-    return Promise.resolve();
+    close();

115-118: Avoid in-place sort of hook data

paymentMethods.sort(...) mutates the array returned by the hook; copy before sorting to prevent side effects.

-  const sortedPaymentMethods = useMemo(
-    () => paymentMethods.sort((a, b) => (a.isDefault && !b.isDefault ? -1 : 1)),
+  const sortedPaymentMethods = useMemo(
+    () => [...paymentMethods].sort((a, b) => (a.isDefault && !b.isDefault ? -1 : 1)),
     [paymentMethods],
   );
📜 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 65b7cc7 and a0e8862.

📒 Files selected for processing (13)
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts (1 hunks)
  • packages/clerk-js/src/core/modules/checkout/__tests__/manager.test.ts (1 hunks)
  • packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx (8 hunks)
  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx (7 hunks)
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx (2 hunks)
  • packages/clerk-js/src/ui/components/PaymentMethods/AddPaymentMethod.tsx (8 hunks)
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx (3 hunks)
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx (8 hunks)
  • packages/clerk-js/src/ui/components/PaymentMethods/TestPaymentMethod.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/PaymentMethods/index.ts (1 hunks)
  • packages/clerk-js/src/ui/components/PaymentSources/index.ts (0 hunks)
  • packages/clerk-js/src/ui/components/UserProfile/BillingPage.tsx (2 hunks)
  • packages/clerk-js/src/ui/contexts/components/Plans.tsx (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/clerk-js/src/ui/components/PaymentSources/index.ts
🧰 Additional context used
📓 Path-based instructions (15)
packages/clerk-js/src/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)

packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure

Files:

  • packages/clerk-js/src/ui/components/PaymentMethods/TestPaymentMethod.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx
  • packages/clerk-js/src/ui/components/UserProfile/BillingPage.tsx
  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx
  • packages/clerk-js/src/ui/contexts/components/Plans.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/index.ts
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/AddPaymentMethod.tsx
  • packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
**/*.{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/clerk-js/src/ui/components/PaymentMethods/TestPaymentMethod.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx
  • packages/clerk-js/src/ui/components/UserProfile/BillingPage.tsx
  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
  • packages/clerk-js/src/ui/contexts/components/Plans.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/index.ts
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/AddPaymentMethod.tsx
  • packages/clerk-js/src/core/modules/checkout/__tests__/manager.test.ts
  • packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
**/*.{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/clerk-js/src/ui/components/PaymentMethods/TestPaymentMethod.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx
  • packages/clerk-js/src/ui/components/UserProfile/BillingPage.tsx
  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
  • packages/clerk-js/src/ui/contexts/components/Plans.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/index.ts
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/AddPaymentMethod.tsx
  • packages/clerk-js/src/core/modules/checkout/__tests__/manager.test.ts
  • packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/**/*.{ts,tsx}

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

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/ui/components/PaymentMethods/TestPaymentMethod.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx
  • packages/clerk-js/src/ui/components/UserProfile/BillingPage.tsx
  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
  • packages/clerk-js/src/ui/contexts/components/Plans.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/index.ts
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/AddPaymentMethod.tsx
  • packages/clerk-js/src/core/modules/checkout/__tests__/manager.test.ts
  • packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/**/*.{ts,tsx,d.ts}

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

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/ui/components/PaymentMethods/TestPaymentMethod.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx
  • packages/clerk-js/src/ui/components/UserProfile/BillingPage.tsx
  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
  • packages/clerk-js/src/ui/contexts/components/Plans.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/index.ts
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/AddPaymentMethod.tsx
  • packages/clerk-js/src/core/modules/checkout/__tests__/manager.test.ts
  • packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
**/*.{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/clerk-js/src/ui/components/PaymentMethods/TestPaymentMethod.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx
  • packages/clerk-js/src/ui/components/UserProfile/BillingPage.tsx
  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
  • packages/clerk-js/src/ui/contexts/components/Plans.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/index.ts
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/AddPaymentMethod.tsx
  • packages/clerk-js/src/core/modules/checkout/__tests__/manager.test.ts
  • packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
**/*.{jsx,tsx}

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

**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: UserProfile, NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...

Files:

  • packages/clerk-js/src/ui/components/PaymentMethods/TestPaymentMethod.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx
  • packages/clerk-js/src/ui/components/UserProfile/BillingPage.tsx
  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx
  • packages/clerk-js/src/ui/contexts/components/Plans.tsx
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/AddPaymentMethod.tsx
  • packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
**/*.{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/clerk-js/src/ui/components/PaymentMethods/TestPaymentMethod.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx
  • packages/clerk-js/src/ui/components/UserProfile/BillingPage.tsx
  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx
  • packages/clerk-js/src/core/modules/billing/payment-source-methods.ts
  • packages/clerk-js/src/ui/contexts/components/Plans.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/index.ts
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/AddPaymentMethod.tsx
  • packages/clerk-js/src/core/modules/checkout/__tests__/manager.test.ts
  • packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
**/*.tsx

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

**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering

Files:

  • packages/clerk-js/src/ui/components/PaymentMethods/TestPaymentMethod.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx
  • packages/clerk-js/src/ui/components/UserProfile/BillingPage.tsx
  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx
  • packages/clerk-js/src/ui/contexts/components/Plans.tsx
  • packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx
  • packages/clerk-js/src/ui/components/PaymentMethods/AddPaymentMethod.tsx
  • packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx
packages/**/*.{test,spec}.{js,jsx,ts,tsx}

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

Unit tests should use Jest or Vitest as the test runner.

Files:

  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
  • packages/clerk-js/src/core/modules/checkout/__tests__/manager.test.ts
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}

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

Visual regression testing should be performed for UI components.

Files:

  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
  • packages/clerk-js/src/core/modules/checkout/__tests__/manager.test.ts
**/*.test.{jsx,tsx}

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

**/*.test.{jsx,tsx}: Use React Testing Library
Test component behavior, not implementation
Use proper test queries
Implement proper test isolation
Use proper test coverage
Test component interactions
Use proper test data
Implement proper test setup
Use proper test cleanup
Implement proper test assertions
Use proper test structure

Files:

  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
**/__tests__/**/*.{ts,tsx}

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

**/__tests__/**/*.{ts,tsx}: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces

Files:

  • packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx
  • packages/clerk-js/src/core/modules/checkout/__tests__/manager.test.ts
packages/**/index.{js,ts}

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

Use tree-shaking friendly exports

Files:

  • packages/clerk-js/src/ui/components/PaymentMethods/index.ts
**/index.ts

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

Use index.ts files for clean imports but avoid deep barrel exports

Avoid barrel files (index.ts re-exports) as they can cause circular dependencies

Files:

  • packages/clerk-js/src/ui/components/PaymentMethods/index.ts
🧬 Code graph analysis (7)
packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx (1)
packages/types/src/billing.ts (1)
  • BillingPaymentMethodResource (277-332)
packages/clerk-js/src/ui/components/UserProfile/BillingPage.tsx (1)
packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx (1)
  • PaymentMethods (107-190)
packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx (8)
packages/clerk-js/src/ui/elements/contexts/index.tsx (1)
  • withCardStateProvider (72-81)
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (2)
  • useSubscriberTypeContext (7-7)
  • useSubscriberTypeLocalizationRoot (9-12)
packages/clerk-js/src/ui/common/DevOnly.tsx (1)
  • DevOnly (4-11)
packages/clerk-js/src/ui/components/PaymentMethods/TestPaymentMethod.tsx (1)
  • TestPaymentMethod (5-68)
packages/types/src/billing.ts (1)
  • BillingPaymentMethodResource (277-332)
packages/clerk-js/src/ui/contexts/components/Plans.tsx (1)
  • usePaymentMethods (32-40)
packages/clerk-js/src/ui/elements/Section.tsx (1)
  • ProfileSection (335-344)
packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx (1)
  • PaymentMethodRow (6-52)
packages/clerk-js/src/core/modules/billing/payment-source-methods.ts (2)
packages/types/src/pagination.ts (1)
  • ClerkPaginatedResponse (22-31)
packages/clerk-js/src/core/resources/BillingPaymentSource.ts (1)
  • BillingPaymentMethod (14-72)
packages/clerk-js/src/ui/contexts/components/Plans.tsx (2)
packages/shared/src/react/hooks/usePaymentMethods.tsx (1)
  • usePaymentMethods (9-21)
packages/shared/src/react/hooks/index.ts (1)
  • usePaymentMethods (13-13)
packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx (1)
packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx (1)
  • PaymentMethods (107-190)
packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx (6)
packages/clerk-js/src/ui/contexts/components/Plans.tsx (1)
  • usePaymentMethods (32-40)
packages/shared/src/react/hooks/usePaymentMethods.tsx (1)
  • usePaymentMethods (9-21)
packages/shared/src/react/hooks/index.ts (1)
  • usePaymentMethods (13-13)
packages/clerk-js/src/ui/elements/contexts/index.tsx (1)
  • withCardStateProvider (72-81)
packages/types/src/billing.ts (1)
  • BillingPaymentMethodResource (277-332)
packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx (1)
  • PaymentMethodRow (6-52)
🔇 Additional comments (13)
packages/clerk-js/src/ui/contexts/components/Plans.tsx (1)

126-134: LGTM! Consistent internal renaming.

The variable renaming from revalidatePaymentSources to revalidatePaymentMethods is correctly applied across the destructuring (line 126), invocation (line 133), and useCallback dependency array (line 134). The refactoring maintains the existing logic while aligning with the PR's objective of internal naming consistency.

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

41-55: LGTM! Refactoring simplifies the code.

The removal of the paymentSources alias in favor of using data directly is a good simplification that aligns with the PR's goal of internal renaming. The changes are functionally equivalent and make the code more straightforward.

packages/clerk-js/src/ui/components/UserProfile/BillingPage.tsx (1)

10-10: LGTM!

The component swap from PaymentSources to PaymentMethods is clean and consistent with the rename.

Also applies to: 66-66

packages/clerk-js/src/ui/components/OrganizationProfile/OrganizationBillingPage.tsx (1)

11-11: LGTM!

The component swap from PaymentSources to PaymentMethods is clean and consistent with the rename.

Also applies to: 71-71

packages/clerk-js/src/ui/components/PaymentMethods/TestPaymentMethod.tsx (1)

41-63: Verify localization keys align with the rename.

The component has been renamed to TestPaymentMethod, but all localization keys still reference paymentSource (e.g., commerce.paymentSource.dev.testCardInfo, commerce.paymentSource.dev.developmentMode, etc.). While this may be intentional to preserve existing translations, this inconsistency should be documented or addressed in a follow-up.

packages/clerk-js/src/core/modules/checkout/__tests__/manager.test.ts (1)

55-55: LGTM!

The test mock field has been correctly updated from paymentSource to paymentMethod, aligning with the type changes in BillingCheckoutResource.

packages/clerk-js/src/ui/components/PaymentMethods/index.ts (1)

1-3: LGTM!

Clean barrel export pattern that provides a consolidated public API for the PaymentMethods module. This follows tree-shaking friendly practices.

packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethodRow.tsx (1)

6-51: LGTM!

The component and prop renaming from PaymentSourceRow to PaymentMethodRow is complete and consistent. Element descriptors follow the camelCase convention as required by the coding guidelines.

packages/clerk-js/src/ui/components/Checkout/__tests__/Checkout.test.tsx (1)

453-453: LGTM!

Test fixtures and assertions have been correctly updated from paymentSource to paymentMethod throughout the test file, maintaining consistency with the rename.

Also applies to: 533-546, 625-638, 750-750, 889-889, 1028-1028

packages/clerk-js/src/ui/components/PaymentMethods/AddPaymentMethod.tsx (1)

104-108: Review localization keys referencing paymentSource
Localization keys still use commerce.paymentSource… across multiple components (e.g. AddPaymentMethod.tsx:241, TestPaymentMethod.tsx, PaymentMethods.tsx). Either update them to paymentMethod or document/track the intentional retention for backward-compatibility.

packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx (1)

18-19: Renamed imports: LGTM

Imports now consistently reference PaymentMethod components.

packages/clerk-js/src/ui/components/PaymentMethods/PaymentMethods.tsx (2)

17-19: Renamed modules: LGTM

Switched to AddPaymentMethod, PaymentMethodRow, TestPaymentMethod consistently.


149-168: Rendering list and actions: LGTM

Rows, menus, and remove actions are wired correctly against the renamed API.

Copy link

pkg-pr-new bot commented Oct 9, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: 34a99d1

@panteliselef panteliselef merged commit 9822e62 into main Oct 9, 2025
42 checks passed
@panteliselef panteliselef deleted the elef/bill-1264-internal-renaming branch October 9, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants