### Run the Sample Script Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/android/scenarios/digital-payment-credentials/README.md Execute the convenience script from the repository root to build, install, and launch the Android app, and start the local merchant and credentials provider servers. ```sh ./code/samples/android/scenarios/digital-payment-credentials/run.sh ``` -------------------------------- ### Install Dependencies with uv Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/android/README.md Use this command to set up your virtual environment and install necessary packages. This is automatically handled by the run.sh script in each scenario. ```bash uv sync ``` -------------------------------- ### Run Scenario End-to-End Source: https://context7.com/google-agentic-commerce/ap2/llms.txt The repository includes run.sh scripts for each scenario that install dependencies and start all agents. ```shell #!/bin/bash # Install dependencies and start all agents for the scenario # Example: ./run.sh ``` -------------------------------- ### Install AP2 Python SDK Source: https://context7.com/google-agentic-commerce/ap2/llms.txt Install the AP2 Python SDK using uv or pip. Requires Python version 3.11 or higher. ```sh # Install via uv (recommended) uv pip install git+https://github.com/google-agentic-commerce/AP2.git@main # Or with pip pip install git+https://github.com/google-agentic-commerce/AP2.git@main ``` -------------------------------- ### Start Shopping Agent Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/scenarios/a2a/human-present/x402/README.md Initiates the Shopping Agent. This command assumes the PAYMENT_METHOD environment variable is already set. ```sh export PAYMENT_METHOD=x402 uv run --package ap2 adk web code/samples/python/src/roles ``` -------------------------------- ### Start Merchant Agent Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/scenarios/a2a/human-present/cards/README.md Run the Merchant Agent in its own terminal. This agent handles product queries. ```bash uv run --package ap2-samples python -m roles.merchant_agent ``` -------------------------------- ### Start Merchant Agent with x402 Payment Method Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/scenarios/a2a/human-present/x402/README.md Initiates the Merchant Agent. Requires the PAYMENT_METHOD environment variable to be set to 'x402'. ```sh export PAYMENT_METHOD=x402 uv run --package ap2-samples python -m roles.merchant_agent ``` -------------------------------- ### Install CM Wallet App Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/android/scenarios/digital-payment-credentials/README.md Install the CM Wallet application APK using ADB and then start the app. This is a prerequisite for using the Digital Payment Credentials. ```sh adb install app-debug.apk adb shell am start -n "com.credman.cmwallet/.MainActivity" ``` -------------------------------- ### Run All Services Script Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/scenarios/a2a/human-not-present/cards/README.md Execute this bash script to start all necessary services for the sample, including the Shopping Agent, Merchant Trigger, Credentials Provider, Payment Processor, and Web Client. ```bash bash code/samples/python/scenarios/a2a/human-not-present/cards/run.sh ``` -------------------------------- ### Start Credentials Provider Agent with x402 Payment Method Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/scenarios/a2a/human-present/x402/README.md Initiates the Credentials Provider Agent. Requires the PAYMENT_METHOD environment variable to be set to 'x402'. ```sh export PAYMENT_METHOD=x402 uv run --package ap2-samples python -m roles.credentials_provider_agent ``` -------------------------------- ### Install AP2 Types Package Source: https://github.com/google-agentic-commerce/ap2/blob/main/README.md Install the AP2 types package directly from the GitHub repository using pip. This is a temporary solution until a PyPI package is published. ```sh uv pip install git+https://github.com/google-agentic-commerce/AP2.git@main ``` -------------------------------- ### Start Credentials Provider Agent Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/scenarios/a2a/human-present/cards/README.md Run the Credentials Provider Agent in its own terminal. This agent manages user payment credentials and facilitates payment. ```bash uv run --package ap2-samples python -m roles.credentials_provider_agent ``` -------------------------------- ### Run All Services Script Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/scenarios/a2a/human-not-present/x402/README.md Execute this bash script to start all necessary services for the sample, including the Merchant Trigger, x402 PSP Trigger, Shopping Agent, and Web Client. An optional flag can enable blockchain broadcast simulation. ```bash bash code/samples/python/scenarios/a2a/human-not-present/x402/run.sh ``` ```bash bash code/samples/python/scenarios/a2a/human-not-present/x402/run.sh \ --enable_broadcast_on_chain ``` -------------------------------- ### Start Merchant Payment Processor Agent with x402 Payment Method Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/scenarios/a2a/human-present/x402/README.md Initiates the Merchant Payment Processor Agent. Requires the PAYMENT_METHOD environment variable to be set to 'x402'. ```sh export PAYMENT_METHOD=x402 uv run --package ap2-samples python -m roles.merchant_payment_processor_agent ``` -------------------------------- ### Start Shopping Agent Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/scenarios/a2a/human-present/cards/README.md Run the Shopping Agent in its own terminal. This agent orchestrates user requests and delegates tasks. Access the UI at http://0.0.0.0:8000. ```bash uv run --package ap2-samples adk web code/samples/python/src/roles ``` -------------------------------- ### Payment Agent Recurrence and Budget Constraints Source: https://context7.com/google-agentic-commerce/ap2/llms.txt Examples of payment.agent_recurrence and payment.budget constraints, setting monthly frequency and a total budget cap. ```json { "type": "payment.agent_recurrence", "frequency": "MONTHLY", "max_occurrences": 12 } ``` ```json { "type": "payment.budget", "max": 200.00, "currency": "USD" } ``` -------------------------------- ### Search Products with Merchant Agent Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/go/scenarios/a2a/human-present/cards/README.md Invoke the 'search_catalog' skill on the merchant agent to find products. This example searches for 'coffee maker'. Ensure the agent is running on localhost:8001. ```sh curl -X POST http://localhost:8001/a2a/merchant_agent \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "agent.invoke", "params": { "skill": "search_catalog", "input": { "shopping_intent": "{\"product_type\": \"coffee maker\"}" } }, "id": 2 }' ``` -------------------------------- ### SD-JWT Structure Example Source: https://github.com/google-agentic-commerce/ap2/blob/main/docs/ap2/agent_authorization.md Illustrates the structure of a combined SD-JWT, including issuer details and truncated disclosure components. This format is used for agent delegation. ```json { "sd-jwt": [ "eyJhbGci......jA~WyJiWk5w......Q~WyJCdThH......Q~WyJNUThs......Q~eyJ0eXAi......jZ" ] } ``` -------------------------------- ### Start Merchant Payment Processor Agent Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/scenarios/a2a/human-present/cards/README.md Run the Merchant Payment Processor Agent in its own terminal. This agent processes payments on behalf of the merchant and handles OTP challenges. ```bash uv run --package ap2-samples python -m roles.merchant_payment_processor_agent ``` -------------------------------- ### Run All Sample Steps Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/scenarios/a2a/human-present/cards/README.md Execute all the steps of the sample in a single terminal. ```bash bash code/samples/python/scenarios/a2a/human-present/cards/run.sh ``` -------------------------------- ### Manual Build and Run Go Agents Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/go/scenarios/a2a/human-present/cards/README.md Manually build and run the Go agents by navigating to the code/samples/go directory, downloading dependencies, building the agents, and then running them individually in separate terminals. ```sh cd code/samples/go # Install dependencies go mod download # Build all agents make build # Run individual agents (in separate terminals) ./bin/merchant_agent ./bin/credentials_provider_agent ./bin/merchant_payment_processor_agent ``` -------------------------------- ### Encoded Closed Payment Mandate SD-JWT Source: https://github.com/google-agentic-commerce/ap2/blob/main/docs/ap2/payment_mandate.md This is an example of an encoded SD-JWT for a closed payment mandate. It includes a delegate payload and other claims, with a different structure than the open mandate example. ```text eyJhbGciOiAiRVMyNTYiLCAidHlwIjogImtiK3NkLWp3dCJ9.eyJkZWxlZ2F0ZV9wYXlsb2FkIjogW3siLi4uIjogIkcyRHVVNklqeURrRC05SXRTdGRzVW80OEM1dUpxRHMxRTlIZjVHVDNUZ00ifV0sICJpYXQiOiAxNzc3MzQyMzcwLCAiYXVkIjogImNyZWRlbnRpYWwtcHJvdmlkZXIiLCAibm9uY2UiOiAiYThiN2M2ZDVlNGYzYTJiMWMwZDllOGY3YTZiNWM0ZDMiLCAic2RfaGFzaCI6ICJ1aXhvSGVtbWZyckNTYlBSRW85ai16aUx1TWtxRXhzUGVXcndBLVBLMENrIiwgIl9zZF9hbGciOiAic2hhLTI1NiJ9.TgI6w9zeL993uzAYE9fnAJXjnrpliDY5DpDKTSQoioH3msapVIz0Ex23ncQXwmsSmT3xOqkSpigQD1EYKck-dQ~WyJmVzZNY0JKSW1xT0R1aFFscEk0SWR3IiwgeyJ2Y3QiOiAibWFuZGF0ZS5wYXltZW50LjEiLCAidHJhbnNhY3Rpb25faWQiOiAiTml2V2h1cWZ6Y3ZaTmFwdklFSjItM3RzZFFMa2l1SWN5ZTJnNDZXVmdYOCIsICJwYXllZSI6IHsiaWQiOiAibWVyY2hhbnRfMSIsICJuYW1lIjogIkRlbW8gTWVyY2hhbnQiLCAid2Vic2l0ZSI6ICJodHRwczovL2RlbW8tbWVyY2hhbnQuZXhhbXBsZSJ9LCAicGF5bWVudF9hbW91bnQiOiB7ImFtb3VudCI6IDE5OTAwLCAiY3VycmVuY3kiOiAiVVNEIn0sICJwYXltZW50X2luc3RydW1lbnQiOiB7ImlkIjogInN0dWIiLCAidHlwZSI6ICJjYXJkIiwgImRlc2NyaXB0aW9uIjogIkNhcmQgXHUyMDIyXHUyMDIyXHUyMDIyNDI0MiJ9fV0~ ``` -------------------------------- ### Encoded Token Example Source: https://github.com/google-agentic-commerce/ap2/blob/main/docs/ap2/checkout_mandate.md An example of an encoded token used in checkout mandates. This token contains various pieces of information necessary for the checkout process, including delegation payloads, constraints, and cryptographic details. ```APIDOC ## Encoded Token An example of an encoded token used in checkout mandates. This token contains various pieces of information necessary for the checkout process, including delegation payloads, constraints, and cryptographic details. ``` eyJhbGciOiAiRVMyNTYiLCAidHlwIjogImV4YW1wbGUrc2Qtand0IiwgImtpZCI6ICJhZ2VudC1wcm92aWRlci1rZXktMSJ9.eyJkZWxlZ2F0ZV9wYXlsb2FkIjogW3siLi4uIjogIlF0WFRKdFdxZzk5OUNtVVdHakhGVFdNa1JQZ3VEZmVLM3dHU2FJbmQtZHcifV0sICJfc2RfYWxnIjogInNoYS0yNTYifQ.HvCGk7ye_c0LN2-NFG13wfyu3LA--rckTPGm36ugO2aRvsded7ngw1py8W3JF7wBpoQnsKr17tNTF3zLeYcoWA~WyI0bjNMXy0zX0ZtMkdneUZBRjhDdF9nIiwgeyJpZCI6ICJzdXBlcnNob2VfbGltaXRlZF9lZGl0aW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zd2Q1UDlZWG1HTE9yTFRXeGdYdkd5UVF0dERETTVELUc0czE5dnhfVTY1ZHJ1UmciXQ~``` ``` -------------------------------- ### Go Project Structure Overview Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/go/scenarios/a2a/human-present/cards/README.md This text-based diagram outlines the directory structure for the Go agent samples, detailing the organization of command-line entry points, shared infrastructure, agent implementations, and scenario-specific files. ```text code/samples/go/ ├── cmd/ # Agent entry points │ ├── merchant_agent/main.go │ ├── credentials_provider_agent/main.go │ └── merchant_payment_processor_agent/main.go ├── pkg/ │ ├── ap2/types/ # AP2 protocol types │ │ ├── mandate.go # Mandate structures │ │ ├── payment_request.go │ │ └── contact_address.go │ ├── common/ # Shared infrastructure │ │ ├── base_executor.go # Base agent execution │ │ ├── message_builder.go # A2A message construction │ │ ├── server.go # HTTP/JSON-RPC server │ │ └── function_resolver.go # Tool/skill handling │ └── roles/ # Agent implementations │ ├── merchant_agent/ │ │ ├── agent.json # Capabilities & skills │ │ ├── executor.go # Business logic │ │ ├── tools.go # Agent tools │ │ └── storage.go # Product catalog │ ├── credentials_provider_agent/ │ │ ├── agent.json │ │ └── executor.go │ └── merchant_payment_processor_agent/ │ ├── agent.json │ └── executor.go └── scenarios/a2a/human-present/cards/ ├── README.md # This file └── run.sh # Start all agents ``` -------------------------------- ### Payment Execution Date Constraint Source: https://context7.com/google-agentic-commerce/ap2/llms.txt Example of a payment.execution_date constraint, specifying the valid date range for payment execution. ```json { "type": "payment.execution_date", "not_before": "2026-04-01T00:00:00Z", "not_after": "2026-04-30T23:59:59Z" } ``` -------------------------------- ### Checkout Line Items Constraint Source: https://context7.com/google-agentic-commerce/ap2/llms.txt Example of a checkout.line_items constraint, defining acceptable items and quantities for an agent to purchase. ```json { "type": "checkout.line_items", "items": [ { "id": "shoe-requirement", "acceptable_items": [ { "id": "SKU-RED", "title": "Red Sneaker" }, { "id": "SKU-BLUE", "title": "Blue Sneaker" } ], "quantity": 1 }, { "id": "sock-requirement", "acceptable_items": [{ "id": "SKU-SOCK", "title": "Best Socks" }], "quantity": 1 } ] } ``` -------------------------------- ### Checkout Allowed Merchants Constraint Source: https://context7.com/google-agentic-commerce/ap2/llms.txt Example of a checkout.allowed_merchants constraint, specifying allowed merchants for an open checkout mandate. ```json { "type": "checkout.allowed_merchants", "allowed": [ { "name": "Cat Store", "website": "https://catstore.example" }, { "name": "Pet Palace", "website": "https://petpalace.example" } ] } ``` -------------------------------- ### Generate Pydantic Models Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/sdk/schemas/README.md Use this command to generate Pydantic models from the schema definitions. Ensure you have `uv` and `datamodel-code-generator` installed. ```bash $ uv run --with datamodel-code-generator python3 code/sdk/schemas/generate.py ``` -------------------------------- ### Run Go Agent Tests Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/go/scenarios/a2a/human-present/cards/README.md Execute the test suite for the Go agents by navigating to the 'code/samples/go' directory and running the 'make test' command. ```sh cd code/samples/go make test ``` -------------------------------- ### Payment Amount Range Constraint Source: https://context7.com/google-agentic-commerce/ap2/llms.txt Example of a payment.amount_range constraint, defining the minimum and maximum amount for an open payment mandate. ```json { "type": "payment.amount_range", "min": 0, "max": 20000, "currency": "USD" } ``` -------------------------------- ### Adding a New Backend Agent in Go Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/go/scenarios/a2a/human-present/cards/README.md This list outlines the steps required to add a new backend agent to the Go project. It includes creating entry points, implementing executors, defining agent capabilities, and updating build and run scripts. ```text 1. Create entry point in `cmd/your_agent/main.go` 2. Implement executor in `pkg/roles/your_agent/executor.go` 3. Define `agent.json` with capabilities and skills 4. Add build target to `Makefile` 5. Update `run.sh` to start the new agent ``` -------------------------------- ### Set JAVA_HOME Environment Variable Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/android/scenarios/digital-payment-credentials/README.md Set the JAVA_HOME environment variable to point to your JDK installation. This is necessary for Gradle to function correctly. ```sh export JAVA_HOME= ``` -------------------------------- ### Configure Google API Key Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/README.md Create a .env file at the repository root to store your Google API key. This is required for most scenarios. ```shell GOOGLE_API_KEY= ``` -------------------------------- ### Get Merchant Agent Info Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/go/scenarios/a2a/human-present/cards/README.md Retrieve information about the merchant agent by sending a POST request to the /a2a/merchant_agent endpoint with the agent.info method. ```APIDOC ## Get Merchant Agent Info ### Description Retrieves information about the merchant agent. ### Method POST ### Endpoint http://localhost:8001/a2a/merchant_agent ### Request Body ```json { "jsonrpc": "2.0", "method": "agent.info", "params": {}, "id": 1 } ``` ### Response (Success response details not provided in source) ``` -------------------------------- ### Get Merchant Agent Info Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/go/scenarios/a2a/human-present/cards/README.md Use this cURL command to retrieve information about the merchant agent. Ensure the agent is running on localhost:8001. ```sh curl -X POST http://localhost:8001/a2a/merchant_agent \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "agent.info", "params": {}, "id": 1 }' ``` -------------------------------- ### Run All Steps in One Terminal Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/scenarios/a2a/human-present/x402/README.md Execute all scenario steps sequentially in a single terminal. Ensure the payment method is set to x402. ```sh code/samples/python/scenarios/a2a/human-present/cards/run.sh --payment-method x402 ``` -------------------------------- ### Run Human-Present Shopping Agent with Specific Payment Method Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/README.md Run the human-present shopping agent scenario, specifying a particular payment method (e.g., x402) using a command-line argument. ```shell ./code/samples/python/scenarios/a2a/human-present/cards/run.sh --payment-method x402 ``` -------------------------------- ### Agent Recurrence Payment Mandate Example Source: https://github.com/google-agentic-commerce/ap2/blob/main/docs/ap2/payment_mandate.md Defines conditions for reusing a Payment Mandate multiple times. Specify the frequency and maximum occurrences. ```json { "type": "payment.agent_recurrence", "frequency": "MONTHLY", "max_occurrences": 12 } ``` -------------------------------- ### Run Go Agents with Bash Script Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/go/scenarios/a2a/human-present/cards/README.md Execute the provided bash script to start all three backend Go agents: Merchant Agent, Credentials Provider, and Payment Processor. These agents will run on ports 8001, 8002, and 8003 respectively. ```sh # From repository root bash code/samples/go/scenarios/a2a/human-present/cards/run.sh ``` -------------------------------- ### Configure Additional Scenario Variables Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/python/README.md Some scenarios, like 'shopping_agent_v2', require additional variables. Create a local .env file within the specific role directory for these settings. ```shell GOOGLE_API_KEY= AGENT_MODEL=gemini-3.1-flash-lite-preview ``` -------------------------------- ### Get Payment Methods Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/go/scenarios/a2a/human-present/cards/README.md Retrieve available payment methods using the credentials provider agent by invoking the agent.invoke method with the get_payment_method skill. ```APIDOC ## Get Payment Methods ### Description Retrieves the available payment methods from the credentials provider agent. ### Method POST ### Endpoint http://localhost:8002/a2a/credentials_provider ### Parameters #### Request Body - **jsonrpc** (string) - Required - JSON-RPC protocol version. - **method** (string) - Required - The method to call, should be "agent.invoke". - **params** (object) - Required - Parameters for the agent invocation. - **skill** (string) - Required - The skill to use, should be "get_payment_method". - **id** (integer) - Required - The request ID. ### Request Example ```json { "jsonrpc": "2.0", "method": "agent.invoke", "params": { "skill": "get_payment_method" }, "id": 3 } ``` ### Response (Success response details not provided in source) ``` -------------------------------- ### Open Checkout Mandate Line Items Constraint Source: https://github.com/google-agentic-commerce/ap2/blob/main/docs/ap2/checkout_mandate.md Example of the 'checkout.line_items' constraint for open Checkout Mandates. It defines acceptable items and their quantities for a checkout. ```json { "type": "checkout.line_items", "items": [ { "id": "id-shoe-choices", "acceptable_items": [ {"id": "BAB1234", "title": "Red Style"} {"id": "FAF1234", "title": "Blue Style"} ], "quantity": 1 }, { "id": "id-sock-choices", "acceptable_items": [ {"id": "QRT1234", "title": "The Best Socks"} ], "quantity": 1 }, ] } ``` -------------------------------- ### Run Tests in Go Project Source: https://github.com/google-agentic-commerce/ap2/blob/main/code/samples/go/README.md Execute all tests within the Go project. Ensure you are in the project's root directory. ```sh make test ```