Skip to content

fix(credits): support custom currencies in grant APIs - #5318

Merged
GAlexIHU merged 2 commits into
mainfrom
codex/fix-credit-grant-custom-currencies
Oct 26, 2026
Merged

GAlexIHU merged 2 commits into
mainfrom
codex/fix-credit-grant-custom-currencies

Conversation

@GAlexIHU

@GAlexIHU GAlexIHU commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Credit-grant list requests rejected custom currency codes, and grant responses omitted managed currency identity.

  • Accept fiat and custom currency codes in grant list filters.
  • Return custom_currency.id consistently from create, get, list, void, and external-settlement responses.
  • Cover custom and fiat currency filters with active currencies, including both pages of a paginated grant listing.
  • Regenerate the v3 OpenAPI, server bindings, and SDKs, and update the currency identity documentation.
  • Use the shared tax-code test environment in the currency-filter and booking-time fixtures.

Validation

  • Passed HTTP schema and handler tests, credit-grant and credit-purchase package tests.
  • Passed PostgreSQL grant, settlement, cost-basis, void, currency-filter, and pagination regressions.
  • Passed Go SDK build, vet, and tests; TypeScript typechecks and all 548 SDK tests.
  • Passed focused Go lint checks and e2e module lint.
  • Compiled the e2e module, including the new promotional and manual/pinned/dynamic custom-currency grant lifecycle scenarios.

Notes for reviewer

  • The generated Go SDK grant currency filter now takes *BillingCurrencyCode instead of *string.
  • Grant currency filters continue to exclude deleted custom currencies.
  • The new HTTP lifecycle e2e test was compiled only; no local HTTP server was running.
  • Full API generation was blocked by a missing legacy Python emitter virtualenv. Targeted v3 generation completed successfully.

Summary by CodeRabbit

  • New Features

    • Credit grants now expose their associated managed custom currency when applicable.
    • Credit grant filtering supports fiat and custom currency codes.
    • Added client support for credit balance and paginated credit transaction responses.
    • Custom-currency grants support listing, filtering, pagination, retrieval, settlement, and voiding.
  • Documentation

    • Clarified that credit-grant responses include managed currency identifiers.
  • Tests

    • Added coverage for custom-currency grant lifecycles, validation, filtering, pagination, and currency metadata.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no blocking issues were found.

Summary

Grant list filters now accept custom currency codes, and grant responses expose custom_currency.id.

  • Grant lists accept fiat and custom currency codes as filters.
  • Custom-currency grants include their managed currency ID in responses.
  • A custom-currency test fixture uses the suite tax-code helper.

Reviews (4) · Last reviewed commit: "fix(credits): preserve currency filterin..." · Reviewed by Greptile

@GAlexIHU GAlexIHU added the release-note/bug-fix Release note: Bug Fixes label Oct 20, 2026
@GAlexIHU
GAlexIHU requested a review from a team as a code owner October 20, 2026 09:57
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 490041c and 55f7334.

Files ignored due to path filters: 1
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
Files selected for processing: 8
  • api/spec/packages/aip-client-javascript/src/models/schemas.ts
  • api/spec/packages/aip-client-javascript/src/models/types.ts
  • api/v3/api.gen.go
  • api/v3/client/models_customers.go
  • api/v3/handlers/customers/credits/convert_test.go
  • openmeter/billing/charges/README.md
  • test/credits/creditgrant_customcurrency_test.go
  • test/credits/customcurrency_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Walkthrough

Credit grant contracts now expose managed custom-currency references. Currency filters use typed billing currency codes. Server conversion and client serialization support these changes. Tests cover filter validation, grant conversion, listing, pagination, and grant lifecycles.

Changes: Custom-Currency Credit Grants

Layer / File(s) Summary
Credit grant API contracts
api/spec/packages/aip/..., api/spec/packages/aip-client-javascript/src/..., api/v3/api.gen.go, api/v3/client/models_customers.go, openmeter/billing/charges/README.md
The API specification and generated clients add managed custom-currency references to credit grants. Credit grant filters use billing currency codes. The JavaScript client also includes credit-balance and transaction schemas and types, and the documentation notes that grant reads expose the managed currency ID.
Grant response mapping and filter serialization
api/v3/handlers/customers/credits/convert.go, api/v3/client/customers_credits_grants.go
Grant conversion sets the managed currency reference for custom-currency grants. Filter serialization converts the typed currency value to a query string.
Filter and grant lifecycle coverage
api/v3/test/credit_grants_test.go, api/v3/handlers/customers/credits/convert_test.go, e2e/creditgrant_customcurrency_v3_test.go, test/credits/creditgrant_customcurrency_test.go, test/credits/customcurrency_test.go
Tests cover accepted and rejected filter values, response conversion, custom-currency grant lifecycles, listing, managed currency IDs, and pagination. The test setup also obtains default tax codes through TaxCodeEnv.

Priority: Normal

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

Change: Bug fix

Possibly related PRs

Suggested labels: area/api, area/billing, kind/bug

Suggested reviewers: turip

Merge Risk: Minimal · up to 55f73

The reviewed changes are mergeable after normal checks; no actionable grant-contract or lifecycle issue was established.

Pre-merge checks: Passed 4
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely summarizes the main change: adding custom-currency support to credit-grant APIs.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Comment thread test/credits/creditgrant_customcurrency_test.go Outdated
@GAlexIHU
GAlexIHU enabled auto-merge (squash) October 20, 2026 12:34
@GAlexIHU
GAlexIHU force-pushed the codex/fix-credit-grant-custom-currencies branch from 78281d9 to 490041c Compare October 20, 2026 12:50
@GAlexIHU
GAlexIHU force-pushed the codex/fix-credit-grant-custom-currencies branch from 490041c to 55f7334 Compare October 26, 2026 13:49
@GAlexIHU
GAlexIHU merged commit a1268a7 into main Oct 26, 2026
37 checks passed
@GAlexIHU
GAlexIHU deleted the codex/fix-credit-grant-custom-currencies branch October 26, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants