feat(billing-platform): add refund types and endpoints for charge.refunded flow#298
Draft
armcknight wants to merge 4 commits into
Draft
feat(billing-platform): add refund types and endpoints for charge.refunded flow#298armcknight wants to merge 4 commits into
armcknight wants to merge 4 commits into
Conversation
…unded flow Adds the proto contracts needed to handle refunds on the billing platform (REVENG-157): - `common/v1/stripe_charge.proto`: new `StripeRefund` message + `repeated refunds` on `StripeCharge` so webhooks can convey per-refund metadata (id, amount, reason) for idempotent ingestion. - `services/charge/v1/charge.proto`: new `PlatformRefund` canonical projection paralleling `PlatformCharge`. - `services/charge/v1/endpoint_refund_charge.proto`: `ChargeService.refund_charge` for admin-initiated refunds (calls Stripe + records `PlatformRefund`). - `services/charge/v1/endpoint_list_refunds.proto`: `ChargeService.list_refunds_by_invoice` so presentation surfaces can render invoice-level refund state without crossing service boundaries. - `services/invoicer/v1/endpoint_handle_charge_refunded.proto`: `InvoicerService.handle_charge_refunded`, mirrors `handle_charge_succeeded` for the `charge.refunded` webhook path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest Buf updates on your PR. Results from workflow ci / buf-checks (pull_request).
|
Webhook-side counterpart to ``refund_charge``. Records ``PlatformRefund`` rows idempotently from a ``StripeCharge`` payload (the Stripe-side refund has already happened) and syncs aggregate refund state on the stored ``PlatformCharge``. Allows the presentation handler for ``charge.refunded`` to record refunds without crossing service boundaries to the charge service's models. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the proto contracts needed to handle refunds on the billing platform (REVENG-157).
common/v1/stripe_charge.proto: newStripeRefundmessage +repeated refundsonStripeChargeso webhooks can carry per-refund metadata (id, amount, reason) for idempotent ingestion. The aggregateamount_refundedalone isn't enough to dedupe refunds by Stripe refund id.services/charge/v1/charge.proto: newPlatformRefundcanonical projection, parallelingPlatformCharge.services/charge/v1/endpoint_refund_charge.proto:ChargeService.refund_charge— admin-initiated refund (calls Stripe + recordsPlatformRefund, with over-refund guard and optimistic locking implemented service-side).services/charge/v1/endpoint_record_charge_refunds.proto:ChargeService.record_charge_refunds— webhook-side counterpart (Stripe already refunded; just recordsPlatformRefundrows idempotently and syncs aggregates). Lets thecharge.refundedpresentation handler avoid importing the charge service's models directly.services/charge/v1/endpoint_list_refunds.proto:ChargeService.list_refunds_by_invoiceso presentation surfaces can render invoice-level refund state without crossing the charge service boundary.services/invoicer/v1/endpoint_handle_charge_refunded.proto:InvoicerService.handle_charge_refunded— mirrorshandle_charge_succeededfor thecharge.refundedwebhook path.Stack
This is the bottom of a stack for REVENG-157. Follow-up getsentry PRs that consume these contracts:
PlatformRefundmodel +ChargeService.refund_charge/record_charge_refunds/list_refunds_by_invoiceimplementationcharge.refundedwebhook +InvoicerService.handle_charge_refundedKept draft while the full stack is built and tested end-to-end at the top.
Test plan
make build-pyregenerates without errors🤖 Generated with Claude Code