Skip to main content
Glama

paytriage

读取支付网关错误,告诉你它可能意味着什么、接下来该检查什么,以及重试是否安全。

把它指向一行日志、一个错误字符串或整个日志文件。它用平实的语言回答,而不是给你一个需要去查的代码。

无依赖。Python 3.8 及以上。可用作 CLI、库,以及代理可以调用的 MCP 服务器。

为什么

支持和实施人员花费大量时间把 response_code="51" 翻译成"客户的卡里没有钱,这不是你的问题"。这种翻译存在于人们的头脑中和书签收藏的 PDF 里。这个工具把它放在一个你可以阅读、grep 和修正的文件中。

超时是最重要的情况。超时不是拒付。交易可能已经在对方那边被授权了,所以盲目重试就是重复扣款的方式。paytriage 每次都会明确说出这一点。

安装

git clone https://github.com/Flyingmiata-droid/paytriage.git
cd paytriage
pip install -e .

或者跳过安装,直接用 python -m paytriage.cli 就地运行。

从命令行使用

$ paytriage 'AUTH DECLINED response_code="51" insufficient funds'

  [low] Insufficient funds  (decline)
    cause: The issuer declined the authorization because the account did not have
           enough available balance or credit.
    check: Nothing to fix on the integration side. Ask the cardholder to use
           another card or retry later.
    matched response code: 51
    safe to retry: no

整个文件,汇总输出:

$ paytriage -f examples/gateway.log --summary

lines: 11  matched: 9  unmatched: 2

by severity:
  low: 2
  medium: 3
  high: 2
  critical: 2

by signature:
  decline.insufficient_funds: 1
  transport.tls_handshake: 1
  format.signature_mismatch: 1
  ...

在任何调用中添加 --json 即可获得机器可读的输出。

作为库使用

from paytriage import triage_line

result = triage_line("SSLError: handshake failure tlsv1 alert protocol version")

result.severity          # "critical"
result.retryable         # True
result.findings[0].label # "TLS handshake failure"
result.findings[0].fix   # what to check

作为 MCP 服务器使用

该服务器通过 stdio 使用 JSON-RPC 通信,并暴露一个工具 triage_payment_error,代理可以将错误交给它并获得结构化输出。

python -m paytriage.mcp_server

Claude Desktop 或 Claude Code 配置:

{
  "mcpServers": {
    "paytriage": {
      "command": "python",
      "args": ["-m", "paytriage.mcp_server"]
    }
  }
}

覆盖范围

六个类别共二十四种签名:

  • 拒付:余额不足、不予承兑、卡已过期、收回卡片、卡号无效

  • 验证:AVS 不匹配、CVV 不匹配

  • 传输:TLS 握手、证书过期或不受信任、超时、连接被拒绝或重置、DNS

  • API:401、403、429、5xx

  • 消息格式:XML 解析、JSON 解析、签名或 HMAC 不匹配、缺少必填字段

  • 业务规则:重复交易、不支持的货币、金额错误、令牌无效

匹配方式为:存在响应码时按响应码匹配,否则按模式匹配。一行可以匹配多个签名,结果按严重程度从高到低返回。

它不是

  • 不是欺诈评分,也不是风险引擎。

  • 不连接任何网关。它只读取你已有的文本,不发起任何网络调用。

  • 并非详尽无遗。它是一个初步分流辅助工具。对于任何特定代码,发卡行自己的文档仍然是权威。

  • 不是决策者。这里没有任何东西应该自行自动重试付款。

添加签名

所有内容都放在 paytriage/signatures.py 中的一个表里。一个签名是一个模式或一组代码,加上原因、修复方法和严重程度。添加一个条目,添加一个测试,提交一个 pull request。对现有措辞的修正和新条目一样受欢迎。

测试

python -m unittest discover -s tests -t .

23 个测试,无网络,无需下载测试夹具。

许可证

MIT。参见 LICENSE

-
license - not tested
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • Check if a counterparty is safe to pay: trust/risk score for AI agents. Scam/phishing screen.

  • Find your AI agent's likely failure mode, get runtime settings, and clarify ambiguous prompts.

  • Verify x402 payment endpoints before an AI agent pays: scam scan, on-chain checks, trust scores.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Flyingmiata-droid/paytriage'

If you have feedback or need assistance with the MCP directory API, please join our Discord server