feat(python): add facilitator HTTP server#1908
Open
Bortlesboat wants to merge 1 commit intox402-foundation:mainfrom
Open
feat(python): add facilitator HTTP server#1908Bortlesboat wants to merge 1 commit intox402-foundation:mainfrom
Bortlesboat wants to merge 1 commit intox402-foundation:mainfrom
Conversation
Add create_facilitator_app() factory that wraps x402Facilitator or x402FacilitatorSync in a FastAPI application exposing the standard /supported, /verify, /settle, and /health endpoints. This brings the Python SDK to parity with the Go SDK's facilitator hosting capabilities. Supports both async and sync facilitators (sync runs in thread pool), optional CORS configuration, and V1/V2 protocol version routing. Includes 20 unit tests covering all endpoints, error handling, CORS, both facilitator variants, and response schema round-trip validation.
🟡 Heimdall Review Status
|
|
@Bortlesboat is attempting to deploy a commit to the Coinbase Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Python SDK has
x402Facilitator(logic) andHTTPFacilitatorClient(client), but no way to host a facilitator as an HTTP service. The Go SDK has this viago/http/server.go. This PR fills that gap.Adds
create_facilitator_app()— a factory function that wraps anyx402Facilitatororx402FacilitatorSyncinstance in a FastAPI application exposing the standard facilitator endpoints:GET /supported— capability discoveryPOST /verify— payment verificationPOST /settle— payment settlementGET /health— liveness checkDesign decisions
x402Facilitator(async) andx402FacilitatorSync(sync via thread pool)x402Versionin the request bodycors_originsparameter for cross-origin deploymentsVerifyResponse,SettleResponse,SupportedResponsefromx402.schemascreate_facilitator_app()is called, so the module doesn't force the dependencyUsage
Testing
20 unit tests covering:
VerifyResponse/SettleResponse/SupportedResponse)