x402 (HTTP 402 Payment Required; Coinbase -> Linux Foundation, Visa/ Stripe/Circle) is where agentic-commerce momentum is, and OpenPay had no agentic acceptance path despite being built to ride it. New op-rails-x402 crate adds the protocol surface: - PaymentRequirements::for_charge(&Money, ...) -> the 402 challenge from an OpenPay charge (minor units -> atomic maxAmountRequired; the fiat Money preserved in `extra.fiat` so the merchant ledger keeps its truth) + to_402_body() (the x402Version/accepts response). - PaymentPayload encode/decode for the X-PAYMENT header (base64 of JSON) + matches() guard (scheme/network). - SettleResult + X-PAYMENT-RESPONSE; accept(req, header, settler) reference flow. - Settler trait = the on-chain edge (signature verify + settlement against a chain RPC), host-implemented per OpenPay's swappable-driver doctrine — keeps this crate network- and dependency-free. Validated standalone (3 tests green: challenge-from-Money, X-PAYMENT round-trip, accept+settle+mismatch). No new deps (op-core + serde). NOTE: the openpay workspace does NOT currently resolve due to a PRE-EXISTING issue in op-vault (`rand_core ^0.10` requested with the `getrandom` feature that rand_core 0.10 no longer has) — unrelated to this crate; `cargo build -p op-core` fails the same way. op-rails-x402 was validated against op-core in isolation. op-vault's rand_core pin needs fixing for the full workspace to build again. Co-Authored-By: Claude Opus 4.8 <[email protected]>
14 lines
663 B
TOML
14 lines
663 B
TOML
[package]
|
|
name = "op-rails-x402"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
rust-version.workspace = true
|
|
license.workspace = true
|
|
repository.workspace = true
|
|
description = "OpenPay x402 rail — the HTTP 402 'Payment Required' agentic-payment protocol (Coinbase → Linux Foundation; Visa/Stripe/Circle). Emits the 402 challenge from an OpenPay Money, parses the X-PAYMENT header, and dispatches verify+settle through a pluggable Settler seam (the on-chain edge). Lets OpenPay accept machine/agent payments."
|
|
|
|
[dependencies]
|
|
op-core = { path = "../op-core" }
|
|
serde = { workspace = true }
|
|
serde_json = { workspace = true }
|
|
thiserror = { workspace = true }
|