-
Notifications
You must be signed in to change notification settings - Fork 23
/
transaction_responses.go
54 lines (45 loc) · 1.03 KB
/
transaction_responses.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
package AuthorizeCIM
func (transx TransactionResponse) TransactionID() string {
return transx.Response.TransID
}
func (transx TransactionResponse) Message() string {
return transx.Response.Errors[0].ErrorText
}
func (transx TransactionResponse) AVS() AVS {
out := AVS{
avsResultCode: transx.Response.AvsResultCode,
cvvResultCode: transx.Response.CvvResultCode,
cavvResultCode: transx.Response.CavvResultCode,
}
return out
}
type AVS struct {
avsResultCode string
cvvResultCode string
cavvResultCode string
}
type TransxReponse interface {
ErrorMessage()
Approved()
}
func (r MessagesResponse) ErrorMessage() string {
return r.Messages.Message[0].Text
}
func (r TransactionResponse) Approved() bool {
if r.Response.ResponseCode == "1" || r.Response.ResponseCode == "4" {
return true
}
return false
}
func (r TransactionResponse) Held() bool {
if r.Response.ResponseCode == "4" {
return true
}
return false
}
func (r MessagesResponse) Ok() bool {
if r.Messages.ResultCode == "Ok" {
return true
}
return false
}