add
This commit is contained in:
parent
2261c021fa
commit
f0050a938e
|
@ -32,34 +32,7 @@ wxpay:
|
||||||
appid: "wxc28fd8aaf31984b6"
|
appid: "wxc28fd8aaf31984b6"
|
||||||
serial_no: "51D8E75620B9569F10FF5363022F3C9D2152DF50"
|
serial_no: "51D8E75620B9569F10FF5363022F3C9D2152DF50"
|
||||||
apiv3_key: "UoaswgnuKYwIadqxCVag1IZlq5n9USvt"
|
apiv3_key: "UoaswgnuKYwIadqxCVag1IZlq5n9USvt"
|
||||||
private_key: "-----BEGIN PRIVATE KEY-----
|
private_key_path: "/app/wishpal-ironfan/etc/mix/wxpaycert/apiclient_key.pem"
|
||||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDgxWmqIZVZEVdO
|
|
||||||
/XNOzc66UkyYAS6/LzTAWP6WW/wIfilaDSDAe99jUspFKl1YmubJkDJ5Y2WaHcOy
|
|
||||||
irgfYX3GHMrr1x7vtqON6eQPiGShlf9HlOQCdi1zmUrBeMWj5Tcll+ldyazYaqR4
|
|
||||||
yG6ahhj1BnsqZ+W6Sa9xtTfMtTUrBvJuHm4dWAQR62A2Teetk9YN9cxiOwL7BXaJ
|
|
||||||
o5hYaumNobz7pIz6XHqBgEhBH6Qv8ka746NOR1UFSvMeqHWv+uyBzUthdIKFLCRE
|
|
||||||
gQmFToXs7oJsuF2nshZKnMPta3Xvi8wbPbAZc4b4KwLLv9SxBKiRhztagF8KqYn1
|
|
||||||
k4RB8mFDAgMBAAECggEAFfMxXmvpKcmHvS8DE68FgSyITk/PQNxbSm1mb0iMVEf9
|
|
||||||
wc2GZUWziv+KwTZh50U5RHXQeAo84dAGTGk/kdDzd2VYa6+WVdKAJluw6dNoAF+l
|
|
||||||
jlf77EGeLqvJoRsqMdcwi3tKTt5jAr9nUGRCaNSvmz4GyR1cUdTgTTplOJh5mLnm
|
|
||||||
GGZQPVR87pex00QCTtQ7dggG/vg8QM+XbBeSAkWByeUDsrCo4pKbsY+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hMhx1iTsjr/ockyUZuXKiCr5Q43tzrMJ
|
|
||||||
tMrOrkquEUSn+XDIomat7Bnw
|
|
||||||
-----END PRIVATE KEY-----"
|
|
||||||
notify_url: "https://api.wishpal.cn/ext/vas/wxpay_callback"
|
notify_url: "https://api.wishpal.cn/ext/vas/wxpay_callback"
|
||||||
|
|
||||||
crypto:
|
crypto:
|
||||||
|
|
|
@ -63,12 +63,12 @@ type RedisConfig struct {
|
||||||
|
|
||||||
// 微信支付客户端配置
|
// 微信支付客户端配置
|
||||||
type WxpayClientConfig struct {
|
type WxpayClientConfig struct {
|
||||||
MchId string `json:"mchid" yaml:"mchid"` // 商户id
|
MchId string `json:"mchid" yaml:"mchid"` // 商户id
|
||||||
AppId string `json:"appid" yaml:"appid"` // appid
|
AppId string `json:"appid" yaml:"appid"` // appid
|
||||||
SerialNo string `json:"serial_no" yaml:"serial_no"` // 商户API证书的证书序列号
|
SerialNo string `json:"serial_no" yaml:"serial_no"` // 商户API证书的证书序列号
|
||||||
ApiV3Key string `json:"apiv3_key" yaml:"apiv3_key"` // APIv3Key,商户平台获取
|
ApiV3Key string `json:"apiv3_key" yaml:"apiv3_key"` // APIv3Key,商户平台获取
|
||||||
PrivateKey string `json:"private_key" yaml:"private_key"` // 商户API证书下载后,私钥 apiclient_key.pem 读取后的字符串内容
|
PrivateKeyPath string `json:"private_key_path" yaml:"private_key_path"` // 商户API证书下载后,私钥 apiclient_key.pem 读取后的字符串内容
|
||||||
NotifyUrl string `json:"notify_url" yaml:"notify_url"` // 回调地址
|
NotifyUrl string `json:"notify_url" yaml:"notify_url"` // 回调地址
|
||||||
}
|
}
|
||||||
|
|
||||||
// 账号相关验密配置
|
// 账号相关验密配置
|
||||||
|
|
|
@ -3,6 +3,7 @@ package wxpaycli
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-pay/gopay"
|
"github.com/go-pay/gopay"
|
||||||
|
@ -30,7 +31,15 @@ func GetDefaultWxpayClient() *WxpayClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Init(cfg *configcenter.WxpayClientConfig) (err error) {
|
func Init(cfg *configcenter.WxpayClientConfig) (err error) {
|
||||||
wxpayCli, err := wxpay.NewClientV3(cfg.MchId, cfg.SerialNo, cfg.ApiV3Key, cfg.PrivateKey)
|
// private key
|
||||||
|
bs, err := os.ReadFile(cfg.PrivateKeyPath)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("real PrivateKeyPath fail, cfg: %v, err: %v", util.ToJson(cfg), err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
privateKey := string(bs)
|
||||||
|
|
||||||
|
wxpayCli, err := wxpay.NewClientV3(cfg.MchId, cfg.SerialNo, cfg.ApiV3Key, privateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("NewClientV3 fail, cfg: %v, err: %v", util.ToJson(cfg), err)
|
logger.Error("NewClientV3 fail, cfg: %v, err: %v", util.ToJson(cfg), err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -4,48 +4,20 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"service/app/mix/conf"
|
||||||
"service/library/configcenter"
|
"service/library/configcenter"
|
||||||
"service/library/idgenerator"
|
"service/library/idgenerator"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
cfg := &configcenter.WxpayClientConfig{
|
cfg := new(conf.ConfigSt)
|
||||||
MchId: "1665016206",
|
err := configcenter.LoadConfig("/Users/erwin/wishpalv2/service/etc/mix/mix-test.yaml", cfg)
|
||||||
AppId: "wxc28fd8aaf31984b6",
|
if err != nil {
|
||||||
SerialNo: "51D8E75620B9569F10FF5363022F3C9D2152DF50",
|
fmt.Printf("%v\n", err)
|
||||||
ApiV3Key: "UoaswgnuKYwIadqxCVag1IZlq5n9USvt",
|
|
||||||
PrivateKey: `-----BEGIN PRIVATE KEY-----
|
|
||||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDgxWmqIZVZEVdO
|
|
||||||
/XNOzc66UkyYAS6/LzTAWP6WW/wIfilaDSDAe99jUspFKl1YmubJkDJ5Y2WaHcOy
|
|
||||||
irgfYX3GHMrr1x7vtqON6eQPiGShlf9HlOQCdi1zmUrBeMWj5Tcll+ldyazYaqR4
|
|
||||||
yG6ahhj1BnsqZ+W6Sa9xtTfMtTUrBvJuHm4dWAQR62A2Teetk9YN9cxiOwL7BXaJ
|
|
||||||
o5hYaumNobz7pIz6XHqBgEhBH6Qv8ka746NOR1UFSvMeqHWv+uyBzUthdIKFLCRE
|
|
||||||
gQmFToXs7oJsuF2nshZKnMPta3Xvi8wbPbAZc4b4KwLLv9SxBKiRhztagF8KqYn1
|
|
||||||
k4RB8mFDAgMBAAECggEAFfMxXmvpKcmHvS8DE68FgSyITk/PQNxbSm1mb0iMVEf9
|
|
||||||
wc2GZUWziv+KwTZh50U5RHXQeAo84dAGTGk/kdDzd2VYa6+WVdKAJluw6dNoAF+l
|
|
||||||
jlf77EGeLqvJoRsqMdcwi3tKTt5jAr9nUGRCaNSvmz4GyR1cUdTgTTplOJh5mLnm
|
|
||||||
GGZQPVR87pex00QCTtQ7dggG/vg8QM+XbBeSAkWByeUDsrCo4pKbsY+kxKGCkhV0
|
|
||||||
3hxgHz2v7QZ8kanbgVPZzB76tOxRf9ghUQ5TFPc9kjgtQmn5ViqzMTXdotFXlE/u
|
|
||||||
n82BreEK03E9kWE3Uvt9jf21oJkQGQsRqTNYd8uIAQKBgQDyNOIIOnOgwt3coiZk
|
|
||||||
LYmo+F/zQQm6R8gebYWO1XCKLkMto9JaeJyEpehZQngMJvJc4r+4tWNFv8rcOHu5
|
|
||||||
/7SnteVUJK4RBXpKosLqswqD0ySEXzNLloumvxXz8HnXIiTSQ3rtISQSHzp0uunq
|
|
||||||
fkTzezc9ZRT08Jx6rmLvpKsJ3QKBgQDtklbus1fRQ/zbdddKbTfYMZsWSi7qQiA3
|
|
||||||
AKM7rY6wrS1gUJtVk9mhNgUe0uIvkkdQvtm/QKiSrtgGkre59g9sekZppCyWId6a
|
|
||||||
i1tlFvkG16Oc/TsAJDBNJgtWrkPDsjjHSx2VExTeRJ30XGd8lx3EEWHEbSboGPbf
|
|
||||||
G3gxm9a1nwKBgAdH06uPpj4k3WpubV0BiWvM24WCZPp2get4O1WJ0PI2ZcqPbBlQ
|
|
||||||
GtRZ8FwOhXFIEmz8W+r/eNZ153ErOXzj1NhdvWEEIT9dvMlVjypi62P/Cs/31KDn
|
|
||||||
C5edktlcVy1CV30CjkVmg6EP00ADBlkIJqZzA7wSt8iNGwcNCuhNON75AoGBAOGA
|
|
||||||
GXIj24RwM1Agr8UenHZix6HFsnh7YdazjT11RU7gYoTcnkUBvP5vpzaV10puX7D+
|
|
||||||
JvOJrTjmK3k5xJkIPaWq/rEBu6yZ45DwHEV9I81h3BSErX852nswVGznprzXq1tI
|
|
||||||
KoE5BoLfwMqU90nkqsVT9mgbb2W5ZINrsI/uK0RjAoGBAL+9L8iJx6/M4yQosTrQ
|
|
||||||
IL6SOxPU3HlfkqZzObiQ8vs7VdIpGhB1EMc9UEKe8RcnpTUeLsVeNHdiDZzRHtJ3
|
|
||||||
RxZS/AsjJtYAZ2f/maJhgQsh6JN1AceDhMhx1iTsjr/ockyUZuXKiCr5Q43tzrMJ
|
|
||||||
tMrOrkquEUSn+XDIomat7Bnw
|
|
||||||
-----END PRIVATE KEY-----`,
|
|
||||||
NotifyUrl: "https://api.tiefen.fun/vas/wxpay_callback",
|
|
||||||
}
|
}
|
||||||
err := Init(cfg)
|
|
||||||
|
err = Init(cfg.Wxpay)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
Loading…
Reference in New Issue