forked from AuthorizeNet/sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnvironment.java
More file actions
142 lines (126 loc) · 4.1 KB
/
Environment.java
File metadata and controls
142 lines (126 loc) · 4.1 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
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
package net.authorize;
/*================================================================================
*
* Determines the target environment to post transactions.
*
* SANDBOX should be used for testing. Transactions submitted to the sandbox
* will not result in an actual card payment. Instead, the sandbox simulates
* the response. Use the Testing Guide to generate specific gateway responses.
*
* PRODUCTION connects to the production gateway environment.
*
*===============================================================================*/
public enum Environment {
SANDBOX("https://test.authorize.net","https://apitest.authorize.net","https://test.authorize.net"),
PRODUCTION("https://secure2.authorize.net","https://api2.authorize.net","https://cardpresent.authorize.net"),
LOCAL_VM(null,null,null),
HOSTED_VM(null,null,null),
CUSTOM(null,null,null);
//http://ww725ramittal1.qa.intra/xml/v1/request.api
private String baseUrl;
private String xmlBaseUrl;
private String cardPresentUrl;
private Environment(String baseUrl, String xmlBaseUrl, String cardPresentUrl) {
this.baseUrl = baseUrl;
this.xmlBaseUrl = xmlBaseUrl;
this.cardPresentUrl = cardPresentUrl;
}
/**
* @return the baseUrl
*/
public String getBaseUrl() {
return baseUrl;
}
/**
* @return the xmlBaseUrl
*/
public String getXmlBaseUrl() {
return xmlBaseUrl;
}
/**
* @return the cardPresentUrl
*/
public String getCardPresentUrl() {
return cardPresentUrl;
}
/**
* If a custom environment needs to be supported, this convenience create
* method can be used to pass in a custom baseUrl.
*
* @param baseUrl
* @param xmlBaseUrl
* @return Environment object
*/
public static Environment createEnvironment(String baseUrl, String xmlBaseUrl) {
Environment environment = Environment.CUSTOM;
environment.baseUrl = baseUrl;
environment.xmlBaseUrl = xmlBaseUrl;
return environment;
}
/**
* If a custom environment needs to be supported, this convenience create
* method can be used to pass in a custom baseUrl.
*
* @param baseUrl
* @param xmlBaseUrl
* @param cardPresentUrl
*
* @return Environment object
*/
public static Environment createEnvironment(String baseUrl, String xmlBaseUrl, String cardPresentUrl) {
Environment environment = Environment.CUSTOM;
environment.baseUrl = baseUrl;
environment.xmlBaseUrl = xmlBaseUrl;
environment.cardPresentUrl = cardPresentUrl;
return environment;
}
/**
* Reads a integer value from property file and/or the environment
* Values in property file supersede the values set in environment
* @param propertyName name of the integer property to read
* @return int property value
*/
public static int getIntProperty( String propertyName)
{
int value = 0;
String stringValue = getProperty(propertyName);
value = (net.authorize.util.StringUtils.parseInt(stringValue));
return value;
}
/**
* Reads a boolean value from property file and/or the environment
* Values in property file supersede the values set in environment
* @param propertyName name of the boolean property to read
* @return boolean property value
*/
public static boolean getBooleanProperty( String propertyName)
{
boolean value = false;
String stringValue = getProperty(propertyName);
if ( null != stringValue)
{
value = Boolean.parseBoolean(stringValue.trim());
}
return value;
}
/**
* Reads the value from property file and/or the environment
* Values in property file supersede the values set in environment
* @param propertyName name of the property to read
* @return String property value
*/
public static String getProperty(String propertyName) {
String stringValue = null;
String propValue = System.getProperty(propertyName);
String envValue = System.getenv(propertyName);
if ( null != propValue && propValue.trim().length() > 0 )
{
stringValue = propValue;
}
else if ( null != envValue && envValue.trim().length() > 0 )
{
stringValue = envValue;
}
return stringValue;
}
}