feat(billing-platform): add ChargeService.refund_charge endpoint (REVENG-157)#304
Closed
armcknight wants to merge 3 commits into
Conversation
…le_charge_refunded endpoints Adds the proto contracts the getsentry ``charge.refunded`` webhook path will need (REVENG-157): - ``common/v1/stripe_charge.proto``: new ``StripeRefund`` message + ``repeated refunds`` field on ``StripeCharge`` so webhook handlers receive per-refund metadata (id, amount, reason) and can record refunds idempotently — the aggregate ``amount_refunded`` on the charge alone isn't enough. - ``services/charge/v1/charge.proto``: new ``PlatformRefund`` canonical projection, paralleling ``PlatformCharge``. The shared response type for every charge-service refund endpoint. - ``services/charge/v1/endpoint_record_charge_refunds.proto``: ``ChargeService.record_charge_refunds`` — records per-refund rows from a Stripe webhook payload idempotently (keyed on refund stripe_id) and syncs the aggregate ``amount_refunded`` / ``refunded`` state. - ``services/invoicer/v1/endpoint_handle_charge_refunded.proto``: ``InvoicerService.handle_charge_refunded`` — presentation handler that the webhook layer calls; delegates to ``record_charge_refunds`` and returns ``handled=False`` when the charge isn't platform so the caller falls through to legacy. The other two refund endpoints (``refund_charge``, ``list_refunds_by_invoice``) are split into separate PRs paired with their getsentry consumers. Rust bindings + Cargo.lock + python bindings regen are handled by CI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds the proto contract for admin-initiated refunds against a platform charge (REVENG-157). The endpoint takes a Stripe charge id + amount, calls Stripe to create the refund, records a ``PlatformRefund`` row, and enforces an over-refund guard so cumulative refunds against a single charge can't exceed the charge total. Builds on the ``PlatformRefund`` message added in the previous PR in this proto stack. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2 tasks
|
The latest Buf updates on your PR. Results from workflow ci / buf-checks (pull_request).
|
3 tasks
fc673f0 to
83023b0
Compare
Member
Author
|
Closing — we've decided not to support admin-initiated refunds for now. The webhook ingestion path (#303 + getsentry#20611) is the only refund flow we need; refunds originate in Stripe (e.g. via the Stripe dashboard) and are mirrored locally via charge.refunded webhooks. Leaving the branch in place in case we revisit admin-initiated refunds later. |
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
ChargeService.refund_charge, the proto contract for admin-initiated refunds. The endpoint takes a Stripe charge id + amount, calls Stripe to create the refund, records aPlatformRefundrow, and enforces an over-refund guard so cumulative refunds against a single charge can't exceed the charge total.services/charge/v1/endpoint_refund_charge.proto(new) —RefundChargeRequest(stripe_charge_id, amount, optional reason) andRefundChargeResponse(refund, charge).Reuses the
PlatformRefundandPlatformChargemessages fromcharge.proto(extended by #303).Proto stack
StripeRefund+PlatformRefundshared types,record_charge_refunds,handle_charge_refundedendpoint_refund_charge.protoendpoint_list_refunds.protoStacked on #303 (for
PlatformRefund). Sibling to #305 — independent of each other.Test plan
sentry-protospin is bumped🤖 Generated with Claude Code