forked from smartwalle/alipay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrade.go
72 lines (60 loc) · 2.49 KB
/
trade.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package alipay
import (
"strings"
"net/url"
"net/http"
)
// TradePagePay https://doc.open.alipay.com/doc2/detail.htm?treeId=270&articleId=105901&docType=1
func (this *AliPay) TradePagePay(param AliPayTradePagePay) (url *url.URL, err error) {
var buf = strings.NewReader(this.URLValues(param).Encode())
req, err := http.NewRequest("POST", this.apiDomain, buf)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")
rep, err := this.client.Do(req)
if err != nil {
return nil, err
}
defer rep.Body.Close()
if err != nil {
return nil, err
}
url = rep.Request.URL
return url, err
}
// TradeQuery https://doc.open.alipay.com/doc2/apiDetail.htm?apiId=757&docType=4
func (this *AliPay) TradeQuery(param AliPayTradeQuery) (results *AliPayTradeQueryResponse, err error) {
err = this.doRequest("POST", param, &results)
return results, err
}
// TradeClose https://doc.open.alipay.com/doc2/apiDetail.htm?apiId=1058&docType=4
func (this *AliPay) TradeClose(param AliPayTradeClose) (results *AliPayTradeCloseResponse, err error) {
err = this.doRequest("POST", param, &results)
return results, err
}
// TradeRefund https://doc.open.alipay.com/doc2/apiDetail.htm?apiId=759&docType=4
func (this *AliPay) TradeRefund(param AliPayTradeRefund) (results *AliPayTradeRefundResponse, err error) {
err = this.doRequest("POST", param, &results)
return results, err
}
// TradeFastpayRefundQuery https://doc.open.alipay.com/doc2/apiDetail.htm?docType=4&apiId=1049
func (this *AliPay) TradeFastpayRefundQuery(param AliPayFastpayTradeRefundQuery) (results *AliPayFastpayTradeRefundQueryResponse, err error) {
err = this.doRequest("POST", param, &results)
return results, err
}
// TradePay https://doc.open.alipay.com/docs/api.htm?spm=a219a.7395905.0.0.6jrv8J&docType=4&apiId=850
func (this *AliPay) TradePay(param AliPayTradePay) (results *AliPayTradePayResponse, err error) {
err = this.doRequest("POST", param, &results)
return results, err
}
// TradeCreate https://doc.open.alipay.com/docs/api.htm?spm=a219a.7395905.0.0.x39G6l&docType=4&apiId=1046
func (this *AliPay) TradeCreate(param AliPayTradeCreate) (results *AliPayTradeCreateResponse, err error) {
err = this.doRequest("POST", param, &results)
return results, err
}
// TradeAppPay https://doc.open.alipay.com/doc2/detail.htm?treeId=204&articleId=105462&docType=1
func (this *AliPay) TradeAppPay(param AliPayTradeAppPay) (results string, err error) {
results = this.URLValues(param).Encode()
return results, nil
}