feat(checkout): add Checkout orchestrator for one-call agent-commerce flow - #45
Merged
Merged
Conversation
… flow Composes 402-emit + verify+settle into a single 'await checkout.handle()' call. Services every merchant shape via the same primitive: - Goods sellers: wire on_settled for order persistence + mint_recipients for Stripe-multichain per-order addresses. - API sellers: wire compute_pricing for per-call billing; on_settled can return the inline API response body. - Self-custody / Stripe / mixed: rails dict is the single source of truth. - x402 only / MPP only / both: each handler is independently optional. - Gated / ungated identity: CheckoutRequest.assess is optional. Framework-neutral: handle() takes CheckoutRequest, returns CheckoutResult (body + headers + status + reference_id + settled). Domain-neutral: reference_id is a UUID; goods merchants persist as order id, API merchants treat as request id. x402 base network is auto-derived from rails['x402_base'].network. No duplicate kwarg. CheckoutRequest.raw is an escape hatch for compose_mppx hooks that need the framework's native request object.
CodeQL flagged Awaitable as unused because it only appeared inside string forward refs. All referenced types (CheckoutContext, SettleOutcome, etc.) are defined earlier in the file, so the strings aren't needed — drop them and the linter sees Awaitable as a direct reference again.
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
High-level orchestrator that collapses 402-emit + verify+settle into a single
await checkout.handle()call. Services every merchant shape via the same primitive:Common usage
Goods seller (full agent-commerce):
API seller (per-call x402):
Design notes
handle()takesCheckoutRequest, returnsCheckoutResult(body + headers + status + reference_id + settled). Merchant wraps in their framework's response.reference_idis a UUID; goods merchants persist as order id, API merchants treat as request id.rails["x402_base"].network— no duplicate kwarg.CheckoutRequest.rawis an escape hatch forcompose_mppxhooks that need the framework's native request object.__init__is flat-kwargs with*keyword-only marker; all dataclasses are value types (data shapes for inputs/outputs), not parameter-bundle wrappers.Test plan
pytestgreen (1076 tests pass; coverage 95.17%)ty checkcleanruff checkcleanvulturecleantests/test_checkout.pycovers every flexibility axis