package lib import ( "fmt" "kefu/tools" "log" "testing" "time" ) var ( appId = "1wx302b154e07c1b830" //公众号APPID mchID = "11634212571" //商户号 mchCertificateSerialNumber = "13ABF0709AF730BBF26C6F470FCB3B823B9AC931C" //商户证书序列号 //商户API V3密钥 mchAPIv3Key = "14C49DC3FC55E22983CAA24088C99E8C9" //商户私钥 mchPrivateKey = `-----BEGIN PRIVATE KEY----- 1MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCuabXxDkLK/gHp JXeSOvAP/9EpGLwKiAlcADLylO4D5CMpqSx7szB2ygISFN8zWkZYO4uVxRZomp2z E/Cn44tmjxsbZAu8Wl/ltsG+fmm39uz52V893BWgBDEKl3nnxXPGNR4m1SXjSIp+ pBoWY1s/HgH3xMJjqMrtAgcXAoHUmXCLyaEAzUzC/ZOnAWSKVxr8xKI6TBlV6cJv d+6+WZoJNzOgI4NX/tlydAWxnIUlSQSM75jRXhPHq2raZdh3+jK5Ic0cjYlutbio hIRLj34PwbIYJHS2kBrumIhRNy6VAmnb5zVyRQXnFVS2jEqflcZ+BJoElzhYogkz 9vBmMYTDAgMBAAECggEAdtvHh+1GC3wq5S4JXHgZ3W1ipvUaQLsQVcg08CgaRECW ze9iRzKIVou3+YaLzT06Lyr1Jy3W5ZZo3f86w89H0q63tGTrsoKMU8nGIwGXHi2C tYozY762ZgQ1P5iXFSH0kiDk2WXsmgV3jHJc7ODs8AiNIsLODoibMgVtu3qT68M9 Q+mR5yCgKunwCFkknC7DynzALKKRqF7g7gYU7TeAnT7W0JB9rH6h5At8u+oYp1kJ INEPCIf+oDG2+I/hcB/JMMdPCRpkI/DrnSKtrlU6yTWI8tMqn+uJ4Kf3UbcQzKOB KsBWdKwOm/a6VgYmcARsfao2AaUIYYX/0vp3tq5UgQKBgQDbI+LbWxPwgUZMwcXP vueFUme2Bxlk2m++wtjPrp116HomDW/lZSxRo675nIXIk1CrEhDQql+5Nd+FYb/P cnik0ct1D60aRNgyo2sgG3GVfcljBjEo3raBMD3hEWVBdsum0xTkuu9sB8QER2vg cmnq55MU8GJgW66a+kIVYsK/YQKBgQDLv+HJTOMsVx5PFDpZXqieG3CLh1DXhaRa v7ERfgPZQ7Hr1phAVxtP/2RAzubzriZufn3j1Bei8J+vWURc6ggWQHpC6JXX069r F0d7oyPlzgziuQ8KwaetL2luLxSew5oEbEj4lmVMmwrjzEpzPlD8gu2Ju+21zLJ9 zJpetyPqowKBgQCnglb2tjgXr7m9EqHSm2r+Tm9YhTS0EwU4HFj+58sVRg+Y5syR 3TRzc1tdEnhxSapwGe8gkht5x+SEYKPuPuJZmsSbRtBbNCTPEHvinxfD3dMDDsil JRj8x5OFZ3avA8/IRbHC5eH+AjGj07RybQLpvPqBFv8cCPj/Hi1Fi6iyAQKBgBMG BGfOJPvT2oGZquUDQI0alMSCStsEoFbUxQyUDnnvpyIU9Dw1pdgvSUX/y3J/FRmF 9+0YtWhCPTabCBYAx+aD+KZcnvj6y8sc7lCt58EiHvPgQXZIpIY4AgkGnk9AhhXZ omqLaEPhyf+A6IagD+Gzu8f7YvNxfEzgmJ01TkYvAoGALTLoYt9DQb6J9Lpdgdyn Av7HVkgvBDY4S2zxBRl0Kidf8N5vmhgohlL/ErCARUZiGB08eEgcrHfCxQ9exG0O icMzFXihJ2eN3KIwebKp/2xSo9HEkFXmjiPTpeydMZn0VNGa/dJ/7CaEcuZ+8QRj 6ItYVaS0JVYn8Imh+QVxmAQ= -----END PRIVATE KEY-----` notifyUrl = "https://gofly.v1kf.com/api/v1/5/taoshihan/wechat_pay/notify" ) func TestNewWechatPay(t *testing.T) { wechatpay, err := NewWechatPay(appId, mchID, mchCertificateSerialNumber, mchAPIv3Key, mchPrivateKey, notifyUrl) log.Println(wechatpay, err) } func TestNativePayPreOrder(t *testing.T) { snow, _ := tools.NewSnowflake(1) orderId := fmt.Sprintf("%s%d", time.Now().Format("0601021504"), snow.Generate()) wechatpay, _ := NewWechatPay(appId, mchID, mchCertificateSerialNumber, mchAPIv3Key, mchPrivateKey, notifyUrl) wechatpay.NativePayPreOrder(1, "客服系统充值服务", orderId) } func TestNativePayQueryOrder(t *testing.T) { wechatpay, _ := NewWechatPay(appId, mchID, mchCertificateSerialNumber, mchAPIv3Key, mchPrivateKey, notifyUrl) body, res, err := wechatpay.NativePayQueryOrder("2308271940880416513704595456") log.Println(body, res, err) }