-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprotocol_bind_card.go
76 lines (69 loc) · 2.36 KB
/
protocol_bind_card.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
package epaylinks
import (
"errors"
)
type ProtocolBindCard struct {
MchtOrderNo string `json:"mchtOrderNo"` // 请求流水号
CustomerCode string `json:"customerCode"` // 商户号
MemberId string `json:"memberId"` // 会员编号
UserName string `json:"userName"` // 会员姓名
PhoneNum string `json:"phoneNum"` // 手机号码
BankCardNo string `json:"bankCardNo"` // 银行卡号
BankCardType string `json:"bankCardType"` // 银行卡类型
CertificatesType string `json:"certificatesType"` // 证件类型
CertificatesNo string `json:"certificatesNo"` // 证件号码
Expired string `json:"expired"` // 有效日期
Cvn string `json:"cvn"` // CVN 码
NonceStr string `json:"nonceStr"` // 随机字符串
}
type ProtocolBindCardRsp struct {
ReturnCode string `json:"returnCode"` // 返回状态码
ReturnMsg string `json:"returnMsg"` // 返回信息
SmsNo string `json:"smsNo"` // 绑卡流水号
CustomerCode string `json:"customerCode"` // 商户号
MemberId string `json:"memberId"` // 会员编号
NonceStr string `json:"nonceStr"` // 随机字符串
}
// 协议支付绑卡预交易
func (c *Client) ProtocolBindCard(pbc *ProtocolBindCard) (rsp *ProtocolBindCardRsp, err error) {
rsp = new(ProtocolBindCardRsp)
err = pbc.checkParms()
if err != nil {
return rsp, err
}
err = c.doPostReq(protocolBindCard, pbc, rsp)
if err != nil {
return rsp, err
}
return rsp, err
}
func (pbc *ProtocolBindCard) checkParms() error {
if pbc.CustomerCode == "" {
return errors.New("商户号不能为空")
}
if pbc.MemberId == "" {
return errors.New("会员编号不能为空")
}
if pbc.UserName == "" {
return errors.New("会员姓名不能为空")
}
if pbc.PhoneNum == "" {
return errors.New("手机号码不能为空")
}
if pbc.BankCardNo == "" {
return errors.New("银行卡号不能为空")
}
if pbc.BankCardType != "debit" && pbc.BankCardType != "credit" {
return errors.New("银行卡类型不能为空")
}
if pbc.CertificatesType != "01" {
return errors.New("证件类型不能为空")
}
if pbc.CertificatesNo == "" {
return errors.New("证件号码不能为空")
}
if pbc.NonceStr == "" {
return errors.New("随机字符串不能为空")
}
return nil
}