service/vendor/github.com/go-pay/gopay/wechat/v3/papay.go

32 lines
810 B
Go
Raw Normal View History

2023-12-21 22:17:40 +08:00
package wechat
import (
"context"
"fmt"
"net/http"
"github.com/go-pay/gopay"
)
// 预扣费通知API
// Code = 0 is success
// 电商文档https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_10.shtml
func (c *ClientV3) V3EntrustPayNotify(ctx context.Context, contractId string, bm gopay.BodyMap) (wxRsp *EmptyRsp, err error) {
url := fmt.Sprintf(v3EntrustPayNotify, contractId)
authorization, err := c.authorization(MethodPost, url, bm)
if err != nil {
return nil, err
}
res, si, bs, err := c.doProdPost(ctx, bm, url, authorization)
if err != nil {
return nil, err
}
wxRsp = &EmptyRsp{Code: Success, SignInfo: si}
if res.StatusCode != http.StatusNoContent {
wxRsp.Code = res.StatusCode
wxRsp.Error = string(bs)
return wxRsp, nil
}
return wxRsp, c.verifySyncSign(si)
}