优化结构
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user