修改支付参数
This commit is contained in:
+24
-16
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/app"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/jsapi"
|
||||
"hepa-calc-api/utils"
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -61,24 +60,29 @@ func (r JsapiRequest) GetJsapiPrepay() (prepay *jsapi.PrepayWithRequestPaymentRe
|
||||
|
||||
svc := jsapi.JsapiApiService{Client: client}
|
||||
// 得到prepay_id,以及调起支付所需的参数和签名
|
||||
resp, result, err := svc.PrepayWithRequestPayment(context.Background(),
|
||||
jsapi.PrepayRequest{
|
||||
Appid: core.String(r.AppId),
|
||||
Mchid: core.String(r.MchId),
|
||||
Description: core.String(r.Description),
|
||||
OutTradeNo: core.String(r.OutTradeNo),
|
||||
NotifyUrl: core.String(r.NotifyUrl),
|
||||
Amount: &jsapi.Amount{
|
||||
Total: core.Int64(r.Amount.Total),
|
||||
Currency: core.String("CNY"),
|
||||
},
|
||||
Payer: &jsapi.Payer{
|
||||
Openid: core.String(r.Payer.OpenId),
|
||||
},
|
||||
PrepayRequest := jsapi.PrepayRequest{
|
||||
Appid: core.String(r.AppId),
|
||||
Mchid: core.String(r.MchId),
|
||||
Description: core.String(r.Description),
|
||||
OutTradeNo: core.String(r.OutTradeNo),
|
||||
NotifyUrl: core.String(r.NotifyUrl),
|
||||
Amount: &jsapi.Amount{
|
||||
Total: core.Int64(r.Amount.Total),
|
||||
Currency: core.String("CNY"),
|
||||
},
|
||||
Payer: &jsapi.Payer{
|
||||
Openid: core.String(r.Payer.OpenId),
|
||||
},
|
||||
}
|
||||
|
||||
resp, result, err := svc.PrepayWithRequestPayment(context.Background(),
|
||||
PrepayRequest,
|
||||
)
|
||||
|
||||
utils.LogJsonInfo("发起支付", *result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Response.StatusCode != 200 {
|
||||
return nil, errors.New("发起支付失败")
|
||||
}
|
||||
@@ -118,6 +122,10 @@ func (r AppRequest) GetAppPrepay() (prepay *app.PrepayWithRequestPaymentResponse
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result.Response.StatusCode != 200 {
|
||||
return nil, errors.New("发起支付失败")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user