Skip to content

Conversation

@matiasedgeandnode
Copy link
Collaborator

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds HTTP support for x402 payments by creating an adapter that integrates the Ampersend SDK's treasurer pattern with Coinbase's x402 v2 SDK for HTTP clients. This enables sophisticated payment authorization logic (budgets, policies, approvals) to work seamlessly with standard x402 HTTP clients like @x402/fetch.

Key Changes

  • Introduces wrapWithAmpersend() adapter function that wraps x402Client instances with treasurer-based payment hooks
  • Implements TreasurerSchemeClient for v1 protocol support using WeakMap-based storage for correlation
  • Adds comprehensive test suite covering registration, payment flows, error handling, and edge cases

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
typescript/packages/ampersend-sdk/src/x402/http/adapter.ts Core adapter implementation with TreasurerSchemeClient and wrapWithAmpersend function
typescript/packages/ampersend-sdk/src/x402/http/index.ts Module export for the HTTP adapter
typescript/packages/ampersend-sdk/src/x402/http/README.md Documentation with API reference, usage examples, and integration guide
typescript/packages/ampersend-sdk/src/x402/index.ts Exports wrapWithAmpersend to SDK's x402 module
typescript/packages/ampersend-sdk/tests/x402/http/adapter.test.ts Comprehensive test suite with 421 lines covering all adapter functionality
typescript/packages/ampersend-sdk/package.json Adds @x402/core as optional peer dependency and dev dependency
pnpm-lock.yaml Lockfile updates for @x402/core@2.1.0 dependency
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@tmigone tmigone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plgtm

@matiasedgeandnode matiasedgeandnode merged commit 486297b into main Jan 14, 2026
12 checks passed
@matiasedgeandnode matiasedgeandnode deleted the ma/http branch January 14, 2026 14:16
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.

3 participants