Conversation
Added note about token support for facilitators.
There was a problem hiding this comment.
Pull request overview
This PR integrates x402 protocol v2 with significant architectural changes to support multi-chain payments, CAIP-2 network identifiers, and a version strategy pattern. The default protocol version is now v2, with backward compatibility for v1 maintained through a strategy pattern.
Key changes:
- Implements version strategy pattern (V1, V2) with protocol-specific headers, network formats, and requirement structures
- Adds multi-chain payment support via
config.accept()allowing simultaneous acceptance of payments on multiple chains - Introduces custom chain and token registration for EVM networks beyond built-in options
- Updates PaymentRequirement and PaymentPayload to handle both v1 and v2 formats with CAIP-2 network normalization
Reviewed changes
Copilot reviewed 20 out of 21 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/x402/versions/v2_spec.rb | Comprehensive tests for v2 strategy: CAIP-2 formatting, PAYMENT-SIGNATURE header, amount field usage |
| spec/x402/versions/v1_spec.rb | Tests for v1 legacy strategy: internal network format, X-PAYMENT header, maxAmountRequired field |
| spec/x402/requirement_generator_spec.rb | Tests for multi-version requirement generation, multiple accepts, Solana support, and version overrides |
| spec/x402/configuration_spec.rb | Tests for custom chain/token registration, multi-chain accept configuration, and effective_accepted_payments |
| spec/x402/chains_spec.rb | Tests for CAIP-2 mapping, custom chains, token configuration, and asset address resolution |
| lib/x402/versions/v2.rb | V2 strategy implementation with CAIP-2 formatting, new headers, and v2-specific requirement structure |
| lib/x402/versions/v1.rb | V1 legacy strategy with internal network format and original header names |
| lib/x402/versions/base.rb | Abstract base class defining version strategy interface |
| lib/x402/versions.rb | Factory method for version strategy instantiation |
| lib/x402/requirement_generator.rb | Updated to support multi-chain accepts, version-specific formatting, and Solana fee payer handling |
| lib/x402/rails/controller_extensions.rb | Enhanced paywall logic with version-aware headers, network matching, and requirement generation |
| lib/x402/payment_requirement.rb | Added version-aware to_h method, CAIP-2 network normalization, and max_amount_required alias |
| lib/x402/payment_payload.rb | Extended for v2 with accepted/resource_info fields, network normalization, and version-specific serialization |
| lib/x402/configuration.rb | Added accept(), register_chain(), register_token() methods and version/fee_payer configuration |
| lib/x402/chains.rb | Extended with Solana chains, CAIP-2 mapping, custom chain support, and fee payer configuration |
| lib/x402/rails/version.rb | Bumped version to 1.0.0 for v2 protocol support |
| lib/x402/rails/generators/templates/x402_initializer.rb | Updated default facilitator URL to include www subdomain |
| README.md | Added extensive documentation for v2 features, custom chains/tokens, multi-chain accepts, and protocol versions |
| CHANGELOG.md | Documents v2 integration, multi-chain support, and breaking changes |
| Gemfile.lock | Updated to reflect new gem version 1.0.0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
luccastera
previously approved these changes
Jan 7, 2026
luccastera
approved these changes
Jan 8, 2026
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.
Note
Enables protocol v2 by default with CAIP-2 identifiers and updated HTTP transport, plus flexible network/token support.
versions/v1,versions/v2) with new headers (PAYMENT-SIGNATURE,PAYMENT-RESPONSE,PAYMENT-REQUIRED) and CAIP-2 network formattingconfig.acceptand per-accept wallet addresses; refactor requirement generation to output v1/v2 formatsPaymentPayload/PaymentRequirementto v2 shapes (amount, nestedaccepted, top-levelresource) while keeping v1 compatibility1.0.0; update README, CHANGELOG, initializer, and tests to cover new behaviorsWritten by Cursor Bugbot for commit 0ec2b24. This will update automatically on new commits. Configure here.