Skip to content

Add x402 HTTP payment protocol: client, spec, and registry integration#128

Open
tboutron wants to merge 1 commit intoreleasefrom
codex/add-x402-protocol-integration
Open

Add x402 HTTP payment protocol: client, spec, and registry integration#128
tboutron wants to merge 1 commit intoreleasefrom
codex/add-x402-protocol-integration

Conversation

@tboutron
Copy link
Copy Markdown
Member

Motivation

  • Introduce support for an HTTP-native payment challenge/settlement protocol (x402) to allow services to respond with 402 challenges and enable automatic settlement and retry semantics.

Description

  • Add an integration spec for payments.x402 with configuration and secret schema in src/integrations/providers/x402.ts and register it in the default provider registry via registerX402Integration.
  • Implement the X402PaymentsClient (src/impls/x402-payments.ts) and shared parsing/utility code (src/impls/x402-payments.shared.ts) to parse challenge headers, create payment intents via an underlying PaymentsProvider, and attach proof tokens to retried requests.
  • Extend the payments contract types with X402PaymentRequirement, X402PaymentProof, X402FetchRequest, and X402HttpPaymentClient in payments.ts to expose the new client API surface.
  • Wire the implementation into the provider implementations and exports by adding ./impls/x402-payments to the package exports and export * from './x402-payments' in the impls index, and add a createX402PaymentsClient helper to provider-factory.ts for constructing the client using an existing settlement PaymentsProvider.
  • Add unit tests for the client logic in x402-payments.test.ts and add a registration test to providers.test.ts; update package exports entries for the newly added modules.

Testing

  • Ran the new unit tests for the x402 client via bun:test targeting src/impls/x402-payments.test.ts, and the tests passed.
  • Ran the updated providers.test.ts that checks registration of payments.x402 via bun:test, and the test passed.

Codex Task

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
contractspec-library-api Ready Ready Preview, Comment Mar 26, 2026 9:01pm
contractspec-library-landing Error Error Mar 26, 2026 9:01pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 907b9600-7212-4758-9e44-781a46f561c7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/add-x402-protocol-integration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

📋 ContractSpec Impact Analysis

⚠️ Impact analysis results not found.


Generated by ContractSpec CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant