Skip to content

Conversation

@marcosmmb
Copy link

Description

This PR implements V2 X402Client for Python by following the TypeScript reference implementation and the proposed V2 Changelog.

Related to #482

As per the TODO guidance, I have added new x402.core, and x402.client modules. Because there's already a V1 types.py file, I have added the new types module as x402.core.types.

Tests

============================================================================================================================== test session starts ===============================================================================================================================
platform linux -- Python 3.10.6, pytest-8.4.0, pluggy-1.6.0
rootdir: /root/x402/python/x402
configfile: pytest.ini
plugins: asyncio-1.0.0, anyio-4.9.0
asyncio: mode=auto, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 104 items                                                                                                                                                                                                                                                              

tests/client/test_x402_client.py .................                                                                                                                                                                                                                         [ 16%]
tests/clients/test_base.py .......                                                                                                                                                                                                                                         [ 23%]
tests/clients/test_httpx.py .........                                                                                                                                                                                                                                      [ 31%]
tests/clients/test_requests.py ..........                                                                                                                                                                                                                                  [ 41%]
tests/fastapi_tests/test_middleware.py ............                                                                                                                                                                                                                        [ 52%]
tests/flask_tests/test_middleware.py ............                                                                                                                                                                                                                          [ 64%]
tests/test_common.py ......                                                                                                                                                                                                                                                [ 70%]
tests/test_encoding.py ...                                                                                                                                                                                                                                                 [ 73%]
tests/test_exact.py ......                                                                                                                                                                                                                                                 [ 78%]
tests/test_paywall.py ..............                                                                                                                                                                                                                                       [ 92%]
tests/test_types.py ........                                                                                                                                                                                                                                               [100%]

============================================================================================================================== 104 passed in 0.76s ===============================================================================================================================

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits

@vercel
Copy link

vercel bot commented Nov 15, 2025

@marcosmmb is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@marcosmmb marcosmmb marked this pull request as ready for review November 15, 2025 07:36
@marcosmmb marcosmmb mentioned this pull request Nov 15, 2025
@CarsonRoscoe CarsonRoscoe self-assigned this Nov 19, 2025
@marcosmmb
Copy link
Author

marcosmmb commented Nov 23, 2025

Last few commits update X402Client class with hooks and change the register_scheme/register_scheme_V1 methods to register/register_V1 to follow the standard from the TypeScript reference implementation

@phdargen
Copy link
Contributor

Hi @marcosmmb, thanks a lot for your initiative!

We have a development branch for python v2 up now with the core building blocks but there is still a lot missing.
Please have a look at this PR: #841 and let me know if you are interested in working on any of the TODO items. Your contribution would be much appreciated!

Closing this now, please target the feat/python-v2-sdk branch if you open a new PR

@phdargen phdargen closed this Dec 23, 2025
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.

3 participants