1
This commit is contained in:
parent
c21b47fc73
commit
5dd3c44917
@ -10,8 +10,8 @@ import (
|
||||
// CallBack 回调
|
||||
type CallBack struct{}
|
||||
|
||||
// WxJsapiPay 微信支付回调-jsapi
|
||||
func (r *CallBack) WxJsapiPay(c *gin.Context) {
|
||||
// WxPaySingle 微信支付回调-单项
|
||||
func (r *CallBack) WxPaySingle(c *gin.Context) {
|
||||
notifyReq, err := weChat.ParseNotify(c)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
@ -19,5 +19,8 @@ func (r *CallBack) WxJsapiPay(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 记录日志
|
||||
utils.LogJsonErr("微信支付回调-jsapi", notifyReq)
|
||||
utils.LogJsonErr("微信支付回调-单项", notifyReq)
|
||||
|
||||
// 查询订单
|
||||
|
||||
}
|
||||
|
||||
@ -98,7 +98,8 @@ func publicRouter(r *gin.Engine, api controller.Api) {
|
||||
// 微信支付回调
|
||||
wxpayGroup := callbackGroup.Group("/wxpay")
|
||||
{
|
||||
wxpayGroup.POST("/jsapi", api.CallBack.WxJsapiPay)
|
||||
// 单项
|
||||
wxpayGroup.POST("/single", api.CallBack.WxPaySingle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ dysms:
|
||||
wechat:
|
||||
app-id: wxc8ac5051745bc795
|
||||
app-secret: 678b63a8a7541e528abc3040c3cea809
|
||||
pay-notify-url: callback/wxpay/inquiry/success
|
||||
pay-notify-url: callback/wxpay/single
|
||||
refund-notify-url: callback/wxpay/inquiry/refund
|
||||
refund-notify-domain: https://dev.hospital.applets.igandanyiyuan.com/
|
||||
pay-1659662936:
|
||||
|
||||
@ -9,15 +9,13 @@ import (
|
||||
"hepa-calc-api/config"
|
||||
)
|
||||
|
||||
var (
|
||||
mchId = config.C.Wechat.Pay1659662936.MchId // 商户号
|
||||
mchCertificateSerialNumber = config.C.Wechat.Pay1659662936.MchCertificateSerialNumber // 商户证书序列号
|
||||
v3ApiSecret = config.C.Wechat.Pay1659662936.V3ApiSecret // 商户APIv3密钥
|
||||
privateKeyPath = "extend/weChat/certs/" + mchId + "/apiclient_key.pem" // 商户私钥文件地址
|
||||
)
|
||||
|
||||
// 创建客户端
|
||||
func createClient() (*core.Client, error) {
|
||||
mchId := config.C.Wechat.Pay1659662936.MchId // 商户号
|
||||
mchCertificateSerialNumber := config.C.Wechat.Pay1659662936.MchCertificateSerialNumber // 商户证书序列号
|
||||
v3ApiSecret := config.C.Wechat.Pay1659662936.V3ApiSecret // 商户APIv3密钥
|
||||
privateKeyPath := "extend/weChat/certs/" + config.C.Wechat.Pay1659662936.MchId + "/apiclient_key.pem" // 商户私钥文件地址
|
||||
|
||||
if mchId == "" {
|
||||
return nil, errors.New("商户号错误")
|
||||
}
|
||||
|
||||
@ -10,10 +10,16 @@ import (
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core/notify"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/utils"
|
||||
"hepa-calc-api/config"
|
||||
)
|
||||
|
||||
// ParseNotify 回调通知的验签与解密
|
||||
func ParseNotify(c *gin.Context) (notifyReq *notify.Request, err error) {
|
||||
mchId := config.C.Wechat.Pay1659662936.MchId // 商户号
|
||||
mchCertificateSerialNumber := config.C.Wechat.Pay1659662936.MchCertificateSerialNumber // 商户证书序列号
|
||||
v3ApiSecret := config.C.Wechat.Pay1659662936.V3ApiSecret // 商户APIv3密钥
|
||||
privateKeyPath := "extend/weChat/certs/" + config.C.Wechat.Pay1659662936.MchId + "/apiclient_key.pem" // 商户私钥文件地址
|
||||
|
||||
// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||
mchPrivateKey, err := utils.LoadPrivateKeyWithPath(privateKeyPath)
|
||||
if err != nil {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user