X402rClient. These represent the planned API for querying payment information once a subgraph is deployed. This page documents each method’s intended behavior and provides working alternatives you can use today.
getPaymentState
Query the current lifecycle state of a payment.Signature
Workaround: Use
merchant.getPaymentAmounts(paymentInfo) from the Merchant SDK. If capturable > 0, the payment is effectively in escrow. If both capturable and refundable are 0, the payment is settled.paymentExists
Check whether a payment has been authorized through the operator.Signature
Workaround: Watch for
AuthorizationCreated events on the PaymentOperator contract. You can query past logs using viem’s getContractEvents:isInEscrow
Check if a payment is currently held in escrow with capturable funds.Signature
Workaround: Use the working escrow period methods instead. If
isDuringEscrowPeriod returns true, the payment is still in its escrow window:getPaymentDetails
Retrieve the fullPaymentInfo struct from a payment hash.
Signature
Workaround: Store the
PaymentInfo struct locally when you first create the payment. The hash is deterministic (it is the keccak256 of the struct), so you can maintain your own mapping of hash to PaymentInfo in a local database or cache.getMyPayments
List all payment hashes where the connected wallet is the payer.Signature
Workaround: Use
watchMyPayments to track payments in real-time and accumulate them, or query AuthorizationCreated logs filtered by the payer address:Why a Subgraph Is Needed
ThePaymentOperator contract is designed for gas efficiency. It does not maintain queryable mappings of all payments. Payment lifecycle data is emitted as events (AuthorizationCreated, ReleaseExecuted, RefundInEscrowExecuted, etc.) but not stored in contract storage.
To provide these query methods, the SDK needs a subgraph (e.g., The Graph) or an indexer that:
- Indexes all
PaymentOperatorevents - Maintains a derived state machine for each payment
- Tracks payer-to-payment relationships
- Exposes a GraphQL API for efficient querying
