-
Notifications
You must be signed in to change notification settings - Fork 1
/
alipay.go
53 lines (42 loc) · 1.4 KB
/
alipay.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
package alipay
import (
"net/http"
"net/url"
)
// 支付表单
func BuildHttpForm(config Config, params map[string]string, method, buttonName string) (form string, err error) {
if params["out_trade_no"] == "" {
err = errors.New("订单号不能为空")
return
} else if params["subject"] == "" {
err = errors.New("商品名称不能为空")
return
} else if params["total_fee"] == "" {
err = errors.New("交易金额不能为空")
return
} else if params["payment_type"] == "" {
err = errors.New("支付类型不能为空")
return
}
params["service"] = config.Service
params["partner"] = config.Partner
params["_input_charset"] = config.InputCharset
params["notify_url"] = config.NotifyUrl
params["return_url"] = config.ReturnUrl
params["sign_type"] = config.SignType
params["sign"] = makeSign(params, config.Key)
form := "<form id='alipaysubmit' name='alipaysubmit' action='""' method='"+method+"'>"
for key, val := range params {
form += fmt.Sprintf("<input type='hidden' name='"%s"' value='"%s"'/>", key, val)
}
//submit按钮控件请不要含有name属性
form += "<input type='submit' value='".$button_name."'></form>";
form += "<script>document.forms['alipaysubmit'].submit();</script>";
return form;
}
func Notify(request *http.Request) (resp NotifyResponse, err error) {
return
}
func Return(request *http.Request) (resp NotifyResponse, err error) {
return
}