Skip to content

feat: migrate to x402 v2 protocol format#9

Merged
rawgroundbeef merged 7 commits intomainfrom
feat/x402-v2-migration
Feb 1, 2026
Merged

feat: migrate to x402 v2 protocol format#9
rawgroundbeef merged 7 commits intomainfrom
feat/x402-v2-migration

Conversation

@rawgroundbeef
Copy link
Copy Markdown
Owner

@rawgroundbeef rawgroundbeef commented Feb 1, 2026

Summary

  • Normalize all 402 responses to x402 v2 format — replaces maxAmountRequired with amount, adds maxTimeoutSeconds, and ensures x402Version: 2 + accepts are included in all error responses (verify/settle failures), not just the initial 402
  • SDK middleware refactor — hoists accepts array construction before the payment header check so it's available for all 402 response paths; normalizes v1 → v2 field names in the accepts output
  • SDK types — adds optional resource, description, and outputSchema fields to PaymentRequirementsV2; makes extra optional
  • Server routes — migrates maxAmountRequiredamount across facilitator, public, and stats routes; moves resource/description to the response envelope level

Test plan

  • Lint passes (turbo lint)
  • SDK unit tests pass (vitest run — 57 tests)
  • Verify 402 responses from /pay/:productId include x402Version: 2, accepts with amount field, and resource in envelope
  • Verify 402 verify/settle failure responses include x402Version and accepts
  • Test Hono middleware path returns consistent v2 format
  • End-to-end payment flow with v2 client

🤖 Generated with Claude Code

Normalize all 402 responses to x402 v2 format: replace maxAmountRequired
with amount, add maxTimeoutSeconds, include x402Version and accepts in
all error responses (verify/settle failures), and move resource/description
to the response envelope. Also adds billing-arcade demo.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 1, 2026

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

Project Deployment Actions Updated (UTC)
openfacilitator-dashboard Ready Ready Preview, Comment Feb 1, 2026 10:41pm

Request Review

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Cover createPaymentMiddleware (Express) and honoPaymentMiddleware (Hono)
with 14 tests: 402 responses, v1→v2 normalization, verification/settlement
failures, refund protection, and multi-network accepts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
rawgroundbeef and others added 2 commits February 1, 2026 17:26
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
pnpm/action-setup@v4 conflicts when both the action's `version` key
and package.json's `packageManager` field specify a version.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Publishes @openfacilitator/core, sdk, and server to npm when their
package.json version changes on main. Compares local version against
the published version and only publishes if they differ.

Requires NPM_TOKEN repository secret.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Breaking change: middleware 402 responses now use x402 v2 format
with `accepts` array and `amount` instead of `maxAmountRequired`.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rawgroundbeef rawgroundbeef merged commit 94e3b0e into main Feb 1, 2026
3 checks passed
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