支付模拟服务器

一个基于Go语言实现的Stripe API封装服务器,用于模拟AI代理的支付场景。

  • by dothanhlam
  • Go
  • 本地部署
  • 更新于
在 GitHub 查看 dothanhlam/go-payment-mcp

使用说明

Go Stripe MCP服务器

Go中实现的MCP服务器,包裹Stripe API以模拟人工智能代理的支付场景。

先决条件

  • 转到1.22+
  • 条纹密钥(测试模式)

安装

  1. 初始化依赖关系:

    go mod tidy
    
  2. 构建服务器:

    go build -o stripe-mcp
    

用法

环境变量

export STRIPE_SECRET_KEY=sk_test_...

运行服务器

./stripe-mcp

工具

工具 说明
create_payment 创建Stripe PaymentIntent(仅限卡)。返回PI ID和客户端密码。
mock_confirm_payment 使用测试PaymentMethod ID确认PaymentIntent以模拟结果。
get_payment 检索PaymentIntent的当前状态和详细信息。
cancel_payment 取消付款意向。
create_refund 对成功的PaymentIntent发出全额或部分退款。

测试付款方法ID mock_confirm_payment

备注:这些是Stripe PaymentMethod测试ID(pm_card_*),而不是传统源令牌(tok_*).

test_token value 模拟结果
pm_card_visa 成功
pm_card_chargeDeclined 普遍下降
pm_card_visa_chargeDeclinedInsufficientFunds 资金不足
pm_card_cvcCheckFail CVC检查失败

示例流程

  1. 创建付款:

    create_payment(amount="20.00", currency="usd", description="Test order")
    → PaymentIntent ID: pi_xxx
    
  2. 模拟确认:

    mock_confirm_payment(payment_intent_id="pi_xxx", test_token="pm_card_visa")
    → Payment Confirmed Successfully. Status: succeeded
    
  3. 检查状态:

    get_payment(payment_intent_id="pi_xxx")
    → Status: succeeded
    
  4. 退款:

    create_refund(payment_intent_id="pi_xxx", amount="10.00")
    → Refund Created. Status: succeeded