Skip to content

fix(x402): update payment headers to v2 spec#20

Open
arc0btc wants to merge 1 commit into
mainfrom
fix/x402-v2-payment-headers
Open

fix(x402): update payment headers to v2 spec#20
arc0btc wants to merge 1 commit into
mainfrom
fix/x402-v2-payment-headers

Conversation

@arc0btc
Copy link
Copy Markdown
Owner

@arc0btc arc0btc commented Mar 16, 2026

Summary

  • Migrates Ask Arc endpoint (/api/ask-arc) from legacy x-402-payment header format to x402 v2 spec
  • Updates handlers.ts to use lib/x402.ts (same pattern as research routes) — returns payment-required header on 402, accepts payment-signature, returns payment-response on 200
  • Fixes Services page curl example and interactive form to show correct v2 two-step flow (probe → pay)
  • Updates landing page fallback with correct v2 header names and relay discovery link

Before: x-402-payment: stx:{address}:{txid}:{amount}:STX (custom, non-standard)
After: payment-required / payment-signature / payment-response (x402 v2 standard, base64-encoded JSON payloads, relay settlement via x402-relay.aibtc.com)

Test plan

  • Verify POST /api/ask-arc without payment returns 402 with payment-required header
  • Verify payment-required header decodes to valid PaymentRequiredV2 JSON
  • Verify POST /api/ask-arc with valid payment-signature header returns 200 + payment-response
  • Verify Services page shows correct v2 curl example
  • Verify landing page (fallback) shows correct v2 example
  • Build client: npm run build:client succeeds

🤖 Generated with Claude Code

Migrate Ask Arc endpoint from legacy x-402-payment header format
(stx:{address}:{txid}:{amount}:STX) to x402 v2 spec using standard
headers: payment-required, payment-signature, payment-response.

- handlers.ts: Use lib/x402 buildPaymentRequired + verifyPayment
  (same pattern as research routes), return payment-required on 402
  and payment-response on 200
- Services.tsx: Update curl example to show v2 two-step flow (probe
  then pay), fix AskArcForm to send payment-signature header with
  base64-encoded PaymentPayloadV2, update button text to sats
- landing.ts: Update curl example to show v2 flow with correct
  header names and relay discovery link

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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