Repository navigation
fix(billing): preserve payment authorizations on invoice retry - #5229
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: openmeterio/openmeter/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (10)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughInvoice authorization retries now accept an existing active payment when its namespace, invoice, line, and amount match. The change covers flat-fee, usage-based, and credit-purchase charges, with unit and integration tests for matching replays, conflicts, and retry results. ChangesPayment Authorization Retries
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change makes invoice authorization retries safely reuse matching existing payments, with conflicts and invalid records still rejected. No merge-blocking concerns remain. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Retries reuse a valid payment only when its namespace, invoice, line and amount match, preserving the original booking rather than authorizing it again. No introduced attack path was demonstrated. Remaining uncertainty concerns transaction boundaries and lifecycle recovery during interruptions or concurrent retries. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Overview
Invoice authorization can commit the first line's payment before a later line callback fails. Retrying the invoice replays all lines, and the existing payment previously blocked advancement.
Flat-fee, usage-based, and credit-purchase charges now acknowledge an existing valid, non-deleted payment when its namespace, invoice, line, and amount match. The original authorization and ledger references are preserved, including when the payment has already settled. Credit purchases apply this check before replaying the authorization state transition. Conflicting or invalid payment records remain errors.
Notes for reviewer
Service period is deliberately excluded from the retry identity check. Separate integration tests cover all three charge types with distinct $5 and $10 lines. They reproduce partial progress through the invoice app callback boundary, retry through the billing service, and verify that the first booking remains unchanged while exactly one authorization is added for the second line.
Validation
make lint-go-fastpasses for the affected charge services and credit tests.Summary by CodeRabbit
The PR appears safe to merge; no actionable defect was established.
Summary
The PR makes invoice authorization retries recognize matching existing payments for flat-fee, usage-based, and credit-purchase charges.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Invoice authorization callback] --> B{Charge type} B --> C[Flat-fee or usage-based run] B --> D[Credit purchase] C --> E{Existing valid matching payment?} D --> E E -- Yes --> F[Keep payment and authorization references] E -- No payment --> G[Book authorization] E -- Conflicting or invalid --> H[Return error]Reviews (1) · Last reviewed commit: "fix(billing): preserve payment authoriza..."