This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
/
translation.go
46 lines (40 loc) · 1.77 KB
/
translation.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
package authorizenet
import "github.com/BoltApp/sleet"
var cvvMap = map[CVVResultCode]sleet.CVVResponse{
CVVResultMatched: sleet.CVVResponseMatch,
CVVResultNoMatch: sleet.CVVResponseNoMatch,
CVVResultNotProcessed: sleet.CVVResponseNotProcessed,
CVVResultNotPresent: sleet.CVVResponseRequiredButMissing,
CVVResultUnableToProcess: sleet.CVVResponseNotProcessed,
}
// translateCvv converts a Firstdata CVV response code to its equivalent Sleet standard code.
func translateCvv(code CVVResultCode) sleet.CVVResponse {
sleetCode, ok := cvvMap[code]
if !ok {
return sleet.CVVResponseUnknown
}
return sleetCode
}
var avsMap = map[AVSResultCode]sleet.AVSResponse{
AVSResultNotPresent: sleet.AVSResponseSkipped,
AVSResultError: sleet.AVSResponseError,
AVSResultNotApplicable: sleet.AVSResponseSkipped,
AVSResultRetry: sleet.AVSResponseError,
AVSResultNotSupportedIssuer: sleet.AVSResponseUnsupported,
AVSResultInfoUnavailable: sleet.AVSResponseSkipped,
AVSResultPostMatchAddressMatch: sleet.AVSResponseMatch,
AVSResultNoMatch: sleet.AVSResponseNoMatch,
AVSResultPostNoMatchAddressMatch: sleet.AVSResponseZipNoMatchAddressMatch,
AVSResultZipMatchAddressNoMatch: sleet.AVSResponseZip9MatchAddressNoMatch,
AVSResultZipMatchAddressMatch: sleet.AVSResponseMatch,
AVSResultPostMatchAddressNoMatch: sleet.AVSResponseZipMatchAddressUnverified,
AVSResultNotSupportedInternational: sleet.AVSResponseUnsupported,
}
// translateAvs converts a Firstdata AVS response code to its equivalent Sleet standard code.
func translateAvs(avs AVSResultCode) sleet.AVSResponse {
sleetCode, ok := avsMap[avs]
if !ok {
return sleet.AVSResponseUnknown
}
return sleetCode
}