feat: pluggable paymentHandler hook for x402 integration#16
Merged
acedatacloud-dev merged 3 commits intomainfrom Apr 19, 2026
Merged
feat: pluggable paymentHandler hook for x402 integration#16acedatacloud-dev merged 3 commits intomainfrom
acedatacloud-dev merged 3 commits intomainfrom
Conversation
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.
What
Adds a pluggable
paymentHandler(TS) /payment_handler(Python) hook to the SDK transport. When the API returns402 Payment Required, the transport now:acceptslist to the configured handlerX-Payment)Why
Previously the SDK only supported Bearer-token auth, and
@acedatacloud/x402-clienthad to reinvent its own HTTP client to do x402 flows. That meant two parallel ways of calling the same APIs, and features like task polling / streaming / retries were missing from the x402 path.With this hook, the SDK stays the single entry point for every AceDataCloud endpoint, and X402Client becomes a small adapter that produces a
paymentHandler.Usage
Python accepts any callable returning
{"headers": {"X-Payment": ...}}(sync or async).Changes
runtime/payment.ts,TransportacceptspaymentHandler,apiTokenbecomes optional when a handler is supplied_runtime/payment.py,SyncTransport/AsyncTransportacceptpayment_handler, async transport awaits coroutines transparentlyCompanion PR in X402Client: https://github.com/AceDataCloud/X402Client/pulls (will be opened next).