-
Notifications
You must be signed in to change notification settings - Fork 281
/
order_test.go
93 lines (80 loc) · 2.19 KB
/
order_test.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package weapp
import (
"github.com/medivhzhan/weapp/v3/order"
"testing"
"time"
)
var appid = "wx0417444aae7355f7"
var accessToken = "74_7-AVnmRJZz5MpDoeaygGfuSZL5TbSjJQmJJ0lXSJhuH0z0IHCGNe3-Uw_VE42xCiJAVgj29fidOITvQvXwu1luKhIm0fbXZvqTWzBGVo98vYJff-DjSDtocqrFy8dYUoCV8sJCTzPtiKJV20CZFeADDGDJ"
func getClient() *Client {
tokenGetter := func(appid, secret string) (token string, expireIn uint) {
return accessToken, 10
}
sdk := NewClient(
appid,
"",
WithAccessTokenSetter(tokenGetter),
)
return sdk
}
func TestClient_NewOrderIsTradeManaged(t *testing.T) {
orderServe := getClient().NewOrder()
isTradeManaged, err := orderServe.IsTradeManaged(&order.IsTradeManagedRequest{
Appid: "wx0417444aae7355f7",
})
if err != nil {
t.Errorf("isTradeManaged err: %+v", err)
return
}
t.Logf("isTradeManaged: %#v", isTradeManaged)
}
func TestClient_NewOrderUploadShippingInfo(t *testing.T) {
orderServe := getClient().NewOrder()
isTradeManaged, err := orderServe.UploadShippingInfo(&order.UploadShippingInfoRequest{
OrderKey: order.OrderKey{
OrderNumberType: 2,
TransactionId: "4200002027202310272131934449",
Mchid: "",
OutTradeNo: "",
},
DeliveryMode: "UNIFIED_DELIVERY",
LogisticsType: 4,
IsAllDelivered: false,
ShippingList: []order.ShippingList{
{
ItemDesc: "这是一个商品",
},
},
UploadTime: time.Now().Format(time.RFC3339),
Payer: order.Payer{
Openid: "omlPt4v2t9G40JnX4uXjlA9vsfK0",
},
})
if err != nil {
t.Errorf("UploadShippingInfo err: %+v", err)
return
}
t.Logf("UploadShippingInfo: %#v", isTradeManaged)
}
func TestClient_NewOrderGetOrder(t *testing.T) {
orderServe := getClient().NewOrder()
resp, err := orderServe.GetOrder(&order.GetOrderRequest{
TransactionId: "4200002027202310272131934449",
})
if err != nil {
t.Errorf("GetOrder err: %+v", err)
return
}
t.Logf("GetOrder: %#v", resp.Order)
}
func TestClient_NewOrderGetOrderList(t *testing.T) {
orderServe := getClient().NewOrder()
resp, err := orderServe.GetOrderList(&order.GetOrderListRequest{})
if err != nil {
t.Errorf("GetOrder err: %+v", err)
return
}
for _, orderStruct := range resp.OrderList {
t.Logf("GetOrder: %#v", orderStruct)
}
}