Skip to content

fix(ledger): guard custom currency charge payments - #4853

Merged
turip merged 1 commit into
mainfrom
feat/om-435-custom-currency-payment-guards
Aug 5, 2026
Merged

turip merged 1 commit into
mainfrom
feat/om-435-custom-currency-payment-guards

Conversation

@turip

@turip turip commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

Summary

  • reject custom-currency payment authorization in the flat-fee and usage-based ledger adapters
  • reject custom-currency payment settlement through the same explicit unsupported-currency error

Behavioral change

Custom-currency overage accrual is not yet supported by the ledger adapters, but the payment handlers did not enforce the same boundary. If reached independently, they could attempt to resolve a custom-currency receivable using a fiat payment amount.

The payment handlers now return ErrCustomCurrencyNotSupported before resolving or committing a ledger transaction. Fiat charge payment behavior is unchanged. These guards are intentionally temporary and should be removed when OM-435 implements fiat settlement for custom-currency overage.

Validation

go test ./openmeter/ledger/chargeadapter

Ticket: OM-435

Summary by CodeRabbit

  • Bug Fixes
    • Added clear validation when authorizing and settling flat-fee payments with custom currencies.
    • Added the same validation for usage-based payments.
    • Custom-currency transactions are now rejected early with a consistent, actionable error instead of proceeding through payment processing.

Greptile Summary

This PR prevents unsupported custom-currency payment transactions from reaching ledger resolution or commit.

  • Adds early custom-currency rejection to flat-fee payment authorization and settlement.
  • Adds equivalent guards to usage-based payment authorization and settlement.
  • Preserves existing fiat payment behavior and wraps the shared unsupported-currency sentinel for error inspection.

Confidence Score: 5/5

The PR appears safe to merge, with unsupported custom-currency payments rejected before ledger mutations while fiat behavior remains unchanged.

The four new checks return the shared unsupported-currency error before transaction resolution or commit, and current workflow ordering does not expose a conflicting reachable no-op path.

Important Files Changed

Filename Overview
openmeter/ledger/chargeadapter/flatfee.go Adds correctly positioned custom-currency guards before flat-fee payment transaction resolution and ledger commits.
openmeter/ledger/chargeadapter/usagebased.go Adds matching custom-currency guards to usage-based authorization and settlement; no currently reachable regression was identified.

Reviews (1): Last reviewed commit: "feat: guard custom currency payments" | Re-trigger Greptile

Context used:

@coderabbitai

coderabbitai Bot commented Aug 4, 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 Plus

Run ID: 30bb0d97-d084-4347-ba51-d4a3f769ba85

📥 Commits

Reviewing files that changed from the base of the PR and between 887e0ca and a5636e4.

📒 Files selected for processing (2)
  • openmeter/ledger/chargeadapter/flatfee.go
  • openmeter/ledger/chargeadapter/usagebased.go

📝 Walkthrough

Walkthrough

Flat-fee and usage-based charge adapters now reject custom currencies in payment authorization and settlement handlers. Each handler returns a wrapped meta.ErrCustomCurrencyNotSupported error before processing continues.

Changes

Custom currency validation

Layer / File(s) Summary
Add currency guards
openmeter/ledger/chargeadapter/flatfee.go, openmeter/ledger/chargeadapter/usagebased.go
Authorization and settlement handlers reject custom currencies before validation or transaction processing. They return an error wrapping meta.ErrCustomCurrencyNotSupported.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the addition of guards that reject custom-currency charge payments in the ledger adapters.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/om-435-custom-currency-payment-guards

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.

@turip turip added release-note/bug-fix Release note: Bug Fixes area/billing labels Aug 4, 2026
@turip
turip marked this pull request as ready for review August 4, 2026 13:21
@turip
turip requested a review from a team as a code owner August 4, 2026 13:21
@turip
turip merged commit d2ce1a6 into main Aug 5, 2026
29 of 32 checks passed
@turip
turip deleted the feat/om-435-custom-currency-payment-guards branch August 5, 2026 09:34
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.

2 participants