-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathedu_payment.go
58 lines (53 loc) · 1.64 KB
/
edu_payment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package wework
import (
"github.com/go-laoji/wecom-go-sdk/v2/internal"
)
type GetPaymentResultResponse struct {
internal.BizResponse
ProjectName string `json:"project_name"`
Amount int `json:"amount"`
PaymentResult []struct {
StudentUserid string `json:"student_userid"`
TradeState int `json:"trade_state"`
TradeNo string `json:"trade_no"`
PayerParentUserid string `json:"payer_parent_userid"`
} `json:"payment_result"`
}
// GetPaymentResult 获取学生付款结果
// https://open.work.weixin.qq.com/api/doc/90001/90143/94553
func (ww *weWork) GetPaymentResult(corpId uint, paymentId string) (resp GetPaymentResultResponse) {
h := H{}
h["payment_id"] = paymentId
_, err := ww.getRequest(corpId).SetBody(h).SetResult(&resp).
Post("/cgi-bin/school/get_payment_result")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}
type GetTradeRequest struct {
PaymentId string `json:"payment_id" validate:"required"`
TradeNo string `json:"trade_no" validate:"required"`
}
type GetTradeResponse struct {
internal.BizResponse
TransactionId string `json:"transaction_id"`
PayTime int `json:"pay_time"`
}
// GetTrade 获取订单详情
// https://open.work.weixin.qq.com/api/doc/90001/90143/94554
func (ww *weWork) GetTrade(corpId uint, request GetTradeRequest) (resp GetTradeResponse) {
if ok := validate.Struct(request); ok != nil {
resp.ErrCode = 500
resp.ErrorMsg = ok.Error()
return
}
_, err := ww.getRequest(corpId).SetBody(request).SetResult(&resp).
Post("/cgi-bin/school/get_trade")
if err != nil {
resp.ErrCode = 500
resp.ErrorMsg = err.Error()
}
return
}