-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
Description
Context
During review of PR #159, the test server endpoints (/api/protected, /api/extensions-echo) were identified as returning only payment requirements without actually processing payments. The tests expect result.success and result.message responses after payment, but the server doesn't verify or settle payments.
Requested Changes
Implement proper payment verification and settlement in the E2E test server:
- Add middleware to extract and verify payment headers from incoming requests
- Integrate with the @x402x/facilitator-sdk to verify payment signatures and commitments
- Call the facilitator's settle method to execute on-chain settlement
- Return appropriate success/error responses to the client
Suggested Approach
- Create a payment middleware utility in
test/e2e/anvil/payment-middleware.ts - Extract payment headers (PAYMENT-SIGNATURE, PAYMENT-PAYLOAD) from requests
- Use the facilitator SDK's
verify()method to validate payment signatures - Call
settle()to execute the settlement transaction - Return JSON response with success status and message
- Handle errors gracefully and return payment requirements for invalid payments
Files to Modify
test/e2e/anvil/local-chain.test.ts- Add payment middleware to test server endpoints- (Optional) Create
test/e2e/anvil/payment-middleware.tsfor reusable middleware
Related PR
Deferred from PR #159 comment #2652058521
Reactions are currently unavailable