-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmerchant.go
75 lines (67 loc) · 1.93 KB
/
merchant.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
73
74
75
package chinaums
type UmsConfig struct {
AppId string `json:"app_id"`
SubAppId string `json:"sub_app_id"` //微信子商户 appId
AppKey string `json:"app_key"`
AppSecret string `json:"app_secret"`
ApiUrl string `json:"api_url"`
Mid string `json:"mid"` //商户号
Tid string `json:"tid"` //终端号
NotifyUrl string `json:"notify_url"`
RefundUrl string `json:"refund_url"`
ShowUrl string `json:"show_url"` //订单展示页面
WriteLog bool `json:"write_log"` //是否写入日志
}
type OrderInfo struct {
TotalAmount int64 `json:"total_amount"`
MerOrderId string `json:"mer_order_id"`
OrderDesc string `json:"order_desc"`
SubOpenId string `json:"sub_open_id"`
//跳转地址,订单有传值,则会覆盖配置信息
NotifyUrl string `json:"notify_url"`
RefundUrl string `json:"refund_url"`
ShowUrl string `json:"show_url"` //订单展示页面
}
type OrderOption func(order *OrderInfo) (o *OrderInfo)
func SetTotalAmount(amount int64) OrderOption {
return func(order *OrderInfo) (o *OrderInfo) {
order.TotalAmount = amount
return order
}
}
func SetMerOrderId(orderSn string) OrderOption {
return func(order *OrderInfo) (o *OrderInfo) {
order.MerOrderId = orderSn
return order
}
}
func SetOrderDesc(desc string) OrderOption {
return func(order *OrderInfo) (o *OrderInfo) {
order.OrderDesc = desc
return order
}
}
func SetSubOpenId(openId string) OrderOption {
return func(order *OrderInfo) (o *OrderInfo) {
order.SubOpenId = openId
return order
}
}
func SetNotifyUrl(notifyUrl string) OrderOption {
return func(order *OrderInfo) (o *OrderInfo) {
order.NotifyUrl = notifyUrl
return order
}
}
func SetShowUrl(showUrl string) OrderOption {
return func(order *OrderInfo) (o *OrderInfo) {
order.ShowUrl = showUrl
return order
}
}
func SetRefundUrl(refundUrl string) OrderOption {
return func(order *OrderInfo) (o *OrderInfo) {
order.RefundUrl = refundUrl
return order
}
}