修改支付参数

This commit is contained in:
2024-08-14 14:12:37 +08:00
parent 37d2b55dfb
commit 8ee4dec11d
5 changed files with 35 additions and 25 deletions
+24 -16
View File
@@ -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("发起支付失败")
}