Ap2 dev patterns

From OrcaQubits/agentic-commerce-skills-plugins · View interactive version

Ap2 dev patterns is an AI agent skill from the GitHub repository OrcaQubits/agentic-commerce-skills-plugins. Apply AP2 cross-cutting development patterns — multi-agent payment architecture, UCP integration, x402 crypto payments, testing with mock providers, and production deployment. Use when architecting agentic payment systems or solving cross-cutting payment concerns.

How to use this skill

Skill file

AP2 Development Patterns

Before writing code

Fetch live docs:

  1. Fetch https://ap2-protocol.org/ap2/specification/ for the latest protocol details
  2. Fetch https://ap2-protocol.org/overview/ for UCP integration patterns
  3. Fetch https://ap2-protocol.org/overview/ for x402 crypto integration
  4. Web-search site:github.com google-agentic-commerce AP2 samples for reference architectures

Conceptual Architecture

Multi-Agent Payment Architecture

The standard AP2 architecture involves four agents communicating via A2A:

┌──────────────────────────────────────────────────┐
│                    User                           │
│          (trusted device surface)                 │
└──────────┬───────────────────────────────────────┘
           │ intent + signatures
┌──────────▼───────────────────────────────────────┐
│            Shopping Agent (SA)                     │
│    Orchestrator — coordinates the full flow        │
└──┬──────────────┬────────────────────────────────┘
   │              │
   │ A2A          │ A2A
   │              │
┌──▼──────┐  ┌───▼──────────┐
│ Merchant │  │ Credentials  │
│ Agent    │  │ Provider     │
│          │  │              │
│ catalog  │  │ payment      │
│ cart     │  │ methods      │
│ signing  │  │ tokenization │
└────┬─────┘  └──────────────┘
     │
     │ (Merchant → MPP)
     │
┌────▼─────────────┐
│ Merchant Payment  │
│ Processor (MPP)   │
│                   │
│ authorization     │
│ settlement        │
│ Payment Mandate   │
│ challenges        │
└────────┬──────────┘
         │
    ┌────▼──────────┐
    │ Network/Issuer │
    │ (Visa, MC,     │
    │  banks)        │
    └────────────────┘

Important: The SA communicates with the Merchant and the CP via A2A. The Merchant communicates with the MPP. The SA does not directly communicate with the MPP.

UCP Integration Pattern

UCP (Universal Commerce Protocol) operationalizes AP2:

Use UCP when you need the full commerce checkout flow (catalog, cart, checkout, orders) with AP2's payment security.

x402 Payment Integration

AP2 supports emerging digital payment methods via x402:

Testing with Mock Providers

Development testing without real money:

Framework Flexibility

AP2 agents can be built with any framework:

The protocol doesn't mandate a specific framework — only A2A compliance.

Multi-Merchant Comparison

Shopping Agents can query multiple merchants:

  1. Send Intent Mandate to Merchant A, B, C in parallel
  2. Receive Checkout Mandates from each
  3. Compare offers (price, shipping, availability)
  4. Present best options to user
  5. User selects preferred offer
  6. Proceed with selected merchant

Subscription and Recurring Payments

On the V1.x roadmap:

Production Deployment Considerations

Security Checklist

Best Practices

Fetch the latest specification, roadmap, and sample implementations for current capabilities and patterns before implementing.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.