Skip to content

fix(x402): verify and settle payments in Vercel serverless (#107) - #374

Merged
Emmy123222 merged 1 commit into
Emmy123222:mainfrom
DevRushd:fix/107-vercel-x402-verify
Sep 3, 2026
Merged

fix(x402): verify and settle payments in Vercel serverless (#107)#374
Emmy123222 merged 1 commit into
Emmy123222:mainfrom
DevRushd:fix/107-vercel-x402-verify

Conversation

@DevRushd

Copy link
Copy Markdown
Contributor

The Vercel search function previously performed a paid search whenever any payment-signature or x-payment header existed, without facilitator verification or settlement. This allowed forged, malformed, expired, and underpaid payments to reach Serper.

Changes:

  • api/search.ts: use HTTPFacilitatorClient.verify() and .settle() to validate payment before granting search access
  • Decode payment payload from header using decodePaymentSignatureHeader
  • Build payment requirements from shared x402Config module
  • Never trust header presence alone — every payment is verified
  • Forged, malformed, expired, and underpaid payments rejected with 402
  • 14 new verification tests covering all rejection paths

Rejection cases now handled:

  • Invalid/malformed base64 payment headers
  • Facilitator verify returns isValid: false (forged, expired, wrong amount)
  • Facilitator verify throws (network errors)
  • Facilitator settle returns success: false (settlement failure)
  • Facilitator settle throws (network errors)
  • Header presence without valid payload

Closes #107

@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

@DevRushd is attempting to deploy a commit to the Emmanuel's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@DevRushd Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

…2#107)

The Vercel search function previously performed a paid search whenever
any payment-signature or x-payment header existed, without facilitator
verification or settlement. This allowed forged, malformed, expired,
and underpaid payments to reach Serper.

Changes:
- api/search.ts: use HTTPFacilitatorClient.verify() and .settle() to
  validate payment before granting search access
- Decode payment payload from header using decodePaymentSignatureHeader
- Build payment requirements from shared x402Config module
- Never trust header presence alone — every payment is verified
- Forged, malformed, expired, and underpaid payments rejected with 402
- 14 new verification tests covering all rejection paths

Rejection cases now handled:
- Invalid/malformed base64 payment headers
- Facilitator verify returns isValid: false (forged, expired, wrong amount)
- Facilitator verify throws (network errors)
- Facilitator settle returns success: false (settlement failure)
- Facilitator settle throws (network errors)
- Header presence without valid payload

Closes Emmy123222#107

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@DevRushd
DevRushd force-pushed the fix/107-vercel-x402-verify branch from 67a33e7 to 0b9739b Compare September 2, 2026 11:40
@DevRushd

DevRushd commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@AbuJulaybeeb I have resolved conflicts and rebase the branch. Kindly review and merge

@Emmy123222
Emmy123222 merged commit 6226f5f into Emmy123222:main Sep 3, 2026
0 of 2 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.

Verify x402 payments in the Vercel search function instead of trusting header presence

2 participants