Skip to content

Conversation

@lucasacoutinho
Copy link

Description

This PR adds initial PHP server support for the x402 protocol.

Tests

Core Library (php/x402)

cd php/x402 && composer test

24 tests passing covering:

  • AmountTest - Currency conversions (decimal ↔ USDC base units)
  • NetworkTest - Chain IDs, testnet detection, USDC addresses, custom network registration
  • PaymentPayloadTest - Base64 encoding/decoding, validation, error handling
  • PaymentRequirementsTest - Requirements creation and serialization

Laravel Package (php/x402-laravel)

cd php/x402-laravel && composer test

52 tests covering:

Unit tests:

  • Exception classes and error messages
  • PendingPayment fluent builder API

Feature tests:

  • DiscoveryTest - Resource registration, pagination, metadata filtering, auto-discovery of paid routes, JSON endpoint responses
  • EventsTest - PaymentVerified, PaymentSettled, PaymentFailed event dispatching
  • MacrosTest - Route::paid() macro, $request->payer(), $request->requirements() macros
  • RequirePaymentMiddlewareTest - 402 responses, header validation, payment verification, settlement flow
  • RequirePaymentTest - Full middleware integration with mock facilitator

Manual Testing

Verified the Laravel example app runs successfully:
cd examples/php/servers/laravel && docker compose up

Tested endpoints:

  • GET /free - Returns 200 (no payment required)
  • GET /weather - Returns 402 with payment requirements
  • GET /discovery/resources - Returns discovery JSON

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits

@cb-heimdall
Copy link

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@vercel
Copy link

vercel bot commented Nov 27, 2025

@lucasacoutinho is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants