优化逻辑

This commit is contained in:
Yvan
2026-09-23 18:20:17 +08:00
parent 7498f59bd8
commit eb529c696e
6 changed files with 1018 additions and 63 deletions
+13 -5
View File
@@ -39,15 +39,23 @@ func (a *wechatV3Adapter) Create(ctx context.Context, req *bizpayment.PaymentReq
bm.SetBodyMap("amount", func(amount gopay.BodyMap) {
amount.Set("total", req.Amount).Set("currency", strings.ToUpper(req.Currency))
})
mergeGoPayExtras(bm, req.Extra,
"appid", "mchid", "description", "out_trade_no", "notify_url", "amount", "payer",
"trade_type", "pay_type", "method", "openid", "open_id", "auth_code", "authcode", "barcode",
)
tradeType := normalizeWechatV3TradeType(firstAny(req.Extra, "trade_type", "pay_type", "method"))
if tradeType == "" {
tradeType = normalizeWechatV3TradeType(firstAny(c, "trade_type", "pay_type", "method"))
}
if tradeType == "native" || tradeType == "qr" || tradeType == "qrcode" {
// Native orders only accept the fields defined by the WeChat transaction API.
for _, key := range []string{"time_expire", "attach", "goods_tag", "support_fapiao", "detail", "scene_info", "settle_info"} {
if value, ok := req.Extra[key]; ok {
bm[key] = value
}
}
} else {
mergeGoPayExtras(bm, req.Extra,
"appid", "mchid", "description", "out_trade_no", "notify_url", "amount", "payer",
"trade_type", "pay_type", "method", "openid", "open_id", "auth_code", "authcode", "barcode",
)
}
switch tradeType {
case "", "jsapi", "js_api", "mini", "miniapp", "mini_app", "miniprogram", "mini_program", "applet":
if openID := firstAny(req.Extra, "openid", "open_id"); openID != "" {