Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
iGoogle-ink committed Apr 25, 2020
1 parent b9bd59c commit ea74965
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions examples/alipay/alipay_ServiceApi.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,39 +61,39 @@ func VerifySyncSign() {
fmt.Println("ok:", ok)
}

func ParseNotifyResultAndVerifySign(req *http.Request) {
func ParseNotifyAndVerifySign(req *http.Request) {
aliPayPublicKey := "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1wn1sU/8Q0rYLlZ6sq3enrPZw2ptp6FecHR2bBFLjJ+sKzepROd0bKddgj+Mr1ffr3Ej78mLdWV8IzLfpXUi945DkrQcOUWLY0MHhYVG2jSs/qzFfpzmtut2Cl2TozYpE84zom9ei06u2AXLMBkU6VpznZl+R4qIgnUfByt3Ix5b3h4Cl6gzXMAB1hJrrrCkq+WvWb3Fy0vmk/DUbJEz8i8mQPff2gsHBE1nMPvHVAMw1GMk9ImB4PxucVek4ZbUzVqxZXphaAgUXFK2FSFU+Q+q1SPvHbUsjtIyL+cLA6H/6ybFF9Ffp27Y14AHPw29+243/SpMisbGcj2KD+evBwIDAQAB"

// 解析请求参数
notifyReq, err := alipay.ParseNotifyResult(req)
bm, err := alipay.ParseNotifyToBodyMap(req)
if err != nil {
fmt.Println("err:", err)
return
}
fmt.Println("notifyReq:", *notifyReq)
fmt.Println("notifyReq:", bm)

// 验签
ok, err := alipay.VerifySign(aliPayPublicKey, notifyReq)
ok, err := alipay.VerifySign(aliPayPublicKey, bm)
if err != nil {
fmt.Println("err:", err)
return
}
log.Println("支付宝验签是否通过:", ok)
}

func ParseNotifyResultAndVerifySignWithCert(req *http.Request) {
func ParseNotifyAndVerifySignWithCert(req *http.Request) {
aliPayPublicKeyPath := "/root/alipay/cert/alipayCertPublicKey_RSA2.crt"

// 解析请求参数
notifyReq, err := alipay.ParseNotifyResult(req)
bm, err := alipay.ParseNotifyToBodyMap(req)
if err != nil {
fmt.Println("err:", err)
return
}
fmt.Println("notifyReq:", *notifyReq)
fmt.Println("notifyReq:", bm)

// 验签
ok, err := alipay.VerifySignWithCert(aliPayPublicKeyPath, notifyReq)
ok, err := alipay.VerifySignWithCert(aliPayPublicKeyPath, bm)
if err != nil {
fmt.Println("err:", err)
return
Expand Down
10 changes: 5 additions & 5 deletions examples/wechat/wx_ServiceApi.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ func GetOpenIdByAuthCode() {
}

//解析notify参数、验签、返回数据到微信
func ParseWeChatNotifyResultAndVerifyWeChatSign(req *http.Request) string {
func ParseWeChatNotifyAndVerifyWeChatSign(req *http.Request) string {
rsp := new(wechat.NotifyResponse)

//解析参数
notifyReq, err := wechat.ParseNotifyResult(req)
notifyReq, err := wechat.ParseNotify(req)
if err != nil {
fmt.Println("err:", err)
}
Expand All @@ -204,7 +204,7 @@ func ParseWeChatNotifyResultAndVerifyWeChatSign(req *http.Request) string {

//或者

bodyMap, err := wechat.ParseNotifyResultToBodyMap(req)
bodyMap, err := wechat.ParseNotifyToBodyMap(req)
if err != nil {
fmt.Println("err:", err)
}
Expand All @@ -222,10 +222,10 @@ func ParseWeChatNotifyResultAndVerifyWeChatSign(req *http.Request) string {
}

// 解析微信退款异步通知的参数,解析出来的 req_info 是加密数据,需解密
func ParseWeChatRefundNotifyResult(req *http.Request) string {
func ParseWeChatRefundNotify(req *http.Request) string {
rsp := new(wechat.NotifyResponse)
// 解析参数
notifyReq, err := wechat.ParseRefundNotifyResult(req)
notifyReq, err := wechat.ParseRefundNotify(req)
if err != nil {
fmt.Println("err:", err)
}
Expand Down

0 comments on commit ea74965

Please sign in to comment.