# Alipay Open Platform MCP

> Alipay Open Platform connects your AI agent directly into Alipay's payment ecosystem. It lets you programmatically create trades, process refunds, execute fund transfers, and download detailed settlement bills. You manage the full B2C payments lifecycle—from initial order to final ledger reconciliation—all through a single MCP connection.

## Overview
- **Category:** industry-titans
- **Price:** Free
- **Tags:** digital-payments, trade-management, refunds, fund-transfers, billing-reconciliation, mobile-commerce

## Description

You can treat your AI agent like a financial operations specialist with direct access to Alipay's massive payment infrastructure. This MCP handles the entire transaction workflow, letting you create new orders and manage their complete lifecycle. Need to correct an amount? You process full or partial refunds, tracking reasons and settlement status automatically. For money movement, you dispatch B2C payouts to individual accounts while verifying that transfers actually completed. When it's time for accounting, you download structured daily transaction summaries to reconcile your billing ledgers without leaving the chat window. This gives your agent a complete view of payments, refunds, funds, and billing data, making reconciliation effortless. You connect everything through Vinkius, giving your AI client instant access to this complex payment backend.

## Tools

### cancel_trade
Cancels an existing trade transaction, effectively rolling it back.

### close_trade
Finalizes a specific Alipay trade that was created but remains unpaid.

### create_trade
Initializes and creates a new payment order or transaction within the system.

### get_oauth_token
Exchanges an authorization code to retrieve necessary access tokens for user data.

### query_bill_download_url
Retrieves the specific URL needed to download structured accounting bill summaries.

### query_trade
Checks and reports on the current status of any given Alipay trade order.

### query_transfer
Retrieves the current status of a fund transfer sent to a user's account.

### query_user_info
Accesses and reports verified customer profile information for authorized users.

### refund_trade
Processes a refund, reversing funds on a specific Alipay transaction ID.

### transfer_fund
Sends physical money or payouts to another designated Alipay user account.

## Prompt Examples

**Prompt:** 
```
Refund the Alipay order 2024040112345 for 15.50 CNY with reason: defective item.
```

**Response:** 
```
Refund processed successfully! Trade 2024040112345 has been partially refunded 15.50 CNY. Refund ID: RF20240401X9A3. The settlement will reflect in the buyer's account within 3–5 business days. Would you like me to query the refund status for confirmation?
```

**Prompt:** 
```
Create a new Alipay trade for 299.00 CNY with subject 'Premium Subscription' and notify URL pointing to my webhook.
```

**Response:** 
```
Trade created successfully! Order ID: AP2024041200987. Amount: 299.00 CNY. Subject: Premium Subscription. The payment link has been generated and the notify URL is configured to ping your webhook upon completion. The trade will auto-close in 30 minutes if unpaid. Shall I monitor the payment status?
```

**Prompt:** 
```
Download yesterday's settlement bill and summarize the total revenue and refund amounts.
```

**Response:** 
```
Settlement bill downloaded for 2024-04-11. Summary: 142 successful trades totaling 48,720.50 CNY in gross revenue. 7 refunds processed amounting to 1,230.00 CNY. Net settlement: 47,490.50 CNY. The detailed CSV has been parsed and is ready for export. Would you like me to flag any transactions above 5,000 CNY for review?
```

## Capabilities

### Manage Payment Orders
Create new transactions or close existing unpaid trade orders.

### Handle Money Movements
Send funds to a user's Alipay account and verify the transfer status.

### Process Financial Corrections
Execute partial or full refunds on completed transactions, logging the reason for the reversal.

### Check Transaction Statuses
Query the status of a trade, fund transfer, or user account information.

### Reconcile Billing Data
Download daily settlement reports and structured accounting exports for ledger matching.

## Use Cases

### Handling a Customer Return
A customer reports a defective product. Instead of emailing finance, you ask your agent to refund the money and provide details: 'Refund order AP2024041200987 for 50 CNY due to damaged goods.' The MCP executes `refund_trade`, confirming the amount and ID immediately.

### Daily Financial Closing
It's end-of-day. You instruct your agent: 'Download yesterday’s settlement bill, and summarize gross revenue versus total refunds.' The MCP uses `query_bill_download_url` to pull the data and instantly calculates the net figure for review.

### Processing a Subscription Payment
A user signs up for premium access. You command your agent to 'Create a new Alipay trade for 99 CNY.' The MCP uses `create_trade`, generating an order ID and payment link that the client can immediately use.

### Investigating a Failed Transfer
A payout was supposed to go out, but the recipient hasn't confirmed it. You ask: 'Check the status of fund transfer AP20240413X987.' The MCP uses `query_transfer` to get real-time confirmation on whether the money successfully left your account.

## Benefits

- Execute refunds instantly. You can process partial or full reversals using `refund_trade`, automatically tracking the reason for every change.
- Automate bookkeeping. Use `query_bill_download_url` to pull daily settlement reports, giving you structured data ready for automated ledger reconciliation.
- Control transactions end-to-end. You manage the entire payment lifecycle by first using `create_trade`, then querying its status with `query_trade`, and finally closing it with `close_trade` when paid.
- Verify payouts accurately. If you send money, use `transfer_fund` to dispatch funds, followed immediately by `query_transfer` to confirm the payment actually arrived in the recipient's account.
- Secure user access. You retrieve necessary customer details using `get_oauth_token` and then query specific profiles with `query_user_info`, keeping data exchange secure.

## How It Works

The bottom line is that you never have to worry about API signature generation or manual data formatting again.

1. Register as a developer on the Alipay Open Platform to get your initial access credentials.
2. Create an application within the platform to obtain a unique App ID, and generate/upload the required RSA2 key pair.
3. Your AI agent signs all requests automatically. It sends commands through this MCP, which handles cryptographic signing, dispatching, and parsing every Alipay interaction.

## Frequently Asked Questions

**How do I use create_trade with Alipay Open Platform MCP?**
You tell your agent what you need: 'Create a trade for $X amount.' The tool handles generating the unique order ID and setting up the payment link, letting you track it immediately using `query_trade`.

**What is the difference between query_trade and close_trade in Alipay Open Platform MCP?**
`query_trade` only checks the status of a trade. You must use `close_trade` to finalize an order that was successfully paid through the system.

**Can I query user info using get_oauth_token and Alipay Open Platform MCP?**
Yes, first you run `get_oauth_token` to secure the access credentials. Then, your agent can use that token to call `query_user_info` to pull verified customer details.

**How do I get daily settlement reports with Alipay Open Platform MCP?**
You ask for the bill download URL using `query_bill_download_url`. The system provides a temporary link, which your agent can then use to pull and analyze the raw accounting data.

**How do I use refund_trade to process an Alipay refund?**
You must provide the original trade ID and the specific amount for the refund. The MCP handles partial or full refunds automatically, allowing you to track the settlement status right away.

**What's the sequence for transfer_fund and query_transfer in Alipay Open Platform MCP?**
First, use `transfer_fund` to send the money. Then, use `query_transfer` shortly after to check the status. This verifies if the payout completed successfully or if an exception occurred.

**If a payment needs to be reversed, how does cancel_trade work in Alipay Open Platform MCP?**
The `cancel_trade` tool rolls back a transaction that was never settled. This is different from closing it; cancellation stops the process entirely before finalization.

**What information can I get using query_user_info in Alipay Open Platform MCP?**
This function provides verified customer profiles for authorized users. It lets your agent securely access identity details without needing to expose raw credentials.

**Do I need to generate RSA signatures manually for each API call?**
No! Simply provide your App Private Key in PKCS1 or PKCS8 format. The engine handles all RSA-SHA256 signing, timestamping, and parameter encoding under the hood automatically on every request — you never touch signature logic directly.

**Can I process partial refunds specifying only a fraction of the original order amount?**
Yes! The `refund_trade` tool supports both full and partial refunds. Specify the original trade number, the refund amount, and a reason string. The engine will dispatch the correctly signed request and return the settlement confirmation with a unique refund ID for tracking.

**Is there any risk of accidental payments or unauthorized fund transfers through this integration?**
Every transactional action requires explicit parameters — trade amounts, recipient accounts, and refund values must all be specified deliberately. The RSA2 signature layer ensures that no request can be forged or replayed. Additionally, all operations are scoped to your registered App ID and sandbox/production environment.