|
@@ -7,6 +7,8 @@ import (
|
|
|
"github.com/wechatpay-apiv3/wechatpay-go/core/option"
|
|
|
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/jsapi"
|
|
|
payUtils "github.com/wechatpay-apiv3/wechatpay-go/utils"
|
|
|
+ "hongze/hongze_mfyx/models/order"
|
|
|
+ "hongze/hongze_mfyx/utils"
|
|
|
"log"
|
|
|
)
|
|
|
|
|
@@ -17,9 +19,9 @@ const (
|
|
|
MchAPIv3Key = "W1tbnzQrzQ7yRRNuQCIHjis8dgdasKVX"
|
|
|
)
|
|
|
|
|
|
-func init111w() {
|
|
|
- ExampleJsapiApiService_Prepay()
|
|
|
-}
|
|
|
+//func init() {
|
|
|
+// ExampleJsapiApiServicePrepay()
|
|
|
+//}
|
|
|
|
|
|
// 获取加解密处理
|
|
|
func getWechatClient() (context.Context, *core.Client, error) {
|
|
@@ -42,7 +44,7 @@ func getWechatClient() (context.Context, *core.Client, error) {
|
|
|
return ctx, client, nil
|
|
|
}
|
|
|
|
|
|
-func ExampleJsapiApiService_Prepay() {
|
|
|
+func ExampleJsapiApiServicePrepay(orderDetail *order.CygxOrder, openid string) {
|
|
|
//mchPrivateKey, err := payUtils.LoadPrivateKeyWithPath(MchPKFileName)
|
|
|
//if err != nil {
|
|
|
// log.Print("load merchant private key error")
|
|
@@ -63,26 +65,23 @@ func ExampleJsapiApiService_Prepay() {
|
|
|
// 得到prepay_id,以及调起支付所需的参数和签名
|
|
|
resp, _, err := svc.PrepayWithRequestPayment(ctx,
|
|
|
jsapi.PrepayRequest{
|
|
|
- Appid: core.String("wx5e3240ab90c247ac"),
|
|
|
+ Appid: core.String(utils.WxAppId),
|
|
|
Mchid: core.String(Mchid),
|
|
|
- Description: core.String("Image形象店-深圳腾大-QQ公仔"),
|
|
|
- OutTradeNo: core.String("1217752501201407033233368018"),
|
|
|
- Attach: core.String("自定义数据说明"),
|
|
|
+ Description: core.String(orderDetail.SourceTitle),
|
|
|
+ OutTradeNo: core.String(orderDetail.OrderCode),
|
|
|
+ Attach: core.String(""),
|
|
|
NotifyUrl: core.String("https://www.weixin.qq.com/wxpay/pay.php"),
|
|
|
Amount: &jsapi.Amount{
|
|
|
- Total: core.Int64(1),
|
|
|
+ Total: core.Int64(int64(orderDetail.OrderMoney * 100)), // 分
|
|
|
},
|
|
|
Payer: &jsapi.Payer{
|
|
|
- Openid: core.String("ouw2U62cUWNe97e96AZ5jxeAgrJM"),
|
|
|
+ Openid: core.String(openid),
|
|
|
},
|
|
|
},
|
|
|
)
|
|
|
- //fmt.Println("result", result.Response)
|
|
|
- fmt.Println("result", resp.PrepayId)
|
|
|
- //fmt.Println("result", log.(resp.Appid))
|
|
|
- //fmt.Println("result", result.Request)
|
|
|
+ fmt.Println("PrepayId", *resp)
|
|
|
if err == nil {
|
|
|
- log.Println(resp)
|
|
|
+ log.Println(*resp.Appid)
|
|
|
} else {
|
|
|
log.Println(err)
|
|
|
}
|