Write the purchase contract first
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 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
Prepare 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 with one allowed seller, a clear amount cap and a reviewer who can inspect outcomes. Separate configuration for a test environment from real spending. Record which environment produced each result so a test payment is never presented as production evidence.
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.
MagicPay is an affiliated product that connects an AI agent to payment and purchase workflows with approval. Its product route is relevant when the agent needs a supported way to complete a purchase rather than only describe one. We disclose that relationship. Select its role against your actual 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.