api pay3
This commit is contained in:
parent
03eb4812c0
commit
de4e2e27c2
2
go.mod
2
go.mod
|
@ -69,7 +69,7 @@ require (
|
|||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca // indirect
|
||||
github.com/xuri/nfp v0.0.0-20230819163627-dc951e3ffe1a // indirect
|
||||
gitlab.batiao8.com/open/gosdk v0.0.0-20240122144735-aed2f871f032 // indirect
|
||||
gitlab.batiao8.com/open/gosdk v0.0.0-20240124083400-940a627adef3 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/multierr v1.8.0 // indirect
|
||||
go.uber.org/zap v1.21.0 // indirect
|
||||
|
|
|
@ -43,12 +43,22 @@ func (q *QyWeixin) Pay(ctx *gin.Context) {
|
|||
if pass != "1c9dea1fb85cf06ab0b4d946d49aa92f" {
|
||||
panic("password error")
|
||||
}
|
||||
// 获取openid
|
||||
approve := qyweixin.NewAppApprove(&qyweixin.AppConfig{
|
||||
Corpid: config.GetConfig().QyWeixin.Corpid,
|
||||
Secret: config.GetConfig().QyWeixin.ApproveSecret,
|
||||
Agent: config.GetConfig().QyWeixin.ApproveAgent,
|
||||
})
|
||||
openid, err := approve.GetOpenid(userid)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// 支付费用
|
||||
var req qyweixin.PayReq
|
||||
req.BillNo = fmt.Sprintf("API%s_%s", time.Now().Format("20060102150405"), userid)
|
||||
req.Title = title
|
||||
req.Userid = userid
|
||||
req.Openid = openid
|
||||
req.TotalAmount = amount
|
||||
qyPay := qyweixin.NewAppPay(&qyweixin.PayConfig{
|
||||
Corpid: config.GetConfig().QyWeixin.Corpid,
|
||||
|
@ -60,6 +70,7 @@ func (q *QyWeixin) Pay(ctx *gin.Context) {
|
|||
CertPem: config.GetConfig().WxPay.PayCertPem,
|
||||
KeyPem: config.GetConfig().WxPay.PayKeyPem,
|
||||
})
|
||||
|
||||
if err := qyPay.PayMoney(&req); err != nil {
|
||||
log.Errorf("pay error :%s", err.Error())
|
||||
panic(err)
|
||||
|
|
|
@ -148,10 +148,17 @@ func (a *Approve) handleRefund(detail *qyweixin.ApproveDetail) {
|
|||
}
|
||||
|
||||
// 支付费用
|
||||
|
||||
openid, err := a.approveClient.GetOpenid(newData.Username)
|
||||
if err != nil {
|
||||
log.Errorf("GetOpenid error :%s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
var req qyweixin.PayReq
|
||||
req.BillNo = fmt.Sprintf("BX%s%s", newData.SpNo, butil.CutTail(newData.Username, 12))
|
||||
req.Title = fmt.Sprintf("【%s】报销", newData.RefundType)
|
||||
req.Userid = newData.Username
|
||||
req.Openid = openid
|
||||
req.TotalAmount = int64(100 * newData.RefundAmount)
|
||||
qyPay := qyweixin.NewAppPay(&qyweixin.PayConfig{
|
||||
Corpid: config.GetConfig().QyWeixin.Corpid,
|
||||
|
|
Loading…
Reference in New Issue