2025-12-13 17:44:18 +08:00
|
|
|
|
syntax = "v1"
|
|
|
|
|
|
|
|
|
|
|
|
info (
|
|
|
|
|
|
title: "支付服务"
|
|
|
|
|
|
desc: "支付服务"
|
|
|
|
|
|
version: "v1"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@server (
|
|
|
|
|
|
prefix: api/v1
|
|
|
|
|
|
group: pay
|
|
|
|
|
|
)
|
|
|
|
|
|
service main {
|
|
|
|
|
|
// 微信支付回调
|
|
|
|
|
|
@handler WechatPayCallback
|
|
|
|
|
|
post /pay/wechat/callback
|
|
|
|
|
|
|
|
|
|
|
|
// 支付宝支付回调
|
|
|
|
|
|
@handler AlipayCallback
|
|
|
|
|
|
post /pay/alipay/callback
|
|
|
|
|
|
|
|
|
|
|
|
// 微信退款回调
|
|
|
|
|
|
@handler WechatPayRefundCallback
|
|
|
|
|
|
post /pay/wechat/refund_callback
|
2026-06-06 11:52:06 +08:00
|
|
|
|
|
|
|
|
|
|
// 微信小程序虚拟支付发货推送(GET 验签 + POST 事件)
|
|
|
|
|
|
@handler XpayPush
|
|
|
|
|
|
get /pay/xpay/push
|
|
|
|
|
|
post /pay/xpay/push
|
2025-12-13 17:44:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@server (
|
|
|
|
|
|
prefix: api/v1
|
|
|
|
|
|
group: pay
|
|
|
|
|
|
jwt: JwtAuth
|
|
|
|
|
|
middleware: AuthInterceptor
|
|
|
|
|
|
)
|
|
|
|
|
|
service main {
|
|
|
|
|
|
// 支付
|
|
|
|
|
|
@handler Payment
|
|
|
|
|
|
post /pay/payment (PaymentReq) returns (PaymentResp)
|
|
|
|
|
|
|
|
|
|
|
|
@handler IapCallback
|
|
|
|
|
|
post /pay/iap_callback (IapCallbackReq)
|
|
|
|
|
|
|
|
|
|
|
|
@handler PaymentCheck
|
|
|
|
|
|
post /pay/check (PaymentCheckReq) returns (PaymentCheckResp)
|
2026-06-07 14:47:50 +08:00
|
|
|
|
|
|
|
|
|
|
// 小程序虚拟支付:上报微信/Apple 客户端提示与步骤(写入服务端日志并可选查微信单)
|
|
|
|
|
|
@handler XpayClientEvent
|
|
|
|
|
|
post /pay/xpay/client-event (XpayClientEventReq) returns (XpayClientEventResp)
|
2025-12-13 17:44:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
|
|
PaymentReq {
|
|
|
|
|
|
Id string `json:"id"`
|
|
|
|
|
|
PayMethod string `json:"pay_method"` // 支付方式: wechat, alipay, appleiap, test(仅开发环境), test_empty(仅开发环境-空报告模式)
|
|
|
|
|
|
PayType string `json:"pay_type" validate:"required,oneof=query agent_vip agent_upgrade"`
|
2026-02-06 16:00:04 +08:00
|
|
|
|
Code string `json:"code,optional"` // 微信小程序/H5授权码,用于自动绑定微信账号(当用户未绑定微信时)
|
2025-12-13 17:44:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
PaymentResp {
|
|
|
|
|
|
PrepayData interface{} `json:"prepay_data"`
|
|
|
|
|
|
PrepayId string `json:"prepay_id"`
|
|
|
|
|
|
OrderNo string `json:"order_no"`
|
|
|
|
|
|
}
|
|
|
|
|
|
PaymentCheckReq {
|
|
|
|
|
|
OrderNo string `json:"order_no" validate:"required"`
|
|
|
|
|
|
}
|
|
|
|
|
|
PaymentCheckResp {
|
2026-06-07 14:39:21 +08:00
|
|
|
|
Type string `json:"type"`
|
|
|
|
|
|
Status string `json:"status"`
|
|
|
|
|
|
WxSyncError string `json:"wx_sync_error,optional"` // query_order 失败时微信返回
|
|
|
|
|
|
WxOrderStatus int `json:"wx_order_status,optional"` // 微信侧订单 status
|
|
|
|
|
|
WxOrderDetail string `json:"wx_order_detail,optional"` // query_order 原始 order 摘要(排查用)
|
2025-12-13 17:44:18 +08:00
|
|
|
|
}
|
2026-06-07 14:47:50 +08:00
|
|
|
|
XpayClientEventReq {
|
|
|
|
|
|
OrderNo string `json:"order_no,optional"`
|
|
|
|
|
|
Stage string `json:"stage" validate:"required"` // prepay_ok, invoke, success, fail, check
|
|
|
|
|
|
EventType string `json:"event_type" validate:"required,oneof=info tip fail success"`
|
|
|
|
|
|
Message string `json:"message,optional"` // 微信/Apple 展示给用户的话术(非 HTTP 报错)
|
|
|
|
|
|
ErrMsg string `json:"err_msg,optional"`
|
|
|
|
|
|
ErrCode int `json:"err_code,optional"`
|
|
|
|
|
|
Errno int `json:"errno,optional"`
|
|
|
|
|
|
SignData string `json:"sign_data,optional"`
|
|
|
|
|
|
Device string `json:"device,optional"`
|
|
|
|
|
|
Extra string `json:"extra,optional"`
|
|
|
|
|
|
}
|
|
|
|
|
|
XpayClientEventResp {
|
|
|
|
|
|
WxOrderStatus int `json:"wx_order_status,optional"`
|
|
|
|
|
|
WxOrderDetail string `json:"wx_order_detail,optional"`
|
|
|
|
|
|
WxSyncError string `json:"wx_sync_error,optional"`
|
|
|
|
|
|
}
|
2025-12-13 17:44:18 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
|
|
IapCallbackReq {
|
|
|
|
|
|
OrderID string `json:"order_id" validate:"required"`
|
|
|
|
|
|
TransactionReceipt string `json:"transaction_receipt" validate:"required"`
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|