Check if a task requires payment
Get payment requirements from a task
Select the best payment option from requirements
Payment requirements with accepts array
OptionalpreferredNetwork: stringPreferred network (CAIP-2 format)
OptionalpreferredScheme: stringPreferred scheme (e.g., 'exact', 'upto')
The best matching payment option or undefined
Create a payment payload using a mechanism client
The scheme/network client to use
Payment requirements to fulfill
Promise resolving to the payment payload
Create a payment submission message
The payment payload to submit
Optional text message
A2A message with payment metadata
Handle a complete payment flow for a task
This is a convenience method that checks for payment requirements, creates a payload, and returns a payment message.
The A2A task that may require payment
The mechanism client to use for signing
OptionalpreferredNetwork: stringOptional preferred network
OptionalpreferredScheme: stringOptional preferred scheme
A2A message with payment, or undefined if no payment needed
Extract payment requirements from an embedded-flow task. Scans task artifacts for CartMandate DataPart with x402 method data.
The A2A task with CartMandate artifacts
x402 payment requirements or undefined
Create a payment message for the AP2 embedded flow. Wraps the PaymentPayload inside a PaymentMandate DataPart.
Payment mandate contents (without payment_response)
The x402 payment payload
OptionaluserAuthorization: stringOptional user authorization (Verifiable Presentation)
Optional text message
A2A message with PaymentMandate DataPart
A2A Payment Client
Provides methods for handling t402 payments in A2A client agents.
Example