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

32 lines
810 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)
}