Skip to content

Commit

Permalink
add more detailed log
Browse files Browse the repository at this point in the history
  • Loading branch information
sunjiayu committed Jul 5, 2024
1 parent 7a4d989 commit 46b9962
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions service/wx_payment/wx_payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package wx_payment

import (
"context"
"encoding/json"
"fmt"
"os"

Expand Down Expand Up @@ -63,12 +64,15 @@ func (server WxPaymentServiceImpl) Jsapi(ctx context.Context, req *wx_payment.Js
grpclog.Errorf("request params invalid, received openid:%v amount:%v", openid, amount)
return nil, fmt.Errorf("openid: %s amount:%d", openid, amount)
}
reqJson, _ := json.Marshal(req)
grpclog.Infof("received request: %v", string(reqJson))
svc := jsapi.JsapiApiService{Client: server.WxClient}
outTradeNo, err := GenRandomStr()
if err != nil {
grpclog.Error("generate out_trade_no failed error:", err)
return nil, err
}
grpclog.Infof("received request: %v", string(reqJson))
prepayResp, _, err := svc.PrepayWithRequestPayment(ctx,
jsapi.PrepayRequest{
Appid: &server.WxAppID,
Expand All @@ -88,6 +92,8 @@ func (server WxPaymentServiceImpl) Jsapi(ctx context.Context, req *wx_payment.Js
if err != nil {
grpclog.Error("call PrepayWithRequestPayment failed error:", err)
return nil, err
} else {
grpclog.Info("call PrepayWithRequestPayment success")
}
resp := wx_payment.JsApiResponse{
Timestamp: *prepayResp.TimeStamp,
Expand All @@ -96,5 +102,7 @@ func (server WxPaymentServiceImpl) Jsapi(ctx context.Context, req *wx_payment.Js
SignType: *prepayResp.SignType,
PaySign: *prepayResp.PaySign,
}
respJson, _ := json.Marshal(&resp)
grpclog.Infof("return response: %v", string(respJson))
return &resp, nil
}

0 comments on commit 46b9962

Please sign in to comment.