fix(checkout): populate outcome.rail_key from MPP receipt method - #51
Merged
Conversation
_handle_mppx previously defaulted SettleOutcome.rail_key to the literal "tempo" (the field default on MppxComposeOutcome) when the compose hook didn't set it explicitly. With Tempo + Solana + Stripe rails registered, every MPP settle reported the same rail_key, so merchants could not tell Solana settles from Tempo settles (both report rail="mpp"). The rail_key field was designed for exactly this distinction but was never populated authoritatively. Read the credential method off the MPP receipt (composed.raw["receipt"] or composed.raw.receipt -- the auto-built compose hook exposes the pympp Receipt object directly via raw) and map to the merchant's rails-dict key by iterating self.rails and matching against TempoRailSpec / SolanaMppRailSpec / StripeRailSpec via isinstance. Falls through to the existing _mpp_rail_key() heuristic only when the receipt has no method or no rail matches. Also bumps minor deps via uv sync --upgrade: click 8.3.3 -> 8.4.0, pympp 0.7.0 -> 0.8.0, python-multipart 0.0.28 -> 0.0.29, ty 0.0.36 -> 0.0.37. Version: 2.0.2. 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
_handle_mppxnow derivesoutcome.rail_keyfrom the credential's receipt method (tempo/solana/stripe) and maps it to the merchant's rails-dict key viaisinstancechecks againstTempoRailSpec/SolanaMppRailSpec/StripeRailSpec. Falls back to_mpp_rail_key()only when no signal is present._rails_key_for_mppx_method()helper and two unit tests (matching + missing-rail) covering the new path.uv sync --upgrade:click8.3.3 → 8.4.0,pympp0.7.0 → 0.8.0,python-multipart0.0.28 → 0.0.29,ty0.0.36 → 0.0.37.Why
SettleOutcome.railis binary ("x402"|"mpp"), so Tempo, Solana, and Stripe SPT settles all surface asrail="mpp". TheMppxComposeOutcome.rail_keyfield defaults to the literal"tempo"and the auto-built compose hook never set it from the receipt, so every MPP settle reported the samerail_key. Two downstream effects:rail_keyonly ever fired for the first MPP rail.Mirrors the same fix in
node-commerce(cross-language parity).Test plan
uv run ruff check .— cleanuv run ruff format .— cleanuv run ty check agentscore_commerce/— cleanuv run pytest tests/— 1205 passed, 4 skipped, coverage 95.20% (≥95% threshold)🤖 Generated with Claude Code