forked from AuthorizeNet/sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponseCode.java
More file actions
69 lines (58 loc) · 1.49 KB
/
ResponseCode.java
File metadata and controls
69 lines (58 loc) · 1.49 KB
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
package net.authorize;
import net.authorize.util.StringUtils;
/**
* Response code indicates the overall status of the transaction
* with possible values of approved, declined, error, or held for review.
*
*/
public enum ResponseCode {
APPROVED(1, "This transaction has been approved."),
DECLINED(2, "This transaction has been declined"),
ERROR(3, "There has been an error processing this transaction."),
REVIEW(4, "This transaction is being held for review."),
UNKNOWN(0, "Unknown.");
private final int code;
private final String description;
private ResponseCode(int code, String description) {
this.code = code;
this.description = description;
}
/**
* Lookup a ResponseCode by it's response code.
* @param code
*
* @return Returns a ResponseCode if a code match is found.
*/
public static ResponseCode findByResponseCode(int code) {
for(ResponseCode responseCode : values()) {
if(responseCode.code == code) {
return responseCode;
}
}
return ResponseCode.UNKNOWN;
}
/**
* Lookup a ResponseCode by it's response code.
* @param code
*
* @return Returns a ResponseCode if a code match is found.
*/
public static ResponseCode findByResponseCode(String code) {
if(StringUtils.isNotEmpty(code)) {
return findByResponseCode(Integer.parseInt(code));
}
return ResponseCode.UNKNOWN;
}
/**
* @return the code
*/
public int getCode() {
return code;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
}