Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
│   │   ├── blog-writer
│   │   ├── brand-search-optimization
│   │   ├── camel
Expand Down Expand Up @@ -67,4 +68,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 @@ -51,6 +51,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
| [Incident Management](incident-management) | This agent sample showcases the utilization of dynamic identity propagation with ServiceNow and [Application Integration Connectors](https://cloud.google.com/application-integration/docs/using-integration-connectors) | [Application Integration](https://cloud.google.com/application-integration/docs/overview), [Integration Connectors](https://cloud.google.com/integration-connectors/docs/overview), Agent Tool | Conversational | Easy | Single Agent | Customer Support
| [Order Processing](order-processing) | This agent sample showcases how [Application Integration Connectors](https://cloud.google.com/application-integration/docs/using-integration-connectors) can be leveraged to automate orders and include human in the loop for workflows | [Application Integration](https://cloud.google.com/application-integration/docs/overview), [Integration Connectors](https://cloud.google.com/integration-connectors/docs/overview), Agent Tool | Conversational | Easy | Single Agent | Order Management
| [Google Trends Agent](google-trends-agent) | Surfaces top trending search terms from Google Trends using BigQuery dataset. Shows trending topics by region and time period. | BigQuery, Trend analysis, Sequential agent | Conversational | Medium | Sequential Agent | Marketing & Analytics |
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=
112 changes: 112 additions & 0 deletions python/agents/antom-payment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Antom Payment Agent

This project implements an AI-powered payment service agent that integrates Ant International's Antom payment MCP. The agent is designed to ensure secure and smooth handling of payemnts and refunds through AI interactions.

## Overview

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

The Antom Payment Agent aims to provide customers with a convenient and seamless dialogue-based payment process. it enhances the overall shopping and payment experience by flexibly organizing the payment flow according to consumer's intent using Ant International's Antom payment MCP, like initiating order checkout and cancel payment.

## 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.

[agent]
Sure! Here's a payment link for an order called "Cream Puff" for $100:

🔗 Payment Link:
https://open-sea-global.alipayplus.com/api/open/v1/ac/cashier/self/codevalue/checkout.htm?codeValue=https%3A%2F%2Fglobal.alipay.com%2F281002040096G2MGzTTyy0bKXR6HrRDv4Icb

And here's a sentence describing the Cream Puff:

"Indulge in our heavenly Cream Puff — a delicate, golden shell filled with silky vanilla custard and a hint of caramel, perfect for any sweet craving."

Let me know if you want help generating a real payment link using a specific service!
```
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 Antom payment 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",
]