Define the AI agent payments integration contract
Suppose your operations agent buys a company report for an illustrative $3. The seller exposes a report API, your organization pays and the agent uses the result in a procurement brief. Write those roles down before choosing a wallet or protocol. Otherwise an apparently successful integration can hide an unanswered question about who owns the money or who owes the report.
Describe the input, permitted action and expected output. Here the input is a company identifier, the action is purchasing one report from the approved seller, and the output is a report matching that identifier. Define whether a purchase permits only retrieval or also reuse. A payment method does not answer the seller's licensing questions for you.
Create an application purchase identifier before requesting payment. This is your own record, not an invented protocol field. Link the offer, approval, payment attempt and result to that record. It should remain useful when a process restarts or a response arrives after your original request times out.
Build one complete integration
- Define roles
Organization pays; agent requests; report API sells and delivers.
Read guide ↗ - Set authority
Specify seller, purchase scope, maximum and approval route.
Read guide ↗ - Choose payment
Match the actual seller offer to a supported client and credential.
Read guide ↗ - Connect the server
Verify the payment outcome and prepare the resource.
Read guide ↗ - Record the result
Link delivery and payment evidence to the purchase identifier.
Read guide ↗
Choose a buyer API or merchant API
For the $3 report, the buyer API belongs to the purchasing application: it receives the offer, requests approval and reports the existing attempt’s status. The merchant API belongs to the report seller: it checks payment and returns the resource. An administrative interface changes funding or policy and should have separate permissions. These are recommended architecture boundaries, not official protocol field names.
The contract table lists information your AI agent payments integration should carry between these boundaries. Use the agent payments API guide for the detailed contract, the x402 protocol or Machine Payments Protocol guide for the exchange, and the seller API guide when you operate the resource. Merchant order checkout has its own API guide in Agent Commerce Guide.
Buyer and merchant API responsibilities
Scroll the table to compare all columns.
| Record | Buyer responsibility | Merchant responsibility | Evidence to retain |
|---|---|---|---|
| Request | Name company, report and allowed total | Return current price and resource terms | Accepted offer linked to purchase |
| Approval | Obtain owner decision or evaluate existing authority | Check authority required by the chosen integration | Decision and relevant terms |
| Payment result | Track one attempt and look up uncertain status | Verify the supported payment outcome | Authoritative attempt reference and state |
| Delivery result | Check company identifier and response structure | Return report or documented result-retrieval path | Report reference and validation outcome |
Choose a route that the seller actually accepts
For a paid HTTP resource, x402 provides a buyer and seller payment flow. Its documented CDP facilitator verifies and settles payments. AP2 v0.2 addresses authorization through linked mandates within commerce. Use the relevant integration for your seller and keep authority separate from the mechanism that carries value. [1] [2]
Do not start by enabling every asset or network offered by a wallet. Start with the report seller's supported path and the policy your organization needs. Confirm the actual client interface, payment method and account setup. A generic ability to send funds does not prove that a client can complete the seller's protocol exchange.
Make a brief responsibility map. Identify who checks purchase authority, who signs or supplies a credential, who submits payment, who confirms the outcome and who handles fulfillment. A provider can own several roles, but those responsibilities still exist and need observable results.
Who owns each failure?
Scroll the table to compare all columns.
| Failure | Primary owner to identify | Evidence needed |
|---|---|---|
| Offer changed | Buyer policy and seller offer service | Old and new terms plus approval decision |
| Signing denied | Buyer wallet or credential service | Policy rejection and purchase reference |
| Payment unresolved | Submitting component and payment provider | Attempt reference and authoritative status |
| Payment confirmed, report missing | Seller fulfillment and buyer recovery handler | Payment confirmation and missing-result record |
| Report does not match request | Seller resource service and buyer validator | Requested company and delivered identifier |
Keep approval outside the model decision
The operations agent can propose buying the report and explain why it is useful. A deterministic policy component should evaluate the permitted seller, amount, purpose and time window. The model's confidence in its plan is not payment authority. This is a recommended application boundary rather than a claim that every protocol supplies your entire policy engine.
For the example, allow one $3 report for the selected company and reject a changed recipient. If the seller changes the amount to $4, evaluate the new terms against the actual approval. Do not let the model rewrite the approval after seeing a more expensive offer. Keep the original permission and the new decision as separate records.
If you use a human approval step, show the final relevant terms plainly. An approval saying continue is ambiguous when the conversation contains several products. Tie the approval to the purchase record so an operator can later see exactly which seller and amount were authorized.
Implement one payment attempt with explicit states
Use states that reflect evidence: offer received, permitted, submitted, confirmed, rejected, unresolved and delivered. Your exact names can differ, but do not collapse submitted and confirmed. A request leaving your process proves submission, not final payment success.
Before submission, validate the offer and reserve any relevant application budget. Record the payment result using the selected provider's authoritative reference. If submission fails before a payment is created, the reservation can be released according to your rules. If the outcome is unknown, hold it unresolved until a status check or operator review establishes what happened.
When the seller delivers the report, validate its identifier and required structure. Store a result reference or checksum if that fits your data policy. Avoid retaining more report content than your application needs simply because an agent log can capture everything. The evidence record should support operations without becoming an uncontrolled duplicate of purchased data.
Test failures across the whole purchase
Verify the AI agent payments integration with an expired offer, a rejected approval, insufficient available budget, an unavailable payment provider and a timeout after submission. Each case should lead to a known state and an owner. The purpose is to verify your integration's decisions, not to manufacture an impressive success-rate claim.
The most revealing recovery case is payment confirmed with delivery missing. Your agent should inspect the existing purchase rather than immediately paying again. Define whether the seller supports result retrieval, support escalation or a refund process. A transaction reference alone cannot recreate a report if the seller has no recovery route.
Also try two concurrent requests under a nearly exhausted budget. If both can pass a limit check before either reserves money, your application has an accounting gap. Fix the boundary where budget is reserved instead of adding stronger wording to the model prompt.
Move from a test to a bounded operating workflow
Begin the AI agent payments integration with one allowed seller, a clear amount cap and a reviewer who can inspect outcomes. Separate test configuration from real spending and record which environment produced each result.
Keep credentials in the authorized payment component and expose only the operations the agent needs. A purchasing agent does not necessarily need permission to change recipients, alter limits or export account secrets. Review these permissions separately from the conversation instructions.
Magic Travel is an affiliated product that shows the purchase path in a working agent. In Telegram the user says where and when to fly and picks a flight. The agent then fills the checkout on the airline's own website with the user's card, asking "Yes?" for the saved passenger and card and "Pay?" for the final total. We disclose that relationship. Compare this approval step with your own integration requirements; this guide does not assign unsupported network coverage or fees.
Your acceptance record should show the $3 report purchase from beginning to end, plus the failure cases that matter. Keep protocol revision, provider configuration, expected output and recovery procedure together. Another developer should be able to explain the purchase from those records without guessing which tool response you considered final.
Agent Payment Node is the publisher’s own open-source payment runtime. For the report purchase, the agent prepares an x402 payment through the apn CLI or local MCP, and APN pays it unattended only within the x402 policy and caps the owner created in a terminal. Each payment stays a durable operation with an idempotency key and a receipt for recovery. [4]