Skip to content

fix: show org payment method for all team members on billing tab#2959

Merged
lohanidamodar merged 2 commits intomainfrom
fix-billing-payment-method-display
Apr 7, 2026
Merged

fix: show org payment method for all team members on billing tab#2959
lohanidamodar merged 2 commits intomainfrom
fix-billing-payment-method-display

Conversation

@lohanidamodar
Copy link
Copy Markdown
Member

Summary

  • The billing tab's payment method display used account.listPaymentMethods() which only returns the current user's own cards
  • If the org's payment method was added by a different team member, non-owner members saw "Add a payment method" instead of the actual card
  • Switched to organizations.getPaymentMethod() to fetch the org's primary and backup payment methods directly by ID, so they display correctly for all team members
  • account.listPaymentMethods() is still used for the "change/replace payment method" dropdown since users can only assign their own cards

Test plan

  • Log in as an org member who did not add the org's payment method
  • Navigate to the organization billing tab
  • Verify the org's primary payment method card is displayed correctly
  • Verify the backup payment method (if set) is also displayed
  • Verify the "Replace" dropdown still shows the current user's own cards
  • Verify orgs with no payment method still show "Add a payment method"

🤖 Generated with Claude Code

Fetch the organization's primary and backup payment methods via
organizations.getPaymentMethod() instead of filtering account.listPaymentMethods().
The account endpoint only returns the current user's own cards, so if
a different team member added the org's payment method it was invisible
and the billing page incorrectly showed "Add a payment method".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 7, 2026

Greptile Summary

This PR fixes a bug where non-owner org members saw "Add a payment method" on the billing tab instead of the org's actual card, because account.listPaymentMethods() only returns the calling user's own payment methods. The fix fetches the org's primary and backup payment methods directly via organizations.getPaymentMethod() using the IDs already stored on the organization object, so the display is correct for every member regardless of who added the card.

Key changes:

  • Added primaryPaymentMethodPromise and backupPaymentMethodPromise that call organizations.getPaymentMethod() when the corresponding IDs are set, with .catch(() => null) for graceful error handling
  • Both promises are resolved in the existing Promise.all as the 6th and 7th elements
  • account.listPaymentMethods() is retained for the "Replace payment method" dropdown, which correctly only shows the current user's own cards
  • Removed the now-unnecessary getOrganizationPaymentMethods() helper that filtered the user's card list by ID

Confidence Score: 5/5

This PR is safe to merge — the fix is minimal, targeted, and correct.

No P0 or P1 issues remain. The root cause is correctly identified and the fix uses the right API endpoint. Promise.all handles null entries as already-resolved values so the null-coalescing pattern is safe, .catch(() => null) prevents hard failures, and Dependencies.ORGANIZATION already covers cache invalidation when payment method IDs change. The previously flagged type annotation issue is a non-breaking cosmetic concern with strict: false.

No files require special attention.

Important Files Changed

Filename Overview
src/routes/(console)/organization-[organization]/billing/+page.ts Switches org primary/backup payment method loading from account.listPaymentMethods() (user-scoped) to organizations.getPaymentMethod() (org-scoped) so all team members see the correct card; removes the now-unnecessary getOrganizationPaymentMethods() helper.

Reviews (2): Last reviewed commit: "fix: correct type annotations for paymen..." | Re-trigger Greptile

Promise type should include null for both the resolved value
(.catch(() => null)) and the ternary false branch (null).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lohanidamodar lohanidamodar merged commit 3aae061 into main Apr 7, 2026
4 checks passed
@lohanidamodar lohanidamodar deleted the fix-billing-payment-method-display branch April 7, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants