Skip to content

Conversation

@jolestar
Copy link

@jolestar jolestar commented Nov 1, 2025

Fixes the issue where clients lose paymentRequirements information when creating PaymentPayload by adding an optional paymentRequirements field to the schema.

Problem

Currently, PaymentPayloadSchema does not include a field for paymentRequirements. This causes the original payment requirements to be lost when clients create payments, forcing facilitators to maintain separate state to track requirements or lose access to critical information like extra fields.

Solution

Add an optional paymentRequirements field to PaymentPayloadSchema:

export const PaymentPayloadSchema = z.object({
  x402Version: z.number().refine(val => x402Versions.includes(val as 1)),
  scheme: z.enum(schemes),
  network: NetworkSchema,
  payload: z.union([ExactEvmPayloadSchema, ExactSvmPayloadSchema]),
+  paymentRequirements: PaymentRequirementsSchema.optional(), // Allow client to send back original requirements
});

fix #577

@cb-heimdall
Copy link

cb-heimdall commented Nov 1, 2025

🟡 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 1
Sum 2

@vercel
Copy link

vercel bot commented Nov 1, 2025

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

A member of the Team first needs to authorize it.

@CarsonRoscoe
Copy link
Contributor

CarsonRoscoe commented Nov 3, 2025

Despite this being a super small PR, it is fundamentally a breaking protocol change, as relying on this optional field breaks composability with any 3rd party packages.

This feedback is also already being addressed in the v2 changelog discussion and is being implemented in the v2 development branch.

In v2, the PaymentPayload object will require a accepted field denoting the payment requirements that the client accepted and fulfilled.

Closing as we are not introducing new protocol changes to v1, all new type changes are being coordinated and implemented into the v2 spec

@Mine77
Copy link
Contributor

Mine77 commented Nov 6, 2025

@CarsonRoscoe hi there. I'm a colleague with @jolestar working on the Nuwa AI project.
We've launched a user-friendly AI client with our project supporting users to pay for LLM and MCP usage.

Since we've got your attention here I wanna kindly check with you regarding wether we could get some feedback on #528

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.

Client loses paymentRequirements when creating PaymentPayload

4 participants