forked from go-pay/gopay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
325 lines (286 loc) · 13.2 KB
/
model.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
package alipay
const (
// URL
baseUrl = "https://openapi.alipay.com/gateway.do"
//sandboxBaseUrl = "https://openapi.alipaydev.com/gateway.do"
sandboxBaseUrl = "https://openapi-sandbox.dl.alipaydev.com/gateway.do"
baseUrlUtf8 = "https://openapi.alipay.com/gateway.do?charset=utf-8"
//sandboxBaseUrlUtf8 = "https://openapi.alipaydev.com/gateway.do?charset=utf-8"
sandboxBaseUrlUtf8 = "https://openapi-sandbox.dl.alipaydev.com/gateway.do?charset=utf-8"
LocationShanghai = "Asia/Shanghai"
PKCS1 PKCSType = 1 // 非Java
PKCS8 PKCSType = 2 // Java
RSA = "RSA"
RSA2 = "RSA2"
UTF8 = "utf-8"
)
var (
//不需要处理AppAuthToken的方法
appAuthTokenInBizContent = map[string]bool{
"alipay.open.auth.token.app.query": true,
}
)
type PKCSType uint8
// Deprecated
type NotifyRequest struct {
NotifyTime string `json:"notify_time,omitempty"`
NotifyType string `json:"notify_type,omitempty"`
NotifyId string `json:"notify_id,omitempty"`
AppId string `json:"app_id,omitempty"`
Charset string `json:"charset,omitempty"`
Version string `json:"version,omitempty"`
SignType string `json:"sign_type,omitempty"`
Sign string `json:"sign,omitempty"`
AuthAppId string `json:"auth_app_id,omitempty"`
TradeNo string `json:"trade_no,omitempty"`
OutTradeNo string `json:"out_trade_no,omitempty"`
OutBizNo string `json:"out_biz_no,omitempty"`
BuyerId string `json:"buyer_id,omitempty"`
BuyerLogonId string `json:"buyer_logon_id,omitempty"`
SellerId string `json:"seller_id,omitempty"`
SellerEmail string `json:"seller_email,omitempty"`
TradeStatus string `json:"trade_status,omitempty"`
TotalAmount string `json:"total_amount,omitempty"`
ReceiptAmount string `json:"receipt_amount,omitempty"`
InvoiceAmount string `json:"invoice_amount,omitempty"`
BuyerPayAmount string `json:"buyer_pay_amount,omitempty"`
PointAmount string `json:"point_amount,omitempty"`
RefundFee string `json:"refund_fee,omitempty"`
Subject string `json:"subject,omitempty"`
Body string `json:"body,omitempty"`
GmtCreate string `json:"gmt_create,omitempty"`
GmtPayment string `json:"gmt_payment,omitempty"`
GmtRefund string `json:"gmt_refund,omitempty"`
GmtClose string `json:"gmt_close,omitempty"`
FundBillList []*FundBillListInfo `json:"fund_bill_list,omitempty"`
PassbackParams string `json:"passback_params,omitempty"`
VoucherDetailList []*VoucherDetail `json:"voucher_detail_list,omitempty"`
Method string `json:"method,omitempty"` // 电脑网站支付 支付宝请求 return_url 同步返回参数
Timestamp string `json:"timestamp,omitempty"` // 电脑网站支付 支付宝请求 return_url 同步返回参数
}
// Deprecated
type FundBillListInfo struct {
Amount string `json:"amount,omitempty"`
FundChannel string `json:"fundChannel,omitempty"` // 异步通知里是 fundChannel
}
type UserPhone struct {
ErrorResponse
Mobile string `json:"mobile,omitempty"`
}
type ErrorResponse struct {
Code string `json:"code"`
Msg string `json:"msg"`
SubCode string `json:"sub_code,omitempty"`
SubMsg string `json:"sub_msg,omitempty"`
}
// ===================================================
type FundAuthOrderAppFreezeResponse struct {
Response *FundAuthOrderAppFreeze `json:"alipay_fund_auth_order_app_freeze_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}
type FundAuthOrderAppFreeze struct {
ErrorResponse
AuthNo string `json:"auth_no,omitempty"`
OutOrderNo string `json:"out_order_no,omitempty"`
OperationId string `json:"operation_id,omitempty"`
OutRequestNo string `json:"out_request_no,omitempty"`
Amount string `json:"amount,omitempty"`
Status string `json:"status,omitempty"`
PayerUserId string `json:"payer_user_id,omitempty"`
GmtTrans string `json:"gmt_trans,omitempty"`
PreAuthType string `json:"pre_auth_type,omitempty"`
CreditAmount string `json:"credit_amount,omitempty"`
FundAmount string `json:"fund_amount,omitempty"`
TransCurrency string `json:"trans_currency,omitempty"`
}
// ===================================================
type OpenAuthTokenAppResponse struct {
Response *AuthTokenApp `json:"alipay_open_auth_token_app_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}
type AuthTokenApp struct {
ErrorResponse
UserId string `json:"user_id,omitempty"`
AuthAppId string `json:"auth_app_id,omitempty"`
AppAuthToken string `json:"app_auth_token,omitempty"`
ExpiresIn int `json:"expires_in,omitempty"`
AppRefreshToken string `json:"app_refresh_token,omitempty"`
ReExpiresIn int `json:"re_expires_in,omitempty"`
Tokens []*Token `json:"tokens,omitempty"`
}
type Token struct {
AuthAppId string `json:"auth_app_id,omitempty"`
AppAuthToken string `json:"app_auth_token,omitempty"`
ExpiresIn int `json:"expires_in,omitempty"`
AppRefreshToken string `json:"app_refresh_token,omitempty"`
ReExpiresIn int `json:"re_expires_in,omitempty"`
UserId string `json:"user_id,omitempty"`
}
// ===================================================
type OpenAuthTokenAppInviteCreateResponse struct {
Response *OpenAuthTokenAppInviteCreate `json:"alipay_open_auth_appauth_invite_create_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}
type OpenAuthTokenAppInviteCreate struct {
ErrorResponse
TaskPageUrl string `json:"task_page_url,omitempty"`
}
// ===================================================
type OpenAuthTokenAppQueryResponse struct {
Response *AuthTokenAppQuery `json:"alipay_open_auth_token_app_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}
type AuthTokenAppQuery struct {
ErrorResponse
UserId string `json:"user_id"` //授权商户的user_id
AuthAppId string `json:"auth_app_id"` //授权商户的appid
ExpiresIn int `json:"expires_in"` //应用授权令牌失效时间,单位到秒
AuthMethods []string `json:"auth_methods"` //当前app_auth_token的授权接口列表
AuthStart string `json:"auth_start"` //授权生效时间
AuthEnd string `json:"auth_end"` //授权失效时间
Status string `json:"status"` //valid:有效状态;invalid:无效状态
}
// ===================================================
type UserInfoAuthResponse struct {
Response *ErrorResponse `json:"alipay_user_info_auth_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}
// ===================================================
type MonitorHeartbeatSynResponse struct {
Response *MonitorHeartbeatSynRes `json:"monitor_heartbeat_syn_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}
type MonitorHeartbeatSynRes struct {
ErrorResponse
Pid string `json:"pid"`
}
// ===================================================
type DataBillBalanceQueryResponse struct {
Response *DataBillBalanceQuery `json:"alipay_data_bill_balance_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}
type DataBillBalanceQuery struct {
ErrorResponse
TotalAmount string `json:"total_amount,omitempty"`
AvailableAmount string `json:"available_amount,omitempty"`
FreezeAmount string `json:"freeze_amount,omitempty"`
}
// ===================================================
type DataBillDownloadUrlQueryResponse struct {
Response *DataBillDownloadUrlQuery `json:"alipay_data_dataservice_bill_downloadurl_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}
type DataBillDownloadUrlQuery struct {
ErrorResponse
BillDownloadUrl string `json:"bill_download_url,omitempty"`
}
// ===================================================
type PublicCertDownloadRsp struct {
Response *PublicCertDownload `json:"alipay_open_app_alipaycert_download_response"`
}
type PublicCertDownload struct {
ErrorResponse
AlipayCertContent string `json:"alipay_cert_content"`
}
// ===================================================
type UserAgreementPageSignRsp struct {
Response *UserAgreementPageSign `json:"alipay_user_agreement_page_sign_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}
type UserAgreementPageSign struct {
ErrorResponse
ExternalAgreementNo string `json:"external_agreement_no,omitempty"`
PersonalProductCode string `json:"personal_product_code"`
ValidTime string `json:"valid_time"`
SignScene string `json:"sign_scene"`
AgreementNo string `json:"agreement_no"`
ZmOpenId string `json:"zm_open_id,omitempty"`
InvalidTime string `json:"invalid_time"`
SignTime string `json:"sign_time"`
AlipayUserId string `json:"alipay_user_id"`
Status string `json:"status"`
ForexEligible string `json:"forex_eligible,omitempty"`
ExternalLogonId string `json:"external_logon_id,omitempty"`
AlipayLogonId string `json:"alipay_logon_id"`
CreditAuthMode string `json:"credit_auth_mode,omitempty"`
}
// ===================================================
type OpenAppQrcodeCreateRsp struct {
Response *OpenAppQrcodeCreate `json:"alipay_open_app_qrcode_create_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}
type OpenAppQrcodeCreate struct {
ErrorResponse
QrCodeUrl string `json:"qr_code_url"`
}
// ===================================================
type MerchantItemFileUploadRsp struct {
Response *MerchantItemFileUpload `json:"alipay_merchant_item_file_upload_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}
type MerchantItemFileUpload struct {
ErrorResponse
MaterialId string `json:"material_id"` // 文件在商品中心的素材标识(素材ID长期有效)
MaterialKey string `json:"material_key"` // 文件在商品中心的素材标示,创建/更新商品时使用
}
// ===================================================
type DataDataserviceAdDataQueryRsp struct {
Response *DataDataserviceAdDataQuery `json:"alipay_data_dataservice_ad_data_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}
type DataDataserviceAdDataQuery struct {
ErrorResponse
DataList []*DataDetail `json:"data_list,omitempty"`
}
type DataDetail struct {
OuterId string `json:"outer_id,omitempty"`
Impression int64 `json:"impression,omitempty"`
Click int64 `json:"click,omitempty"`
Cost int64 `json:"cost,omitempty"`
ConversionDataList []*ConversionDataDetail `json:"conversion_data_list,omitempty"`
BizDate string `json:"biz_date,omitempty"`
}
type ConversionDataDetail struct {
ConversionId string `json:"conversion_id,omitempty"`
ConversionResult string `json:"conversion_result,omitempty"`
}
// ===================================================
type OpenAppApiQueryResponse struct {
Response *OpenAppApiQuery `json:"alipay_open_app_api_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}
type OpenAppApiQuery struct {
ErrorResponse
Apis []*Apis `json:"apis"`
}
type Apis struct {
ApiName string `json:"api_name,omitempty"`
FieldName string `json:"field_name,omitempty"`
PackageCode string `json:"package_code,omitempty"`
}