Skip to main content

A Model Context Protocol (MCP) compatible server that integrates Ant International's AlipayPlus payment APIs, enabling AI assistants to handle payment and refund operations seamlessly.

Project description

AlipayPlus MCP Server

A Model Context Protocol (MCP) compatible server that integrates Ant International's AlipayPlus payment APIs, enabling AI assistants to handle payment and refund operations seamlessly.

Overview

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

Features

💳 Payment Operations

  • Create Payment (create_payment): Generate payment requests for processing transactions
  • Query Payment (query_payment): 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

🛃 Customs Operations

  • Customs Declare (customs_declare): Declare a payment to customs or update an existing declaration
  • Query Customs Declaration (query_customs_declare): Inquire about the status of declared payments

Prerequisites

Before using the AlipayPlus MCP Server, ensure you have:

  • Python 3.11 or higher
  • uv (recommended package manager) or pip
  • Valid AlipayPlus Merchant Account with:
    • Merchant Client ID (CLIENT_ID)
    • Merchant RSA Private Key (MERCHANT_PRIVATE_KEY)
    • Alipay RSA Public Key (ALIPAY_PUBLIC_KEY)
    • Payment Notification Callback URL (PAYMENT_NOTIFY_URL)

Quick Start

1. Installation

Direct Usage with uvx (Recommended)

uvx ant-intl-alipayplus-mcp

Install with pip

pip install ant-intl-alipayplus-mcp

Install with uv

uv install ant-intl-alipayplus-mcp

Install from Source

git clone https://github.com/alipay/global-alipayplus-mcp.git
cd global-alipayplus-mcp
uv install

Requirements

  • Python 3.11 or higher
  • Dependencies:
    • cryptography==44.0.3
    • mcp[cli]>=1.9.1
    • pycryptodome==3.22.0
    • rsa>=4.9.1

2. MCP Client Configuration

Add the following configuration to your MCP client:

{
  "mcpServers": {
    "alipayplus-mcp": {
      "command": "uvx",
      "args": ["ant-intl-alipayplus-mcp"],
      "env": {
        "GATEWAY_URL": "https://open-sea-global.alipay.com",
        "CLIENT_ID": "your_client_id_here",
        "MERCHANT_PRIVATE_KEY": "your_merchant_private_key_here",
        "ALIPAY_PUBLIC_KEY": "your_alipay_public_key_here",
        "PAYMENT_NOTIFY_URL": "https://your-domain.com/payment/notify",
        "SETTLEMENT_CURRENCY": "USD",
        "MERCHANT_NAME": "Your Merchant Name",
        "MERCHANT_ID": "Your Merchant ID",
        "MERCHANT_MCC": "5411",
        "MERCHANT_REGION": "US"
      }
    }
  }
}

3. Environment Variables

Variable Required Description
GATEWAY_URL AlipayPlus API gateway URL (defaults to https://open-sea-global.alipay.com)
CLIENT_ID Merchant client ID for identity verification
MERCHANT_PRIVATE_KEY Merchant RSA private key for request signing
ALIPAY_PUBLIC_KEY Alipay RSA public key for response verification
PAYMENT_REDIRECT_URL URL to redirect after payment (defaults to empty string)
PAYMENT_NOTIFY_URL Payment result notification callback URL (defaults to http://localhost:8080/notify)
SETTLEMENT_CURRENCY Currency for settlement (defaults to empty string)
MERCHANT_NAME Merchant name (defaults to "Alipayplus MCP")
MERCHANT_ID Merchant ID (defaults to "M0000000001")
MERCHANT_MCC Merchant Category Code (defaults to "5411")
MERCHANT_REGION Merchant region code (defaults to "CN")

Integration Example

Here's how you can integrate the AlipayPlus MCP Server with your AI agent (using QwenAgent as an example):

import os
from qwen_agent.agents import Assistant

# Configure the MCP server as a tool
tools = [{
    "mcpServers": {
        "alipayplus-mcp": {
            "command": "uvx",
            "args": ["ant-intl-alipayplus-mcp"],
            "env": {
                "CLIENT_ID": os.getenv('CLIENT_ID'),
                "MERCHANT_PRIVATE_KEY": os.getenv('MERCHANT_PRIVATE_KEY'),
                "ALIPAY_PUBLIC_KEY": os.getenv('ALIPAY_PUBLIC_KEY'),
                "GATEWAY_URL": "https://open-sea-global.alipay.com",
                "PAYMENT_NOTIFY_URL": "https://your-domain.com/notify"
            }
        }
    }
}]

# Create your AI assistant with payment capabilities
bot = Assistant(
    llm={'model': 'qwen-max', 'api_key': 'your-api-key'},
    function_list=tools,
)

Changelog

See CHANGELOG.md for a detailed history of changes.

License

This project is licensed under the MIT License.

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ant_intl_alipayplus_mcp-1.0.0.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ant_intl_alipayplus_mcp-1.0.0-py3-none-any.whl (47.8 kB view details)

Uploaded Python 3

File details

Details for the file ant_intl_alipayplus_mcp-1.0.0.tar.gz.

File metadata

  • Download URL: ant_intl_alipayplus_mcp-1.0.0.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for ant_intl_alipayplus_mcp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b43e93ee7fe6e39fd2ae6f483cd552286e6926372b0860114879e367a79152ac
MD5 f6a46a8efe585aa1e08e7c0c40732ad2
BLAKE2b-256 82f77b9ef3e969e2e483535be4e7733422226feeca6ef2de837441aad09dbe45

See more details on using hashes here.

File details

Details for the file ant_intl_alipayplus_mcp-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ant_intl_alipayplus_mcp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbadcc67895bbe5ca54d15bc57e53f0b72daebb7113c506ac35f3c40d1ca3cbd
MD5 21b2d2fb134e68fa0f907dbbad6ee344
BLAKE2b-256 92b8a7f9a2e941a68e3235b23f309532f15eb06ca1bf12d22076ef02e2ae2770

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page