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

CarsonRoscoe and others added 26 commits December 1, 2025 10:50
* fix legacy example builds

* add next example

* fix format

* upgrade to next 16

* fix legacy build

* fix e2e tests
* add next route wrapper

* add protected api to example page

* add unit tests

* fix missing settle failure check

* added e2e tests for withX402

* add SettleResponse to ProcessSettleResultResponse

* add requirements to payment-header
* add express fixes from v1

* add units test for express/hono

* added fetch/axios unit tests
* Remove cdpClientKey and sessionTokenEndpoint from PaywallConfig

Remove Onramp functionality from EvmPaywall

Remove Coinbase fields from paywall template generation

* Migrate site to @x402/next with v2 protocol support

* Clean up tests

* remove CDP onramp from core paywall

* Update templates and build process

* Format

* Lockfile

* mock templates for CI

* Format

* Generate new templates

* Format
* update next/react versions

* update site to next 16, tailwind 4 and fix env vars

* fix initializeOnStart pattern
* fix ts examples

* add clients/advanced/preferred-network example
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.

4 participants