|
@@ -17,7 +17,7 @@ const (
|
|
|
MchAPIv3Key = "W1tbnzQrzQ7yRRNuQCIHjis8dgdasKVX"
|
|
|
)
|
|
|
|
|
|
-func initUU() {
|
|
|
+func init111w() {
|
|
|
ExampleJsapiApiService_Prepay()
|
|
|
}
|
|
|
|
|
@@ -29,7 +29,6 @@ func getWechatClient() (context.Context, *core.Client, error) {
|
|
|
log.Print("load merchant private key error")
|
|
|
return nil, nil, err
|
|
|
}
|
|
|
- fmt.Println("mchPrivateKey", mchPrivateKey)
|
|
|
ctx := context.Background()
|
|
|
// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
|
|
|
opts := []core.ClientOption{
|
|
@@ -44,21 +43,25 @@ func getWechatClient() (context.Context, *core.Client, error) {
|
|
|
}
|
|
|
|
|
|
func ExampleJsapiApiService_Prepay() {
|
|
|
- mchPrivateKey, err := payUtils.LoadPrivateKeyWithPath(MchPKFileName)
|
|
|
+ //mchPrivateKey, err := payUtils.LoadPrivateKeyWithPath(MchPKFileName)
|
|
|
+ //if err != nil {
|
|
|
+ // log.Print("load merchant private key error")
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //ctx := context.Background()
|
|
|
+ //// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
|
|
|
+ //opts := []core.ClientOption{
|
|
|
+ // option.WithWechatPayAutoAuthCipher(Mchid, MchCertificateSerialNumber, mchPrivateKey, MchAPIv3Key),
|
|
|
+ //}
|
|
|
+ //client, err := core.NewClient(ctx, opts...)
|
|
|
+ ctx, client, err := getWechatClient()
|
|
|
if err != nil {
|
|
|
- log.Print("load merchant private key error")
|
|
|
+ log.Printf("getWechatClientt err:%s", err)
|
|
|
return
|
|
|
}
|
|
|
- ctx := context.Background()
|
|
|
- // 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
|
|
|
- opts := []core.ClientOption{
|
|
|
- option.WithWechatPayAutoAuthCipher(Mchid, MchCertificateSerialNumber, mchPrivateKey, MchAPIv3Key),
|
|
|
- }
|
|
|
- client, err := core.NewClient(ctx, opts...)
|
|
|
-
|
|
|
svc := jsapi.JsapiApiService{Client: client}
|
|
|
// 得到prepay_id,以及调起支付所需的参数和签名
|
|
|
- resp, result, err := svc.PrepayWithRequestPayment(ctx,
|
|
|
+ resp, _, err := svc.PrepayWithRequestPayment(ctx,
|
|
|
jsapi.PrepayRequest{
|
|
|
Appid: core.String("wx5e3240ab90c247ac"),
|
|
|
Mchid: core.String(Mchid),
|
|
@@ -70,12 +73,14 @@ func ExampleJsapiApiService_Prepay() {
|
|
|
Total: core.Int64(1),
|
|
|
},
|
|
|
Payer: &jsapi.Payer{
|
|
|
- Openid: core.String("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o"),
|
|
|
+ Openid: core.String("ouw2U62cUWNe97e96AZ5jxeAgrJM"),
|
|
|
},
|
|
|
},
|
|
|
)
|
|
|
- fmt.Println("result", result.Response)
|
|
|
- fmt.Println("result", result.Request)
|
|
|
+ //fmt.Println("result", result.Response)
|
|
|
+ fmt.Println("result", resp.PrepayId)
|
|
|
+ //fmt.Println("result", log.(resp.Appid))
|
|
|
+ //fmt.Println("result", result.Request)
|
|
|
if err == nil {
|
|
|
log.Println(resp)
|
|
|
} else {
|