forked from go-pay/gopay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
payment_api.go
539 lines (514 loc) · 21.8 KB
/
payment_api.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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
package alipay
import (
"encoding/json"
"errors"
"fmt"
"github.com/cedarwu/gopay"
"github.com/cedarwu/gopay/pkg/util"
)
// alipay.trade.pay(统一收单交易支付接口)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.pay
func (a *Client) TradePay(bm gopay.BodyMap) (aliRsp *TradePayResponse, err error) {
err = bm.CheckEmptyError("out_trade_no", "subject")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.pay"); err != nil {
return nil, err
}
aliRsp = new(TradePayResponse)
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)
}
// alipay.trade.precreate(统一收单线下交易预创建)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.precreate
func (a *Client) TradePrecreate(bm gopay.BodyMap) (aliRsp *TradePrecreateResponse, err error) {
err = bm.CheckEmptyError("out_trade_no", "total_amount", "subject")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.precreate"); err != nil {
return nil, err
}
aliRsp = new(TradePrecreateResponse)
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)
}
if aliRsp.NullResponse != nil {
info := aliRsp.NullResponse
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)
}
// alipay.trade.app.pay(app支付接口2.0)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.app.pay
func (a *Client) TradeAppPay(bm gopay.BodyMap) (payParam string, err error) {
err = bm.CheckEmptyError("out_trade_no", "total_amount", "subject")
if err != nil {
return util.NULL, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.app.pay"); err != nil {
return util.NULL, err
}
payParam = string(bs)
return payParam, nil
}
// alipay.trade.wap.pay(手机网站支付接口2.0)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.wap.pay
func (a *Client) TradeWapPay(bm gopay.BodyMap) (payUrl string, err error) {
bm.Set("product_code", "QUICK_WAP_WAY")
err = bm.CheckEmptyError("out_trade_no", "total_amount", "subject")
if err != nil {
return util.NULL, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.wap.pay"); err != nil {
return util.NULL, err
}
payUrl = string(bs)
return payUrl, nil
}
// alipay.trade.page.pay(统一收单下单并支付页面接口)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.page.pay
func (a *Client) TradePagePay(bm gopay.BodyMap) (payUrl string, err error) {
bm.Set("product_code", "FAST_INSTANT_TRADE_PAY")
err = bm.CheckEmptyError("out_trade_no", "total_amount", "subject")
if err != nil {
return util.NULL, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.page.pay"); err != nil {
return util.NULL, err
}
payUrl = string(bs)
return payUrl, nil
}
// alipay.trade.create(统一收单交易创建接口)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.create
func (a *Client) TradeCreate(bm gopay.BodyMap) (aliRsp *TradeCreateResponse, err error) {
err = bm.CheckEmptyError("out_trade_no", "total_amount", "subject")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.create"); err != nil {
return nil, err
}
aliRsp = new(TradeCreateResponse)
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)
}
// alipay.trade.query(统一收单线下交易查询)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.query
func (a *Client) TradeQuery(bm gopay.BodyMap) (aliRsp *TradeQueryResponse, err error) {
if bm.GetString("out_trade_no") == util.NULL && bm.GetString("trade_no") == util.NULL {
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time")
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.query"); err != nil {
return nil, err
}
aliRsp = new(TradeQueryResponse)
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)
}
// alipay.trade.cancel(统一收单交易撤销接口)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.cancel
func (a *Client) TradeCancel(bm gopay.BodyMap) (aliRsp *TradeCancelResponse, err error) {
if bm.GetString("out_trade_no") == util.NULL && bm.GetString("trade_no") == util.NULL {
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time")
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.cancel"); err != nil {
return nil, err
}
aliRsp = new(TradeCancelResponse)
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)
}
// alipay.trade.close(统一收单交易关闭接口)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.close
func (a *Client) TradeClose(bm gopay.BodyMap) (aliRsp *TradeCloseResponse, err error) {
if bm.GetString("out_trade_no") == util.NULL && bm.GetString("trade_no") == util.NULL {
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time")
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.close"); err != nil {
return nil, err
}
aliRsp = new(TradeCloseResponse)
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)
}
// alipay.trade.refund(统一收单交易退款接口)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.refund
func (a *Client) TradeRefund(bm gopay.BodyMap) (aliRsp *TradeRefundResponse, err error) {
if bm.GetString("out_trade_no") == util.NULL && bm.GetString("trade_no") == util.NULL {
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time")
}
err = bm.CheckEmptyError("refund_amount")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.refund"); err != nil {
return nil, err
}
aliRsp = new(TradeRefundResponse)
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)
}
// alipay.trade.page.refund(统一收单退款页面接口)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.page.refund
func (a *Client) TradePageRefund(bm gopay.BodyMap) (aliRsp *TradePageRefundResponse, err error) {
if bm.GetString("out_trade_no") == util.NULL && bm.GetString("trade_no") == util.NULL {
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time")
}
err = bm.CheckEmptyError("out_request_no", "refund_amount")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.page.refund"); err != nil {
return nil, err
}
aliRsp = new(TradePageRefundResponse)
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)
}
// alipay.trade.fastpay.refund.query(统一收单交易退款查询)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.fastpay.refund.query
func (a *Client) TradeFastPayRefundQuery(bm gopay.BodyMap) (aliRsp *TradeFastpayRefundQueryResponse, err error) {
if bm.GetString("out_trade_no") == util.NULL && bm.GetString("trade_no") == util.NULL {
return nil, errors.New("out_trade_no and trade_no are not allowed to be null at the same time")
}
err = bm.CheckEmptyError("out_request_no")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.fastpay.refund.query"); err != nil {
return nil, err
}
aliRsp = new(TradeFastpayRefundQueryResponse)
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)
}
// alipay.trade.order.settle(统一收单交易结算接口)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.order.settle
func (a *Client) TradeOrderSettle(bm gopay.BodyMap) (aliRsp *TradeOrderSettleResponse, err error) {
err = bm.CheckEmptyError("out_request_no", "trade_no", "royalty_parameters")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.order.settle"); err != nil {
return nil, err
}
aliRsp = new(TradeOrderSettleResponse)
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)
}
// alipay.trade.orderinfo.sync(支付宝订单信息同步接口)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.orderinfo.sync
func (a *Client) TradeOrderInfoSync(bm gopay.BodyMap) (aliRsp *TradeOrderInfoSyncRsp, err error) {
err = bm.CheckEmptyError("out_request_no", "trade_no", "biz_type")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.orderinfo.sync"); err != nil {
return nil, err
}
aliRsp = new(TradeOrderInfoSyncRsp)
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)
}
// alipay.trade.advance.consult(订单咨询服务)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.advance.consult
func (a *Client) TradeAdvanceConsult(bm gopay.BodyMap) (aliRsp *TradeAdvanceConsultRsp, err error) {
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.advance.consult"); err != nil {
return nil, err
}
aliRsp = new(TradeAdvanceConsultRsp)
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)
}
// alipay.pcredit.huabei.auth.settle.apply(花芝轻会员结算申请)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.pcredit.huabei.auth.settle.apply
func (a *Client) PcreditHuabeiAuthSettleApply(bm gopay.BodyMap) (aliRsp *PcreditHuabeiAuthSettleApplyRsp, err error) {
err = bm.CheckEmptyError("agreement_no", "pay_amount", "out_request_no", "alipay_user_id")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.pcredit.huabei.auth.settle.apply"); err != nil {
return nil, err
}
aliRsp = new(PcreditHuabeiAuthSettleApplyRsp)
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)
}
// alipay.commerce.transport.nfccard.send(NFC用户卡信息同步)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.commerce.transport.nfccard.send
func (a *Client) CommerceTransportNfccardSend(bm gopay.BodyMap) (aliRsp *CommerceTransportNfccardSendRsp, err error) {
err = bm.CheckEmptyError("issue_org_no", "card_no", "card_status")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.commerce.transport.nfccard.send"); err != nil {
return nil, err
}
aliRsp = new(CommerceTransportNfccardSendRsp)
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)
}
// alipay.data.dataservice.ad.data.query(广告投放数据查询)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.data.dataservice.ad.data.query
func (a *Client) DataDataserviceAdDataQuery(bm gopay.BodyMap) (aliRsp *DataDataserviceAdDataQueryRsp, err error) {
err = bm.CheckEmptyError("query_type", "biz_token", "ad_level", "start_date", "end_date", "outer_id_list")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.data.dataservice.ad.data.query"); err != nil {
return nil, err
}
aliRsp = new(DataDataserviceAdDataQueryRsp)
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)
}
// alipay.commerce.air.callcenter.trade.apply(航司电话订票待申请接口)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.commerce.air.callcenter.trade.apply
func (a *Client) CommerceAirCallcenterTradeApply(bm gopay.BodyMap) (aliRsp *CommerceAirCallcenterTradeApplyRsp, err error) {
err = bm.CheckEmptyError("scene_code", "op_code", "channel", "target_id", "target_id_type", "trade_apply_params")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.commerce.air.callcenter.trade.apply"); err != nil {
return nil, err
}
aliRsp = new(CommerceAirCallcenterTradeApplyRsp)
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)
}
// mybank.payment.trade.order.create(网商银行全渠道收单业务订单创建)
// 文档地址:https://opendocs.alipay.com/apis/api_1/mybank.payment.trade.order.create
func (a *Client) PaymentTradeOrderCreate(bm gopay.BodyMap) (aliRsp *PaymentTradeOrderCreateRsp, err error) {
err = bm.CheckEmptyError("partner_id", "out_trade_no", "recon_related_no", "pd_code", "ev_code", "total_amount", "currency_code", "goods_info", "seller_id", "pay_type", "pay_date")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "mybank.payment.trade.order.create"); err != nil {
return nil, err
}
aliRsp = new(PaymentTradeOrderCreateRsp)
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)
}
// alipay.commerce.operation.gamemarketing.benefit.apply(申请权益发放)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.commerce.operation.gamemarketing.benefit.apply
func (a *Client) CommerceBenefitApply(bm gopay.BodyMap) (aliRsp *CommerceBenefitApplyRsp, err error) {
err = bm.CheckEmptyError("activity_code", "trade_no", "user_account", "platform")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.commerce.operation.gamemarketing.benefit.apply"); err != nil {
return nil, err
}
aliRsp = new(CommerceBenefitApplyRsp)
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)
}
// alipay.commerce.operation.gamemarketing.benefit.verify(权益核销)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.commerce.operation.gamemarketing.benefit.verify
func (a *Client) CommerceBenefitVerify(bm gopay.BodyMap) (aliRsp *CommerceBenefitVerifyRsp, err error) {
err = bm.CheckEmptyError("activity_code", "voucher_code", "user_account", "trade_no")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.commerce.operation.gamemarketing.benefit.verify"); err != nil {
return nil, err
}
aliRsp = new(CommerceBenefitVerifyRsp)
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)
}
// alipay.trade.repaybill.query(还款账单查询)
// 文档地址:https://opendocs.alipay.com/apis/api_1/alipay.trade.repaybill.query
func (a *Client) TradeRepaybillQuery(bm gopay.BodyMap) (aliRsp *TradeRepaybillQueryRsp, err error) {
var bs []byte
if bs, err = a.doAliPay(bm, "alipay.trade.repaybill.query"); err != nil {
return nil, err
}
aliRsp = new(TradeRepaybillQueryRsp)
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)
}