Skip to content

refactor(billing): fetch billing history via the generated OpenAPI SDK#3515

Open
baktun14 wants to merge 2 commits into
mainfrom
refactor/billing-history-generated-sdk
Open

refactor(billing): fetch billing history via the generated OpenAPI SDK#3515
baktun14 wants to merge 2 commits into
mainfrom
refactor/billing-history-generated-sdk

Conversation

@baktun14

@baktun14 baktun14 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Why

The frontend has two parallel ways to call the billing API: the hand-maintained HTTP SDK and the SDK generated from the API's OpenAPI contract. The billing-history transaction list still went through the hand-maintained client, so its request/response types were kept in sync by hand. This recently caused silent drift: the billing-history work changed the /v1/stripe/transactions contract (offset pagination, new transaction fields, a total count) while the generated types stayed on the old cursor-based shape. Sourcing this query from the generated SDK makes the frontend types follow the contract automatically.

Closes CON-747

What

Migrates the billing-history transaction list to fetch through the generated OpenAPI SDK (api.v1.listStripeTransactions) instead of the hand-maintained StripeService.getCustomerTransactions, matching how useDefaultPaymentMethodQuery already works. The fetch migration itself is behavior-neutral (billing history loads, paginates, and date-filters exactly as before).

  • Regenerated console-api-types for the transactions endpoint (offset pagination + current response shape). The generated diff is scoped to that endpoint only; pre-existing drift on main (trial 202 response, confirmStripeTransaction.idempotencyKey) is intentionally left for a separate full sdk:gen sweep.
  • The view's transaction type is now derived from the generated paths and re-exported from @src/queries, replacing the hand-maintained BillingTransaction for this flow.
  • confirmPayment invalidation uses api.v1.listStripeTransactions.getKey(); query error handling switched from axios.isAxiosError to ApiError / extractApiErrorMessage.
  • Removed the now-dead getPaymentTransactionsKey query-key helper.
  • CSV export stays on the hand-written client (its non-JSON blob response doesn't fit the generated client) and is out of scope.
  • UI: tightened the History type/status badge vertical padding (py-1py-0.5) so the pills read less chunky.

Summary by CodeRabbit

  • New Features
    • Updated billing transaction listings to use offset-based pagination, including total counts and “has more results” behavior.
    • Simplified transaction details with clearer, flattened payment method fields and a constrained transaction type.
  • Bug Fixes
    • Billing errors now surface the API-provided message more reliably.
    • Payment confirmation now properly refreshes cached transaction data after successful settled payments.
  • Chores
    • Adjusted query keying and test coverage to match the new API shapes and pagination model.

Replace the hand-written StripeService.getCustomerTransactions call in the
billing-history query with the generated api.v1.listStripeTransactions client,
so its request/response types follow the API contract instead of being kept in
sync by hand. Regenerate console-api-types for the transactions endpoint
(offset pagination and the current response shape), derive the view's
transaction type from the generated paths, and switch the query's error
handling to ApiError. CSV export stays on the hand-written client.

Ref CON-747
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ba86e78e-8dd6-434e-8642-deefefbf3caa

📥 Commits

Reviewing files that changed from the base of the PR and between 1d8cd68 and f671346.

📒 Files selected for processing (1)
  • apps/deploy-web/src/components/billing-usage/BillingView/BillingView.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/deploy-web/src/components/billing-usage/BillingView/BillingView.tsx

📝 Walkthrough

Walkthrough

Changes

Stripe transaction migration

Layer / File(s) Summary
Transaction API contract
apps/api/swagger/openapi.json, packages/console-api-types/src/*
Transaction listing changes from cursor-based to offset pagination, with flattened payment fields, typed transaction kinds, refund data, and totalCount/hasMore metadata.
Payment query integration
apps/deploy-web/src/queries/*
Payment transaction queries use api.v1.listStripeTransactions, normalize request parameters, derive BillingTransaction, and invalidate the generated API query key after confirmation.
Billing rendering and error handling
apps/deploy-web/src/components/billing-usage/*, apps/deploy-web/tests/seeders/payment.ts
Billing code imports the transaction type from the query layer, adjusts badge spacing, and uses ApiError message extraction with updated test coverage.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: stalniy, ygrishajev

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/billing-history-generated-sdk

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

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.12%. Comparing base (de2a2d4) to head (f671346).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3515      +/-   ##
==========================================
- Coverage   74.10%   73.12%   -0.99%     
==========================================
  Files        1141     1051      -90     
  Lines       29707    27357    -2350     
  Branches     7437     6977     -460     
==========================================
- Hits        22015    20005    -2010     
+ Misses       6796     6486     -310     
+ Partials      896      866      -30     
Flag Coverage Δ *Carryforward flag
api 87.23% <ø> (ø)
deploy-web 63.63% <100.00%> (-0.01%) ⬇️
log-collector ?
notifications 93.84% <ø> (ø) Carriedforward from 1d8cd68
provider-console 81.38% <ø> (ø) Carriedforward from 1d8cd68
provider-inventory ?
provider-proxy 88.17% <ø> (ø) Carriedforward from 1d8cd68
tx-signer ?

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...illing-usage/BillingContainer/BillingContainer.tsx 85.29% <100.00%> (ø)
...mponents/billing-usage/BillingView/BillingView.tsx 90.78% <ø> (ø)
apps/deploy-web/src/queries/usePaymentQueries.ts 96.66% <100.00%> (-0.06%) ⬇️

... and 90 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant