feat: flatten x402 verify+settle+validate builders to kwargs - #33
Merged
Conversation
Drops the wrapper construction for the three x402 helpers:
- validate_x402_network_config(ValidateX402NetworkConfigInput(base_network=X))
→ validate_x402_network_config(base_network=X)
- verify_x402_request(VerifyX402RequestInput(headers=..., is_cached_address=..., accepted_network=...))
→ verify_x402_request(headers=..., is_cached_address=..., accepted_network=...)
- process_x402_settle(ProcessX402SettleInput(x402_server=..., payload=..., resource_config=..., resource_meta=..., extension=..., transport_context=...))
→ process_x402_settle(x402_server=..., payload=..., resource_config=..., resource_meta=..., extension=..., transport_context=...)
Deleted from public exports: ProcessX402SettleInput, VerifyX402RequestInput,
ValidateX402NetworkConfigInput.
Kept: ProcessX402SettleSuccess, ProcessX402SettleFailure, ProcessX402SettleResult,
VerifyX402RequestSuccess, VerifyX402RequestFailure, VerifyX402RequestResult,
ClassifiedX402Error — consumers pattern-match on these.
Tests: 1031 passed / 3 skipped, 95.10% coverage. ty + ruff clean.
examples/multi_rail_merchant.py migrated.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
vvillait88
added a commit
that referenced
this pull request
May 14, 2026
…gs (#34) ## Summary Drops the wrapper construction for the 5 payment-side builders in `directive.py`, `headers.py`, and `settlement_override.py`. Same pattern as #32 + #33. ## Builders flattened | Before | After | |---|---| | `build_payment_request_blob(PaymentRequestInput(...))` | `build_payment_request_blob(*, amount_usd, rail=None, ...)` | | `payment_directive(PaymentDirectiveInput(...))` | `payment_directive(*, id, realm, request, rail=None, ...)` | | `build_payment_directive(BuildPaymentDirectiveInput(...))` | `build_payment_directive(*, rail, id, realm, amount_usd, ...)` | | `build_payment_headers(BuildPaymentHeadersInput(...))` | `build_payment_headers(*, rails=None, order_id="", realm="", x402=None)` | | `settlement_override_header(SettlementOverrides(amount=X))` | `settlement_override_header(*, amount=X)` | ## Deleted from exports `PaymentRequestInput`, `PaymentDirectiveInput`, `BuildPaymentDirectiveInput`, `BuildPaymentHeadersInput`, `SettlementOverrides`. ## Kept (data shapes consumers construct) `PaymentHeadersRail`, `PaymentHeadersResult`, `X402AcceptsBlock`. ## Test plan - [x] `uv run pytest tests/` — 1031 passed / 3 skipped, 95.05% coverage - [x] `uv run ty check agentscore_commerce/` — clean - [x] `uv run ruff check . && uv run ruff format .` — clean - [x] Migrated callers: `tests/test_payment_{directive,headers,misc}.py`, `examples/api_provider.py`, `examples/variable_cost_merchant.py`, `agentscore_commerce/discovery/probe.py` Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Drops the wrapper construction for the three x402 helpers. Same pattern as the challenge flatten in #32: same call shape Node already uses, internal-only consumers update in lockstep.
validate_x402_network_config(ValidateX402NetworkConfigInput(base_network=X))validate_x402_network_config(base_network=X)verify_x402_request(VerifyX402RequestInput(headers=..., is_cached_address=..., accepted_network=...))verify_x402_request(headers=..., is_cached_address=..., accepted_network=...)process_x402_settle(ProcessX402SettleInput(x402_server=..., payload=..., resource_config=..., resource_meta=..., extension=..., transport_context=...))process_x402_settle(x402_server=..., payload=..., resource_config=..., resource_meta=..., extension=..., transport_context=...)Deleted from exports
ProcessX402SettleInput,VerifyX402RequestInput,ValidateX402NetworkConfigInput.Kept
Result/failure dataclasses + tagged-error type (consumers pattern-match):
ProcessX402SettleSuccess,ProcessX402SettleFailure,ProcessX402SettleResult,VerifyX402RequestSuccess,VerifyX402RequestFailure,VerifyX402RequestResult,ClassifiedX402Error.Test plan
uv run pytest tests/— 1031 passed / 3 skipped, 95.10% coverageuv run ty check agentscore_commerce/— cleanuv run ruff check . && uv run ruff format .— cleanexamples/multi_rail_merchant.pymigrated