Skip to content

fix(cursor): include Stripe customer balance in Credits#251

Merged
validatedev merged 4 commits intomainfrom
fix/cursor-stripe-credits-balance
Mar 1, 2026
Merged

fix(cursor): include Stripe customer balance in Credits#251
validatedev merged 4 commits intomainfrom
fix/cursor-stripe-credits-balance

Conversation

@robinebers
Copy link
Owner

@robinebers robinebers commented Feb 28, 2026

Description

  • Add Stripe customer balance fetch (GET /api/auth/stripe) in the Cursor plugin using the existing WorkosCursorSessionToken session-cookie pattern.
  • Combine active credit grant totals with Stripe prepaid balance so Credits reflects total available funds (instead of only the active grant).
  • Add regression tests for combined grant+Stripe credits and Stripe-only credits, and update provider docs with endpoint/auth details.

Related Issue

  • None (reported directly by user in chat).

Type of Change

  • Bug fix
  • New feature
  • New provider plugin
  • Documentation
  • Performance improvement
  • Other (describe below)

Testing

  • I ran bun run build and it succeeded
  • I ran bun run test and all tests pass
  • I tested the change locally with bun tauri dev
  • Ran npm test -- plugins/cursor/plugin.test.js (47/47 passing)

Screenshots

  • N/A (no UI changes).

Checklist

  • I read CONTRIBUTING.md
  • My PR targets the main branch
  • I did not introduce new dependencies without justification

Made with Cursor


Note

Medium Risk
Adds a new call to an undocumented cursor.com endpoint and changes credit calculations, which could affect reported balances if the endpoint/auth cookie format changes or responses are unexpected.

Overview
Fixes the Cursor plugin’s Credits metric to reflect total available funds by combining GetCreditGrantsBalance with Stripe’s customerBalance from GET /api/auth/stripe (via WorkosCursorSessionToken cookie).

Adds fetchStripeBalance with defensive parsing (supports numeric strings, treats negative balances as credit, ignores non-2xx/invalid data), updates the Credits line to use the combined total while keeping “used” from grants when present, and adds regression tests plus provider docs for the new endpoint and cookie auth.

Written by Cursor Bugbot for commit 50872b6. This will update automatically on new commits. Configure here.


Summary by cubic

Fixes the Credits metric in the Cursor plugin to include Stripe prepaid balance alongside Cursor credit grants, so it shows total available funds. Adds a session‑cookie Stripe fetch and supports numeric‑string balances.

  • Bug Fixes
    • Fetch Stripe customerBalance from GET https://cursor.com/api/auth/stripe using WorkosCursorSessionToken.
    • Show total Credits = grant totalCents + Stripe prepaid balance (negative customerBalance); keep used from grants, or 0 when grants are unavailable.
    • Add regression tests (grant+Stripe, Stripe-only, numeric-string) and update provider docs with endpoint and session-cookie auth details.

Written for commit 5966603. Summary will update on new commits.

Combine Cursor credit grants with Stripe customer balance so Credits reflects total available funds rather than only the active grant.

Made-with: Cursor
@augmentcode
Copy link

augmentcode bot commented Feb 28, 2026

🤖 Augment PR Summary

Summary: Fixes Cursor’s Credits metric to include Stripe prepaid/customer balance in addition to active credit grants.

Changes:

  • Added a new GET https://cursor.com/api/auth/stripe fetch using the existing WorkosCursorSessionToken session-cookie pattern.
  • Parsed customerBalance (cents; negative indicates prepaid credit) and converted it into a positive “available credit” value.
  • Updated the Credits line to combine GetCreditGrantsBalance.totalCents with Stripe prepaid balance so the shown limit reflects total available funds.
  • Preserved “used” semantics based on grant usage (Stripe-only credits show used=0).
  • Added regression tests covering grant+Stripe combined credits and Stripe-only credits.
  • Updated Cursor provider docs with the new endpoint, auth header requirements, and response details.

Technical Notes: The Stripe call uses a 10s timeout and treats non-2xx responses or unparsable payloads as “no Stripe balance” (non-fatal).

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Cursor provider plugin so the “Credits” metric reflects both active credit grants and any Stripe prepaid customer balance retrieved from cursor.com, aligning displayed available funds with what users can actually spend.

Changes:

  • Add a GET https://cursor.com/api/auth/stripe request (authenticated via WorkosCursorSessionToken cookie) to fetch Stripe customerBalance.
  • Combine Stripe prepaid balance (negative customerBalance) with active credit grant totals when computing the “Credits” line.
  • Add regression tests for combined grant+Stripe credits and Stripe-only credits, and document the new endpoint/auth details.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
plugins/cursor/plugin.js Fetches Stripe customer balance and combines it with grant totals to compute the Credits limit.
plugins/cursor/plugin.test.js Adds test coverage for combined credits and Stripe-only credits scenarios.
docs/providers/cursor.md Documents the Stripe endpoint, cookie auth pattern, and updated Credits metric source/semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Coerce Stripe customerBalance values to a number before validation so numeric-string responses still contribute to the Credits metric.

Made-with: Cursor
Copy link
Collaborator

@davidarny davidarny left a comment

Choose a reason for hiding this comment

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

LGTM!

@validatedev validatedev merged commit 6244c9f into main Mar 1, 2026
3 checks passed
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