优化结构

This commit is contained in:
Yvan
2026-08-28 00:29:40 +08:00
parent 04ff85116c
commit 03a4131f6e
118 changed files with 758 additions and 834 deletions
@@ -6,10 +6,39 @@ import (
"encoding/base64"
bizpayment "kra/internal/biz/payment"
"net/url"
"sort"
"strings"
"testing"
gopayWechat "github.com/go-pay/gopay/wechat"
gopayWechatV3 "github.com/go-pay/gopay/wechat/v3"
)
func wechatV2Sign(values map[string]string, key, signType string) string {
body := toGoPayBodyMap(values)
body.Remove("sign")
return gopayWechat.GetReleaseSign(key, wechatV2SignType(signType), body)
}
func decryptWechatV3(ciphertext, nonce, associatedData, key string) ([]byte, error) {
return gopayWechatV3.V3DecryptNotifyCipherTextToBytes(ciphertext, nonce, associatedData, key)
}
func alipaySignContent(values url.Values) string {
keys := make([]string, 0, len(values))
for key := range values {
if key != "sign" && values.Get(key) != "" {
keys = append(keys, key)
}
}
sort.Strings(keys)
parts := make([]string, 0, len(keys))
for _, key := range keys {
parts = append(parts, key+"="+values.Get(key))
}
return strings.Join(parts, "&")
}
func TestWechatV2SignOfficialStyle(t *testing.T) {
values := map[string]string{
"appid": "wxd930ea5d5a258f4f", "mch_id": "10000100", "device_info": "1000",