Skip to content

Conversation

@madisoncarter1234
Copy link
Contributor

Summary

Adds response status code check before settlement in Java PaymentFilter. If the handler returns a 4xx or 5xx status code, settlement is skipped to prevent charging users for failed requests.

Problem

Currently the Java middleware settles payments regardless of whether the handler succeeded or failed. If the handler returns a 500 error, the user is still charged even though they didn't receive the content they paid for.

Go middleware already checks writer.statusCode >= 400 before settlement.
Python middleware already checks response.status_code >= 200 and response.status_code < 300 before settlement.

Changes

  • Added response.getStatus() >= 400 check before calling facilitator.settle()
  • Added unit tests for 4xx and 5xx response scenarios
  • Updated existing tests to mock resp.getStatus() appropriately

Related

Check response status before settlement in PaymentFilter.
Skip settlement if handler returns 4xx/5xx to avoid charging users for failed requests.

Matches Go/Python middleware behavior.
@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.

1 participant