Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ To learn more, check out the [ADK Documentation](https://google.github.io/adk-do
├── python
│   ├── agents
│   │   ├── academic-research
│   │   ├── antom-payment
│   │   ├── brand-search-optimization
│   │   ├── camel
│   │   ├── customer-service
Expand Down Expand Up @@ -61,4 +62,4 @@ This project is licensed under the Apache 2.0 License - see the [LICENSE](https:

This is not an officially supported Google product. This project is not eligible for the [Google Open Source Software Vulnerability Rewards Program](https://bughunters.google.com/open-source-security).

This project is intended for demonstration purposes only. It is not intended for use in a production environment.
This project is intended for demonstration purposes only. It is not intended for use in a production environment.
1 change: 1 addition & 0 deletions python/agents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Check out the agent samples below, organized by category:
| [Travel Concierge](travel-concierge) | Travel Concierge, Digital Tasks Assistant | Function tool (Python), Custom tool, Agent tool, Input and output schema, Updatable context, Dynamic instructions | Conversational | Advanced | Multi Agent | Travel |
| [Auto Insurance Agent](auto-insurance-agent) | Auto Insurance Agent to manage members, claims, rewards and roadside assistance. | [Apigee](https://cloud.google.com/apigee/docs/api-platform/get-started/what-apigee), [Apigee API hub](https://cloud.google.com/apigee/docs/apihub/what-is-api-hub), Agent Tool | Conversational | Easy | Multi Agent | Financial Services
| [Image Scoring](image-scoring) | Image scoring agent to generate images based on policies and score the generated images to measure policy compliance. | Function tool (Python), Agent tool, Imagen, Loop Agent | Conversational | Easy | Multi Agent | Horizontal
| [Antom Payment](antom-payment) | Integrates Ant International's Antom payment APIs to enable payment and refund operations via standardized MCP tools. | MCP, Payment, Refund, External API | Conversational | Intermediate | Single Agent | Financial Services / Payments



Expand Down
11 changes: 11 additions & 0 deletions python/agents/antom-payment/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Modify this file and rename it to ".env" or Copy as .env file and fill your values below
GATEWAY_URL=
CLIENT_ID=
MERCHANT_PRIVATE_KEY=
ALIPAY_PUBLIC_KEY=
PAYMENT_REDIRECT_URL=
PAYMENT_NOTIFY_URL=


GOOGLE_GENAI_USE_VERTEXAI=
GOOGLE_API_KEY=
97 changes: 97 additions & 0 deletions python/agents/antom-payment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Antom Payment Agent

That integrates Ant International's Antom payment APIs, enabling AI assistants to handle payment and refund operations seamlessly.

## Overview

The Antom Payment Agent wraps Ant International's Antom payment APIs into standardized MCP tools, allowing AI assistants to securely process payment-related operations during conversations. With this server, you can create payment sessions, query transaction status, handle refunds, and more directly through AI interactions.

## Features

### 💳 Payment Operations
- **Create Payment Session** (`create_payment_session`): Generate payment sessions for client-side SDK integration
- **Query Payment Details** (`query_payment_detail`): Retrieve transaction status and information for submitted payment requests
- **Cancel Payment** (`cancel_payment`): Cancel payments when results are not returned within expected timeframes

### 💰 Refund Operations
- **Create Refund** (`create_refund`): Initiate full or partial refunds against successful payments
- **Query Refund Details** (`query_refund_detail`): Check refund status for previously submitted refund requests


## Setup and Installation


1. **Prerequisites**

Before using the Antom Payment Agent, ensure you have:

- **Python 3.11 or higher**
- **uv** (recommended package manager) or **pip**
- **Valid Antom Merchant Account** with:
- Merchant Client ID (CLIENT_ID)
- Merchant RSA Private Key (MERCHANT_PRIVATE_KEY)
- Alipay RSA Public Key (ALIPAY_PUBLIC_KEY)
- Payment Redirect Return URL (PAYMENT_REDIRECT_URL)
- Payment Notification Callback URL (PAYMENT_NOTIFY_URL)


2. **Installation**


```bash
# Clone this repository.
git clone https://github.com/google/adk-samples.git
cd adk-samples/python/agents/antom-payment
# Install the package and dependencies.
pip install poetry
poetry install

or
uv venv
uv sync

```

3. **Configuration**

You may set the following environment variables in your shell, or in a `python/agents/antom-payment/antom-payemnt-agent/.env` file instead.
* Set up Google Cloud credentials.

GOOGLE_GENAI_USE_VERTEXAI
GOOGLE_API_KEY


* your Antom config.


GATEWAY_URL
CLIENT_ID
MERCHANT_PRIVATE_KEY
ALIPAY_PUBLIC_KEY
PAYMENT_REDIRECT_URL
PAYMENT_NOTIFY_URL

## Running the Agent


**Using `adk`**


ADK provides convenient ways to bring up agents locally and interact with them.
You may talk to the agent using:

```bash
poetry run adk web
or
uv run adk web
```


**Try the following prompts:**


After running the agent, try the following example prompt

```
[user]: Create a payment link for an order called "Cream Puff" for $100 and think of a sentence describing Cream Puff.
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import agent
44 changes: 44 additions & 0 deletions python/agents/antom-payment/antom-payemnt-agent/agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
from google.adk.agents import Agent
from google.adk.tools import MCPToolset
from google.adk.tools.mcp_tool import StdioConnectionParams
from mcp import StdioServerParameters

root_agent = Agent(
name="antom_payment_agent",
model="gemini-2.0-flash",
description=(
"Agent creates payment links for merchants, queries payment result details。"
),
instruction=(
"You are an Antom payment agent who can help users create payment links and query payment result details."
"Regarding RequestId, you generate it randomly"
"And you can describe the description of the user creating the order in one sentence"
"when refund get the order details and paymentId based on the paymentRequest ID used when creating "
"the payment method by the payment agent. "
"If the merchant specifies a refund amount, a full refund will be made in the order currency by default."
),
tools=[
MCPToolset(
connection_params=StdioConnectionParams(
server_params=StdioServerParameters(
command='uvx',
args=[
"ant-intl-antom-mcp"
],
# Pass the API key as an environment variable to the npx process
# This is how the MCP server for Google Maps expects the key.
env={
"GATEWAY_URL": os.getenv("GATEWAY_URL"),
"CLIENT_ID": os.getenv("CLIENT_ID"),
"MERCHANT_PRIVATE_KEY": os.getenv("MERCHANT_PRIVATE_KEY"),
"ALIPAY_PUBLIC_KEY": os.getenv("ALIPAY_PUBLIC_KEY"),
"PAYMENT_REDIRECT_URL": os.getenv("PAYMENT_REDIRECT_URL"),
"PAYMENT_NOTIFY_URL": os.getenv("PAYMENT_NOTIFY_URL"),
}
),
),
)
],
)

16 changes: 16 additions & 0 deletions python/agents/antom-payment/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[project]
name = "antom-payment"
version = "0.1.0"
description = "That integrates Ant International's Antom payment APIs, enabling AI assistants to handle payment and refund operations seamlessly."
authors = [
{ name = "Steven", email = "[email protected]" },
{ name = "Zunjiao Wang", email = "[email protected]" }
]
license = "Apache License 2.0"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"google-adk>=1.11.0",
"mcp>=1.13.0",
]