Skip to content

refactor(challenge): build_accepted_methods + build_how_to_pay consume *RailSpec; async - #41

Merged
vvillait88 merged 1 commit into
mainfrom
feat/304b-accepted-methods-how-to-pay-railspec
May 14, 2026
Merged

refactor(challenge): build_accepted_methods + build_how_to_pay consume *RailSpec; async#41
vvillait88 merged 1 commit into
mainfrom
feat/304b-accepted-methods-how-to-pay-railspec

Conversation

@vvillait88

Copy link
Copy Markdown
Contributor

Summary

`build_accepted_methods` and `build_how_to_pay` now accept `*RailSpec` instances directly instead of plain dicts. The helpers are async because `RecipientLike` supports async factories (used by Stripe-multichain merchants that mint fresh deposit addresses per PaymentIntent).

Single canonical type per rail: vendors declare one `TempoRailSpec` / `X402BaseRailSpec` / `SolanaMppRailSpec` / `StripeRailSpec` / `TempoSessionRailSpec` and pass the same instance to every helper.

rails = {
    "tempo": TempoRailSpec(recipient=tempo_addr),
    "x402_base": X402BaseRailSpec(recipient=base_addr),
    "solana_mpp": SolanaMppRailSpec(recipient=solana_addr),
    "stripe": StripeRailSpec(profile_id=os.environ["STRIPE_PROFILE_ID"]),
}
accepted = await build_accepted_methods(**rails)
how_to_pay = await build_how_to_pay(url=..., retry_body_json=..., total_usd=..., rails=rails)

`build_how_to_pay` does not resolve `RecipientLike` factories — the block surfaces CLI commands, none of which include the recipient string. `build_accepted_methods` does resolve, since each entry carries `pay_to`.

Migrates the existing test suite + `multi_rail_merchant` example inline. Other examples (api_provider, variable_cost_merchant, ...) migrate in follow-up PRs.

Test plan

  • `uv run pytest tests/` — 1048 passed, 95.09% coverage
  • `uv run ty check` — clean
  • `uv run ruff check` — clean

🤖 Generated with Claude Code

…e *RailSpec; async

build_accepted_methods and build_how_to_pay now accept *RailSpec instances
directly instead of plain dicts. The helpers are async because RecipientLike
supports async factories (used by Stripe-multichain merchants that mint fresh
deposit addresses per PaymentIntent).

Single canonical type per rail: vendors declare one TempoRailSpec /
X402BaseRailSpec / SolanaMppRailSpec / StripeRailSpec / TempoSessionRailSpec
and pass the same instance to every helper. No more restating the same
recipient across four different per-helper config shapes.

Migrates the existing test suite + multi_rail_merchant example inline.
Scrubs internal version annotations from rail_spec docstrings in both SDKs
as part of the same diff.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vvillait88
vvillait88 merged commit ea8420f into main May 14, 2026
7 checks passed
@vvillait88
vvillait88 deleted the feat/304b-accepted-methods-how-to-pay-railspec branch May 14, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant