Skip to content

feat(billing): Add charge service and capture charge endpoint#206

Merged
noahsmartin merged 9 commits intomainfrom
billing/charge-service
Apr 22, 2026
Merged

feat(billing): Add charge service and capture charge endpoint#206
noahsmartin merged 9 commits intomainfrom
billing/charge-service

Conversation

@noahsmartin
Copy link
Copy Markdown
Contributor

@noahsmartin noahsmartin commented Apr 21, 2026

Introduces a new charge service under billing/v1/services with a CaptureCharge endpoint. The request carries payment intent details and an optional invoice reference; the response reports whether the charge was paid and an optional failure code for downstream error handling.

Two other endpoints that will belong in charge service but we don't need yet for the first milestone are:

  • list charges (for a frontend page showing a user their charges)
  • charge for invoice_id

Introduces a new charge service under billing/v1/services with a
CaptureCharge endpoint. The request carries payment intent details and
an optional invoice reference; the response reports whether the charge
was paid and an optional failure code for downstream error handling.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

The latest Buf updates on your PR. Results from workflow ci / buf-checks (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedApr 21, 2026, 7:43 PM

Comment thread proto/sentry_protos/billing/v1/services/charge/v1/endpoint_capture_charge.proto Outdated
Comment thread proto/sentry_protos/billing/v1/services/charge/v1/endpoint_capture_charge.proto Outdated
Comment thread proto/sentry_protos/billing/v1/services/charge/v1/endpoint_capture_charge.proto Outdated
bool perform = 1;
int64 amount = 2;
string description = 3;
string payment_intent = 4;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this? can it be an enum?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it comes from stripe, so I don't think it can, will double check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to punt on this for now and just removed it. It's definitely not an enum, it's an ID provided by stripe when a payment needs to be retried due to some security verification. Figured that might warrant a separate charge service endpoint but no need to worry about it in phase 1

Comment thread proto/sentry_protos/billing/v1/services/charge/v1/endpoint_capture_charge.proto Outdated
noahsmartin and others added 3 commits April 21, 2026 12:29
Replace the perform boolean with a ChargeMethod enum so callers can
distinguish between recording a charge locally (NONE) and billing via
Stripe (STRIPE). Rename amount to amount_cents to make the unit
explicit, switch organization_id to uint64 to match other billing
endpoints, and drop payment_intent from the request.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Allow callers to omit a human-readable description when capturing a
charge, so internal or system-initiated charges are not forced to
fabricate one.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread proto/sentry_protos/billing/v1/services/charge/v1/endpoint_capture_charge.proto Outdated
noahsmartin and others added 2 commits April 21, 2026 12:38
Close the gap left by removing payment_intent so field numbers remain
contiguous. Safe to renumber since the proto has not been released.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment on lines +26 to +29
message CaptureChargeResponse {
bool paid = 1;
optional string failure_code = 2;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't you want to return the charge id here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hoping it would not be necessary, there isn't any other API that allows you to provide a charge id so not sure why that would need to be exposed

noahsmartin and others added 2 commits April 21, 2026 12:42
Add CHARGE_METHOD_UNSPECIFIED as the zero value so unset charge_method
fields are not silently treated as NONE, which could let Stripe-bound
charges skip billing. Switch amount_cents to uint64 to match other
monetary fields in the billing protos and prevent callers from
accidentally passing negative debits.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b40676f. Configure here.

@noahsmartin noahsmartin merged commit 9cff533 into main Apr 22, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants