forked from go-pay/gopay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ant.go
140 lines (132 loc) · 5.51 KB
/
ant.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package alipay
import (
"encoding/json"
"fmt"
"github.com/cedarwu/gopay"
)
// ant.merchant.expand.shop.modify(修改蚂蚁店铺)
// 文档地址:https://opendocs.alipay.com/apis/014tmb
func (a *Client) AntMerchantShopModify(bm gopay.BodyMap) (aliRsp *AntMerchantShopModifyRsp, err error) {
var bs []byte
if bs, err = a.doAliPay(bm, "ant.merchant.expand.shop.modify"); err != nil {
return nil, err
}
aliRsp = new(AntMerchantShopModifyRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil {
return nil, err
}
if aliRsp.Response != nil && aliRsp.Response.Code != "10000" {
info := aliRsp.Response
return aliRsp, fmt.Errorf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, info.Code, info.Msg, info.SubCode, info.SubMsg)
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}
// ant.merchant.expand.shop.create(蚂蚁店铺创建)
// 文档地址:https://opendocs.alipay.com/apis/api_1/ant.merchant.expand.shop.create
func (a *Client) AntMerchantShopCreate(bm gopay.BodyMap) (aliRsp *AntMerchantShopCreateRsp, err error) {
err = bm.CheckEmptyError("business_address", "shop_category", "store_id", "shop_type", "ip_role_id", "shop_name")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "ant.merchant.expand.shop.create"); err != nil {
return nil, err
}
aliRsp = new(AntMerchantShopCreateRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil {
return nil, err
}
if aliRsp.Response != nil && aliRsp.Response.Code != "10000" {
info := aliRsp.Response
return aliRsp, fmt.Errorf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, info.Code, info.Msg, info.SubCode, info.SubMsg)
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}
// ant.merchant.expand.shop.consult(蚂蚁店铺创建咨询)
// 文档地址:https://opendocs.alipay.com/apis/014yig
func (a *Client) AntMerchantShopConsult(bm gopay.BodyMap) (aliRsp *AntMerchantShopConsultRsp, err error) {
err = bm.CheckEmptyError("business_address", "shop_category", "store_id", "shop_type", "ip_role_id", "shop_name")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "ant.merchant.expand.shop.consult"); err != nil {
return nil, err
}
aliRsp = new(AntMerchantShopConsultRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil {
return nil, err
}
if aliRsp.Response != nil && aliRsp.Response.Code != "10000" {
info := aliRsp.Response
return aliRsp, fmt.Errorf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, info.Code, info.Msg, info.SubCode, info.SubMsg)
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}
// ant.merchant.expand.order.query(商户申请单查询)
// 文档地址:https://opendocs.alipay.com/apis/api_1/ant.merchant.expand.order.query
func (a *Client) AntMerchantOrderQuery(bm gopay.BodyMap) (aliRsp *AntMerchantOrderQueryRsp, err error) {
err = bm.CheckEmptyError("order_id")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "ant.merchant.expand.order.query"); err != nil {
return nil, err
}
aliRsp = new(AntMerchantOrderQueryRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil {
return nil, err
}
if aliRsp.Response != nil && aliRsp.Response.Code != "10000" {
info := aliRsp.Response
return aliRsp, fmt.Errorf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, info.Code, info.Msg, info.SubCode, info.SubMsg)
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}
// ant.merchant.expand.shop.query(店铺查询接口)
// 文档地址:https://opendocs.alipay.com/apis/api_1/ant.merchant.expand.shop.query
func (a *Client) AntMerchantShopQuery(bm gopay.BodyMap) (aliRsp *AntMerchantShopQueryRsp, err error) {
var bs []byte
if bs, err = a.doAliPay(bm, "ant.merchant.expand.shop.query"); err != nil {
return nil, err
}
aliRsp = new(AntMerchantShopQueryRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil {
return nil, err
}
if aliRsp.Response != nil && aliRsp.Response.Code != "10000" {
info := aliRsp.Response
return aliRsp, fmt.Errorf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, info.Code, info.Msg, info.SubCode, info.SubMsg)
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}
// ant.merchant.expand.shop.close(蚂蚁店铺关闭)
// 文档地址:https://opendocs.alipay.com/apis/api_1/ant.merchant.expand.shop.close
func (a *Client) AntMerchantShopClose(bm gopay.BodyMap) (aliRsp *AntMerchantShopCloseRsp, err error) {
var bs []byte
if bs, err = a.doAliPay(bm, "ant.merchant.expand.shop.close"); err != nil {
return nil, err
}
aliRsp = new(AntMerchantShopCloseRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil {
return nil, err
}
if aliRsp.Response != nil && aliRsp.Response.Code != "10000" {
info := aliRsp.Response
return aliRsp, fmt.Errorf(`{"code":"%s","msg":"%s","sub_code":"%s","sub_msg":"%s"}`, info.Code, info.Msg, info.SubCode, info.SubMsg)
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}