优化结构
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
bizpayment "kra/internal/biz/payment"
|
||||
"kra/internal/paymentkit"
|
||||
"strings"
|
||||
|
||||
"github.com/go-pay/gopay"
|
||||
@@ -126,7 +127,7 @@ func qqCreateMethod(extra, config map[string]any) (string, error) {
|
||||
if value == "" {
|
||||
value = firstAny(config, "trade_type", "pay_type", "method", "pay_method")
|
||||
}
|
||||
normalized := strings.ToUpper(strings.ReplaceAll(strings.TrimSpace(value), "-", "_"))
|
||||
normalized := strings.ToUpper(paymentkit.NormalizePaymentMethod(value))
|
||||
switch normalized {
|
||||
case "", "NATIVE", "QR", "QRCODE":
|
||||
return gopayQQ.TradeType_Native, nil
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
bizpayment "kra/internal/biz/payment"
|
||||
"kra/internal/paymentkit"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -120,7 +121,7 @@ func (a *wechatV3Adapter) Create(ctx context.Context, req *bizpayment.PaymentReq
|
||||
}
|
||||
|
||||
func normalizeWechatV3TradeType(value string) string {
|
||||
return strings.NewReplacer(".", "", "-", "_", " ", "_").Replace(strings.ToLower(strings.TrimSpace(value)))
|
||||
return paymentkit.NormalizePaymentMethod(value)
|
||||
}
|
||||
|
||||
func wechatV3CodePayResult(tradeNo string, rsp *gopayWechatV3.CodePayRsp) (*bizpayment.PaymentResult, error) {
|
||||
|
||||
Reference in New Issue
Block a user