NewebPay 藍新金流
Released已發布MCP Server for NewebPay payment gateway, providing payment integration and transaction management for AI agents.
藍新金流 NewebPay MCP Server,為 AI 代理提供金流整合與交易管理功能。
Features功能特色
- 8 payment tools covering payment creation, transaction queries, refunds, and recurring payment management
- AES-256-CBC encryption built-in — handles NewebPay's encryption/decryption protocol automatically
- Test/Production switch — single env var to toggle between sandbox and live environments
- stdio JSON-RPC 2.0 — standard MCP transport
- 8 個支付工具 — 涵蓋建立交易、交易查詢、退款、定期定額管理
- 內建 AES-256-CBC 加解密 — 自動處理藍新的加密協定
- 測試/正式環境切換 — 單一環境變數即可切換 sandbox 與正式環境
- stdio JSON-RPC 2.0 — 標準 MCP 傳輸協定
Quick Start快速開始
Install from PyPI
pip install mcp-newebpay
Or clone and install locally
git clone https://github.com/asgard-ai-platform/mcp-newebpay.git
cd mcp-newebpay
uv venv && source .venv/bin/activate
uv pip install -e .
Configure
cp .env.example .env
# Edit .env with your NewebPay credentials
Environment variables (configure only what you need):
| Variable | Description |
|---|---|
NEWEBPAY_ENV |
test (default) or production |
| NDNF — Online Transaction | |
NEWEBPAY_NDNF_MERCHANT_ID |
Merchant ID for payment APIs |
NEWEBPAY_NDNF_HASH_KEY |
Hash Key (32 chars) |
NEWEBPAY_NDNF_HASH_IV |
Hash IV (16 chars) |
| NDNP — Recurring Payment | |
NEWEBPAY_NDNP_MERCHANT_ID |
Merchant ID for recurring APIs |
NEWEBPAY_NDNP_HASH_KEY |
Hash Key (32 chars) |
NEWEBPAY_NDNP_HASH_IV |
Hash IV (16 chars) |
NDNF and NDNP may use different merchant accounts. Only configure the set you need — tools for unconfigured APIs will report a clear error if called.
Run
python mcp_server.py
Claude Code Integration
This project includes .mcp.json for auto-discovery. Add to your Claude Code config:
{
"mcpServers": {
"newebpay": {
"command": "python",
"args": ["mcp_server.py"],
"cwd": "/path/to/mcp-newebpay",
"env": {
"NEWEBPAY_ENV": "test",
"NEWEBPAY_NDNF_MERCHANT_ID": "your_ndnf_merchant_id",
"NEWEBPAY_NDNF_HASH_KEY": "your_ndnf_hash_key",
"NEWEBPAY_NDNF_HASH_IV": "your_ndnf_hash_iv",
"NEWEBPAY_NDNP_MERCHANT_ID": "your_ndnp_merchant_id",
"NEWEBPAY_NDNP_HASH_KEY": "your_ndnp_hash_key",
"NEWEBPAY_NDNP_HASH_IV": "your_ndnp_hash_iv"
}
}
}
}
從 PyPI 安裝
pip install mcp-newebpay
或 clone 並本地安裝
git clone https://github.com/asgard-ai-platform/mcp-newebpay.git
cd mcp-newebpay
uv venv && source .venv/bin/activate
uv pip install -e .
設定
cp .env.example .env
# 編輯 .env 填入藍新金流憑證
環境變數(只設定你需要的):
| 變數 | 說明 |
|---|---|
NEWEBPAY_ENV |
test (預設) 或 production |
| NDNF — 線上交易 | |
NEWEBPAY_NDNF_MERCHANT_ID |
線上交易商店代號 |
NEWEBPAY_NDNF_HASH_KEY |
Hash Key (32 字元) |
NEWEBPAY_NDNF_HASH_IV |
Hash IV (16 字元) |
| NDNP — 定期定額 | |
NEWEBPAY_NDNP_MERCHANT_ID |
定期定額商店代號 |
NEWEBPAY_NDNP_HASH_KEY |
Hash Key (32 字元) |
NEWEBPAY_NDNP_HASH_IV |
Hash IV (16 字元) |
NDNF 和 NDNP 可能使用不同商店帳號。只需設定你要用的那組 — 未設定的 API 工具在呼叫時會回傳明確錯誤。
啟動
python mcp_server.py
Claude Code 整合
本專案包含 .mcp.json 自動發現設定。加入你的 Claude Code 設定:
{
"mcpServers": {
"newebpay": {
"command": "python",
"args": ["mcp_server.py"],
"cwd": "/path/to/mcp-newebpay",
"env": {
"NEWEBPAY_ENV": "test",
"NEWEBPAY_NDNF_MERCHANT_ID": "your_ndnf_merchant_id",
"NEWEBPAY_NDNF_HASH_KEY": "your_ndnf_hash_key",
"NEWEBPAY_NDNF_HASH_IV": "your_ndnf_hash_iv",
"NEWEBPAY_NDNP_MERCHANT_ID": "your_ndnp_merchant_id",
"NEWEBPAY_NDNP_HASH_KEY": "your_ndnp_hash_key",
"NEWEBPAY_NDNP_HASH_IV": "your_ndnp_hash_iv"
}
}
}
}
API ReferenceAPI 參考文件
Available Tools可用工具
Payment (NDNF — Online Transaction)
| Tool | API | Description |
|---|---|---|
create_mpg_payment |
NPA-F01 | Create a payment and return encrypted form data for browser redirect |
query_trade |
NPA-B02 | Query single transaction status, payment and refund details |
cancel_authorization |
NPA-B01 | Cancel credit card authorization |
close_refund |
NPA-B031~34 | Request close, refund, cancel close, or cancel refund |
ewallet_refund |
NPA-B06 | Refund e-wallet payments (LINE Pay, Taiwan Pay, etc.) |
Recurring Payment (NDNP — Credit Card Periodic Payment)
| Tool | API | Description |
|---|---|---|
create_period_payment |
NPA-B05 | Create a recurring mandate and return encrypted form data for browser redirect |
alter_period_status |
NPA-B051 | Suspend, terminate, or restart a recurring mandate |
alter_period_content |
NPA-B052 | Modify mandate amount, billing cycle, or expiry |
支付工具 (NDNF — 線上交易)
| 工具 | API | 說明 |
|---|---|---|
create_mpg_payment |
NPA-F01 | 建立交易,回傳加密表單資料供瀏覽器跳轉 |
query_trade |
NPA-B02 | 查詢單筆交易狀態、付款及退款詳情 |
cancel_authorization |
NPA-B01 | 取消信用卡授權 |
close_refund |
NPA-B031~34 | 請款、退款、取消請款、取消退款 |
ewallet_refund |
NPA-B06 | 電子錢包退款 (LINE Pay、台灣 Pay 等) |
定期定額工具 (NDNP — 信用卡定期定額)
| 工具 | API | 說明 |
|---|---|---|
create_period_payment |
NPA-B05 | 建立定期定額委託,回傳加密表單資料供瀏覽器跳轉 |
alter_period_status |
NPA-B051 | 暫停、終止或重新啟用委託 |
alter_period_content |
NPA-B052 | 修改委託金額、扣款週期或到期日 |
License授權
MIT License — see LICENSE for details.
MIT License — 詳見 LICENSE。
Usage ExamplesUsage Examples
Once the MCP server is running and connected to your AI assistant, you can interact with NewebPay using natural language:
Create Payment
You: "Help me create a credit card payment for order A20250403001, amount NT$350, item: Annual membership"
AI: I've generated the payment form for order A20250403001. Here are the details:
- Amount: NT$350
- Payment page URL:
https://ccore.newebpay.com/MPG/mpg_gateway
Please open the following URL in a browser to complete the payment. The customer will be redirected to NewebPay's secure payment page to enter their card details.
{
"url": "https://ccore.newebpay.com/MPG/mpg_gateway",
"form_data": {
"MerchantID": "MS358668323",
"TradeInfo": "04ac744434c76218dd6ba52b78da433f...",
"TradeSha": "EFCFC9E418A8DCBE49370897FA4FCFFA...",
"Version": "2.0"
}
}
Query Transaction
You: "Has order mcp1775195782 been paid? The amount was NT$100"
AI: Yes, order mcp1775195782 has been paid successfully. Here's a summary:
| Item | Detail |
|---|---|
| Status | Paid (TradeStatus: 1) |
| Amount | NT$100 |
| Payment Method | Credit Card (CREDIT) |
| Card | 400022******1111 |
| Auth Code | 114493 |
| Acquiring Bank | KGI (凱基銀行) |
| Close Status | Settled (3) |
| Refund Status | None (0) |
| Trade No | 26040313563142518 |
{
"Status": "SUCCESS",
"Message": "查詢成功",
"Result": {
"MerchantID": "MS358668323",
"Amt": 100,
"TradeNo": "26040313563142518",
"MerchantOrderNo": "mcp1775195782",
"TradeStatus": "1",
"PaymentType": "CREDIT",
"RespondCode": "00",
"Auth": "114493",
"Card6No": "400022",
"Card4No": "1111",
"AuthBank": "KGI",
"CloseStatus": "3",
"BackStatus": "0"
}
}
Close (Settle)
You: "Request a close for order demo1775199586, amount NT$200"
AI: Done! The close (settle) request for order demo1775199586 has been submitted successfully.
- Amount: NT$200
- Trade No: 26040315000942606
- The funds will be settled to your account on the next business cycle.
{
"Status": "SUCCESS",
"Message": "請款資料新增成功_模擬信用卡請款成功",
"Result": {
"MerchantID": "MS358668323",
"Amt": 200,
"MerchantOrderNo": "demo1775199586",
"TradeNo": "26040315000942606"
}
}
Cancel Authorization
You: "Cancel the credit card authorization for order canc1775199618, amount NT$150"
AI: The credit card authorization for order canc1775199618 has been cancelled.
- Amount: NT$150
- Trade No: 26040315002642607
- The hold on the customer's credit card has been released.
{
"Status": "SUCCESS",
"Message": "放棄授權成功",
"Result": {
"MerchantID": "MS358668323",
"Amt": 150,
"MerchantOrderNo": "canc1775199618",
"TradeNo": "26040315002642607"
}
}
Modify Recurring Payment
You: "Change the recurring amount to NT$149 for mandate P260403144725zl3MVV"
AI: The recurring mandate P260403144725zl3MVV has been updated:
- New amount per period: NT$149
- Next billing date: 2026-04-05
- The updated amount will take effect starting from the next billing cycle.
{
"Status": "SUCCESS",
"Message": "定期定額委託單修改成功!",
"Result": {
"MerOrderNo": "per1775198836",
"PeriodNo": "P260403144725zl3MVV",
"AlterAmt": "149",
"NewNextAmt": "149",
"NewNextTime": "2026-04-05"
}
}
Suspend Recurring Payment
You: "Pause the recurring mandate P260403144725zl3MVV"
AI: The recurring mandate P260403144725zl3MVV has been paused. No further charges will be made until you resume it.
To resume, just say: "Resume mandate P260403144725zl3MVV"
{
"Status": "SUCCESS",
"Message": "定期定額委託單暫停成功",
"Result": {
"MerOrderNo": "per1775198836",
"PeriodNo": "P260403144725zl3MVV",
"AlterType": "suspend"
}
}
MCP Server 啟動並連接 AI 助手後,你可以用自然語言操作藍新金流:
建立交易
你:「幫我建立一筆信用卡交易,訂單編號 A20250403001,金額 350 元,品項:年費會員」
AI: 已建立訂單 A20250403001 的付款表單,金額 NT$350。請在瀏覽器開啟以下付款頁面,顧客會被導向藍新金流的安全付款頁面填寫信用卡資料。
{
"url": "https://ccore.newebpay.com/MPG/mpg_gateway",
"form_data": {
"MerchantID": "MS358668323",
"TradeInfo": "04ac744434c76218dd6ba52b78da433f...",
"TradeSha": "EFCFC9E418A8DCBE49370897FA4FCFFA...",
"Version": "2.0"
}
}
查詢交易
你:「訂單 mcp1775195782 付款了嗎?金額 100 元」
AI: 訂單 mcp1775195782 已付款成功,以下是摘要:
| 項目 | 內容 |
|---|---|
| 狀態 | 已付款 (TradeStatus: 1) |
| 金額 | NT$100 |
| 付款方式 | 信用卡 (CREDIT) |
| 卡號 | 400022******1111 |
| 授權碼 | 114493 |
| 收單銀行 | KGI(凱基銀行) |
| 請款狀態 | 已請款 (3) |
| 退款狀態 | 無 (0) |
| 藍新交易序號 | 26040313563142518 |
{
"Status": "SUCCESS",
"Message": "查詢成功",
"Result": {
"MerchantID": "MS358668323",
"Amt": 100,
"TradeNo": "26040313563142518",
"MerchantOrderNo": "mcp1775195782",
"TradeStatus": "1",
"PaymentType": "CREDIT",
"RespondCode": "00",
"Auth": "114493",
"Card6No": "400022",
"Card4No": "1111",
"AuthBank": "KGI",
"CloseStatus": "3",
"BackStatus": "0"
}
}
請款
你:「幫我對訂單 demo1775199586 請款,金額 200 元」
AI: 訂單 demo1775199586 的請款已成功送出!
- 金額:NT$200
- 藍新交易序號:26040315000942606
- 款項將於下一個撥款週期撥入您的帳戶。
{
"Status": "SUCCESS",
"Message": "請款資料新增成功_模擬信用卡請款成功",
"Result": {
"MerchantID": "MS358668323",
"Amt": 200,
"MerchantOrderNo": "demo1775199586",
"TradeNo": "26040315000942606"
}
}
取消授權
你:「取消訂單 canc1775199618 的信用卡授權,金額 150 元」
AI: 訂單 canc1775199618 的信用卡授權已取消。
- 金額:NT$150
- 藍新交易序號:26040315002642607
- 持卡人信用卡的預扣額度已釋放。
{
"Status": "SUCCESS",
"Message": "放棄授權成功",
"Result": {
"MerchantID": "MS358668323",
"Amt": 150,
"MerchantOrderNo": "canc1775199618",
"TradeNo": "26040315002642607"
}
}
修改定期定額
你:「把委託單 P260403144725zl3MVV 的金額改成 149 元」
AI: 委託單 P260403144725zl3MVV 已更新:
- 新每期金額:NT$149
- 下次扣款日:2026-04-05
- 新金額從下一期開始生效。
{
"Status": "SUCCESS",
"Message": "定期定額委託單修改成功!",
"Result": {
"MerOrderNo": "per1775198836",
"PeriodNo": "P260403144725zl3MVV",
"AlterAmt": "149",
"NewNextAmt": "149",
"NewNextTime": "2026-04-05"
}
}
暫停定期定額
你:「暫停委託單 P260403144725zl3MVV」
AI: 委託單 P260403144725zl3MVV 已暫停,在恢復之前不會再扣款。
如需恢復,請說:「恢復委託單 P260403144725zl3MVV 的扣款」
{
"Status": "SUCCESS",
"Message": "定期定額委託單暫停成功",
"Result": {
"MerOrderNo": "per1775198836",
"PeriodNo": "P260403144725zl3MVV",
"AlterType": "suspend"
}
}
Project StructureProject Structure
mcp-newebpay/
├── app.py # MCPServer singleton
├── mcp_server.py # Entry point (stdio transport)
├── config/settings.py # Endpoints, URL builder, env switch
├── connectors/
│ └── newebpay_client.py # AES encrypt/decrypt + Form POST
├── auth/
│ └── newebpay.py # Merchant ID + Hash Key/IV credentials
├── tools/
│ ├── payment_tools.py # NDNF: query, cancel, close/refund, e-wallet refund
│ └── periodic_tools.py # NDNP: alter status, alter content
├── tests/test_all_tools.py # E2E test runner
└── reference/ # NewebPay official API docs (PDF)
mcp-newebpay/
├── app.py # MCPServer 單例
├── mcp_server.py # 入口(stdio 傳輸)
├── config/settings.py # API 端點、URL 建構、環境切換
├── connectors/
│ └── newebpay_client.py # AES 加解密 + Form POST
├── auth/
│ └── newebpay.py # 商店代號 + Hash Key/IV 憑證
├── tools/
│ ├── payment_tools.py # NDNF:查詢、取消授權、請退款、電子錢包退款
│ └── periodic_tools.py # NDNP:修改委託狀態、修改委託內容
├── tests/test_all_tools.py # E2E 測試
└── reference/ # 藍新金流官方 API 文件 (PDF)
TestingTesting
# Test connection with NewebPay API
python scripts/auth/test_connection.py
# Run all tool E2E tests
python tests/test_all_tools.py
# 測試藍新金流 API 連線
python scripts/auth/test_connection.py
# 執行所有工具 E2E 測試
python tests/test_all_tools.py
Part Of The Asgard EcosystemPart Of The Asgard Ecosystem
This server is part of the Asgard AI Platform, connecting AI to real-world services across e-commerce, finance, government data, and more.
本伺服器為 Asgard AI Platform 的一部分,連接 AI 至電商、金融、政府開放資料等真實世界服務。
Tags標籤
Need more powerful payment capabilities? 需要更強大的payment能力?
Upgrade to Asgard for enterprise-grade features, SLAs, and dedicated support.
升級至 Asgard 取得企業級功能、SLA 與專屬支援。
View Asgard Products →查看 Asgard 產品 →Related MCP Servers相關 MCP 伺服器
ezPay E-Invoice ezPay 電子發票
MCP Server for Taiwan's ezPay E-Invoice API — 7 AI-callable tools for invoice issuance (B2B/B2C), vo...
ezPay 電子發票 MCP Server — 7 個 AI 可呼叫工具,涵蓋開立發票(B2B/B2C)、作廢、折讓與查詢。
Universal EC E-Invoice 汎宇電商電子發票
MCP Server for Taiwan e-invoice (Universal EC / 汎宇電商) — 27 AI-callable tools covering all POS Web Se...
汎宇電商台灣電子發票 MCP Server — 27 個 AI 可呼叫工具,涵蓋所有 POS Web Service 功能碼(開立、作廢、折讓、查詢)。
ECPay 綠界科技金流
MCP Server for ECPay payment gateway, enabling payment processing, refund management, and transactio...
綠界科技 ECPay 金流 MCP Server,支援透過 AI 代理進行付款處理、退款管理與交易查詢。