Skip to content

Conversation

@madisoncarter1234
Copy link
Contributor

Summary

Fixes two issues in the Go gin middleware:

  1. Missing settlement success check - Only checked for HTTP errors (err != nil), not settleResponse.Success. If facilitator returns 200 with success: false, middleware would still return protected content.

  2. Missing response status check - Settled payments even when handler returned 4xx/5xx errors, charging users for failed requests.

Changes

  • Add settleResponse.Success check after settlement
  • Add statusCode >= 400 check before calling settle
  • Update TestPaymentMiddleware_SettlementFails to expect 402 on settlement failure
  • Add TestPaymentMiddleware_HandlerErrorSkipsSettlement test

Related

…esponses

- Check settleResponse.Success before returning protected content
- Skip settlement if handler returns 4xx/5xx status code
- Update tests to expect correct behavior on settlement failure

Matches TypeScript/Python middleware behavior.
@cb-heimdall
Copy link

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

@vercel
Copy link

vercel bot commented Dec 5, 2025

@madisoncarter1234 is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants