request) {
192 |
193 | LOGGER.info("Sending XML request to Realex.");
194 |
195 | //generate any required defaults e.g. order ID, time stamp, hash
196 | request.generateDefaults(secret);
197 |
198 | //convert request to XML
199 | LOGGER.debug("Marshalling request object to XML.");
200 | String xmlRequest = request.toXml();
201 |
202 | //send request to Realex.
203 | String xmlResult = HttpUtils.sendMessage(xmlRequest, httpClient, httpConfiguration);
204 |
205 | //log the response
206 | LOGGER.trace("Response XML from server: {}", xmlResult);
207 |
208 | //convert XML to response object
209 | LOGGER.debug("Unmarshalling XML to response object.");
210 | U response = request.responseFromXml(new StreamSource(new StringReader(xmlResult)));
211 |
212 | //throw exception if short response returned (indicating request could not be processed).
213 | if (ResponseUtils.isBasicResponse(response.getResult())) {
214 | LOGGER.error("Error response received from Realex with code {} and message {}.", response.getResult(), response.getMessage());
215 | throw new RealexServerException(response.getTimeStamp(), response.getOrderId(), response.getResult(), response.getMessage());
216 | }
217 |
218 | //validate response hash
219 | LOGGER.debug("Verifying response hash.");
220 | if (!response.isHashValid(secret)) {
221 | //Hash invalid. Throw exception.
222 | LOGGER.error("Response hash is invalid. This response's validity cannot be verified.");
223 | throw new RealexException("Response hash is invalid. This response's validity cannot be verified.");
224 | }
225 |
226 | return response;
227 | }
228 | }
229 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/RealexException.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk;
2 |
3 | /**
4 | * An exception class for general Realex SDK errors. All other SDK exceptions will extend this class.
5 | *
6 | * @author markstanford
7 | */
8 | public class RealexException extends RuntimeException {
9 |
10 | private static final long serialVersionUID = -6404893161440391367L;
11 |
12 | /**
13 | * Constructor for RealexException.
14 | *
15 | * @param message
16 | * @param throwable
17 | */
18 | public RealexException(String message, Throwable throwable) {
19 | super(message, throwable);
20 | }
21 |
22 | /**
23 | * Constructor for RealexException.
24 | *
25 | * @param message
26 | */
27 | public RealexException(String message) {
28 | super(message);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/RealexServerException.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk;
2 |
3 | /**
4 | * This exception will be thrown when an error occurs on the Realex server when attempting to process
5 | * the request.
6 | *
7 | * @author markstanford
8 | */
9 | public class RealexServerException extends RealexException {
10 |
11 | private static final long serialVersionUID = -298850091427275465L;
12 |
13 | /**
14 | * The error code returned from Realex.
15 | */
16 | private final String errorCode;
17 |
18 | /**
19 | * The order Id of the request/response.
20 | */
21 | private final String orderId;
22 |
23 | /**
24 | * The timestamp of the request/response.
25 | */
26 | private final String timeStamp;
27 |
28 | /**
29 | * Constructor for RealexServerException.
30 | *
31 | * @param timeStamp
32 | * @param orderId
33 | * @param errorCode
34 | * @param message
35 | */
36 | public RealexServerException(String timeStamp, String orderId, String errorCode, String message) {
37 | super(message);
38 | this.errorCode = errorCode;
39 | this.orderId = orderId;
40 | this.timeStamp = timeStamp;
41 | }
42 |
43 | /**
44 | * Getter for error code.
45 | *
46 | * @return String
47 | */
48 | public String getErrorCode() {
49 | return errorCode;
50 | }
51 |
52 | /**
53 | * Get the order Id of the request which generated this exception.
54 | *
55 | * @return String
56 | */
57 | public String getOrderId() {
58 | return orderId;
59 | }
60 |
61 | /**
62 | * Get the timestamp of the request which generated this exception.
63 | *
64 | * @return String
65 | */
66 | public String getTimeStamp() {
67 | return timeStamp;
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/Amount.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlAttribute;
6 | import javax.xml.bind.annotation.XmlValue;
7 |
8 | /**
9 | *
10 | * Class representing the Amount in a Realex request.
11 | *
12 | *
13 | * Helper methods are provided (prefixed with 'add') for object creation.
14 | *
15 | *
16 | * Example creation:
17 | *
18 | *
19 | * Amount amount = new Amount().addAmount(100l).addCurrency(CurrencyType.EUR);
20 | *
21 | *
22 | * @author markstanford
23 | *
24 | */
25 | @XmlAccessorType(XmlAccessType.FIELD)
26 | public class Amount {
27 |
28 | /**
29 | * The amount should be in the smallest unit of the required currency (For example: 2000=20 euro, dollar or pounds).
30 | */
31 | @XmlValue
32 | private Long amount;
33 |
34 | /**
35 | * The type of curency, e.g. GBP (Sterling) or EUR (Euro)
36 | */
37 | @XmlAttribute(name = "currency")
38 | private String currency;
39 |
40 | /**
41 | * Amount constructor
42 | */
43 | public Amount() {
44 | }
45 |
46 | /**
47 | * Getter for amount.
48 | *
49 | * @return Long
50 | */
51 | public Long getAmount() {
52 | return amount;
53 | }
54 |
55 | /**
56 | * Setter for amount.
57 | *
58 | * @param amount
59 | */
60 | public void setAmount(Long amount) {
61 | this.amount = amount;
62 | }
63 |
64 | /**
65 | * Getter for currency
66 | *
67 | * @return CurrencyType
68 | */
69 | public String getCurrency() {
70 | return currency;
71 | }
72 |
73 | /**
74 | * Setter for currency
75 | *
76 | * @param currency
77 | */
78 | public void setCurrency(String currency) {
79 | this.currency = currency;
80 | }
81 |
82 | /**
83 | * Helper method for adding an amount.
84 | *
85 | * @param amount
86 | * @return Amount
87 | */
88 | public Amount addAmount(Long amount) {
89 | this.amount = amount;
90 | return this;
91 | }
92 |
93 | /**
94 | * Helper method for adding a currency.
95 | *
96 | * @param currency
97 | * @return Amount
98 | */
99 | public Amount addCurrency(String currency) {
100 | this.currency = currency;
101 | return this;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/Card.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlElement;
6 |
7 | /**
8 | *
9 | * Represents the card which is required in AUTH requests.
10 | *
11 | *
12 | * Helper methods are provided (prefixed with 'add') for object creation.
13 | *
14 | *
15 | * Example creation:
16 | *
17 | *
18 | * Card card = new Card().addExpiryDate("0119")
19 | * .addNumber("420000000000000000")
20 | * .addType(CardType.VISA)
21 | * .addCardHolderName("Joe Smith")
22 | * .addCvn("123")
23 | * .addCvnPresenceIndicator(PresenceIndicator.CVN_PRESENT);
24 | *
25 | *
26 | * @author markstanford
27 | *
28 | */
29 | @XmlAccessorType(XmlAccessType.FIELD)
30 | public class Card {
31 |
32 | /* Masks for sanitising card numbers methods */
33 | private static final String SHORT_MASK = "******";
34 |
35 | /**
36 | * Enumeration representing card types.
37 | */
38 | public enum CardType {
39 |
40 | // @formatter:off
41 | VISA("VISA"),
42 | MASTERCARD("MC"),
43 | AMEX("AMEX"),
44 | CB("CB"),
45 | DINERS("DINERS"),
46 | JCB("JCB");
47 | // @formatter:on
48 |
49 | /**
50 | * The card type.
51 | */
52 | private String type;
53 |
54 | /**
55 | * Constructor for enum.
56 | */
57 | CardType(String type) {
58 | this.type = type;
59 | }
60 |
61 | /**
62 | * Getter for card type.
63 | *
64 | * @return String
65 | */
66 | public String getType() {
67 | return this.type;
68 | }
69 | }
70 |
71 | /**
72 | * The reference for this card (Card Storage)
73 | *
74 | * This must be unique within the Payer record if you are adding multiple
75 | * cards, but it does not need to be unique in relation to other Payers.
76 | */
77 | @XmlElement(name = "ref")
78 | private String reference;
79 |
80 |
81 | /**
82 | * The payer ref for this customer (Card Storage)
83 | */
84 | @XmlElement(name = "payerref")
85 | private String payerReference;
86 |
87 | /**
88 | * The card number used for the transaction.
89 | */
90 | @XmlElement(name = "number")
91 | private String number;
92 |
93 | /**
94 | * The card expiry date, in the format MMYY, which must be a date in the future.
95 | */
96 | @XmlElement(name = "expdate")
97 | private String expiryDate;
98 |
99 | /**
100 | * The card holder's name
101 | */
102 | @XmlElement(name = "chname")
103 | private String cardHolderName;
104 |
105 | /**
106 | * The card type used in the transaction.
107 | */
108 | @XmlElement(name = "type")
109 | private String type;
110 |
111 | /**
112 | * The card issue number.
113 | */
114 | @XmlElement(name = "issueno")
115 | private Integer issueNumber;
116 |
117 | /**
118 | * {@link Cvn}, the card verification number.
119 | */
120 | @XmlElement(name = "cvn")
121 | private Cvn cvn;
122 |
123 | /**
124 | * The {@link Card} constructor.
125 | */
126 | public Card() {
127 | }
128 |
129 | /**
130 | * Getter for the card reference.
131 | *
132 | * @return String
133 | */
134 | public String getReference() {
135 | return reference;
136 | }
137 |
138 | /**
139 | * Setter for the card reference.
140 | *
141 | * @param reference
142 | */
143 | public void setReference(String reference) {
144 | this.reference = reference;
145 | }
146 |
147 | /**
148 | * Getter for the payer reference
149 | *
150 | * @return String
151 | */
152 | public String getPayerReference() {
153 | return payerReference;
154 | }
155 |
156 | /**
157 | * Setter for the payer reference
158 | *
159 | * @param payerReference
160 | */
161 | public void setPayerReference(String payerReference) {
162 | this.payerReference = payerReference;
163 | }
164 |
165 |
166 | /**
167 | * Getter for the card number.
168 | *
169 | * @return String
170 | */
171 | public String getNumber() {
172 | return number;
173 | }
174 |
175 | /**
176 | * Setter for the card number.
177 | *
178 | * @param number
179 | */
180 | public void setNumber(String number) {
181 | this.number = number;
182 | }
183 |
184 | /**
185 | * Getter for the expiry date.
186 | *
187 | * @return String
188 | */
189 | public String getExpiryDate() {
190 | return expiryDate;
191 | }
192 |
193 | /**
194 | * Setter for the expiry date.
195 | *
196 | * @param expiryDate
197 | */
198 | public void setExpiryDate(String expiryDate) {
199 | this.expiryDate = expiryDate;
200 | }
201 |
202 | /**
203 | * Getter for the card holder name.
204 | *
205 | * @return String
206 | */
207 | public String getCardHolderName() {
208 | return cardHolderName;
209 | }
210 |
211 | /**
212 | * Setter for the card holder name.
213 | *
214 | * @param cardHolderName
215 | */
216 | public void setCardHolderName(String cardHolderName) {
217 | this.cardHolderName = cardHolderName;
218 | }
219 |
220 | /**
221 | * Getter for the card type.
222 | *
223 | * @return String
224 | */
225 | public String getType() {
226 | return type;
227 | }
228 |
229 | /**
230 | * Setter for the card type.
231 | *
232 | * @param type
233 | */
234 | public void setType(String type) {
235 | this.type = type;
236 | }
237 |
238 | /**
239 | * Getter for the issue number.
240 | *
241 | * @return Integer
242 | */
243 | public Integer getIssueNumber() {
244 | return issueNumber;
245 | }
246 |
247 | /**
248 | * Setter for the issue number.
249 | *
250 | * @param issueNumber
251 | */
252 | public void setIssueNumber(Integer issueNumber) {
253 | this.issueNumber = issueNumber;
254 | }
255 |
256 | /**
257 | * Getter for the {@link Cvn}.
258 | *
259 | * @return Cvn
260 | */
261 | public Cvn getCvn() {
262 | return cvn;
263 | }
264 |
265 | /**
266 | * Setter for the {@link Cvn}.
267 | *
268 | * @param cvn
269 | */
270 | public void setCvn(Cvn cvn) {
271 | this.cvn = cvn;
272 | }
273 |
274 | /**
275 | * Helper method to add the card reference.
276 | *
277 | * @param reference
278 | * @return Card
279 | */
280 | public Card addReference(String reference) {
281 | this.reference = reference;
282 | return this;
283 | }
284 |
285 |
286 | /**
287 | * Helper method to add a payer reference.
288 | *
289 | * @param payerReference
290 | * @return Card
291 | */
292 | public Card addPayerReference(String payerReference) {
293 | this.payerReference = payerReference;
294 | return this;
295 | }
296 |
297 | /**
298 | * Helper method to add a card number.
299 | *
300 | * @param number
301 | * @return Card
302 | */
303 | public Card addNumber(String number) {
304 | this.number = number;
305 | return this;
306 | }
307 |
308 | /**
309 | * Helper method to add CVN. If the {@link Cvn} field is null then one is created.
310 | *
311 | * @param cvn
312 | * @return Card
313 | */
314 | public Card addCvn(String cvn) {
315 | if (null == this.cvn) {
316 | this.cvn = new Cvn().addNumber(cvn);
317 | } else {
318 | this.cvn.addNumber(cvn);
319 | }
320 | return this;
321 | }
322 |
323 | /**
324 | * Helper method to add CVN presence indicator. If the {@link Cvn} is null then one is created.
325 | *
326 | * @param presenceIndicator
327 | * @return Card
328 | */
329 | public Card addCvnPresenceIndicator(Cvn.PresenceIndicator presenceIndicator) {
330 | if (null == this.cvn) {
331 | this.cvn = new Cvn().addPresenceIndicator(presenceIndicator);
332 | } else {
333 | this.cvn.addPresenceIndicator(presenceIndicator);
334 | }
335 | return this;
336 | }
337 |
338 | /**
339 | * Helper method to add CVN presence indicator. If the {@link Cvn} is null then one is created.
340 | *
341 | * @param presenceIndicator
342 | * @return Card
343 | */
344 | public Card addCvnPresenceIndicator(String presenceIndicator) {
345 | if (null == this.cvn) {
346 | this.cvn = new Cvn().addPresenceIndicator(presenceIndicator);
347 | } else {
348 | this.cvn.addPresenceIndicator(presenceIndicator);
349 | }
350 | return this;
351 | }
352 |
353 | /**
354 | * Helper method to add a card expiry date. The format is MMYY e.g. 1219 for December 2019.
355 | *
356 | * @param expiryDate
357 | * @return Card
358 | */
359 | public Card addExpiryDate(String expiryDate) {
360 | this.expiryDate = expiryDate;
361 | return this;
362 | }
363 |
364 | /**
365 | * Helper method to add an issue number.
366 | *
367 | * @param issueNumber
368 | * @return Card
369 | */
370 | public Card addIssueNumber(Integer issueNumber) {
371 | this.issueNumber = issueNumber;
372 | return this;
373 | }
374 |
375 | /**
376 | * Helper method to add a card holder name.
377 | *
378 | * @param cardHolderName
379 | * @return Card
380 | */
381 | public Card addCardHolderName(String cardHolderName) {
382 | this.cardHolderName = cardHolderName;
383 | return this;
384 | }
385 |
386 | /**
387 | * Helper method to add a card type.
388 | *
389 | * @param type
390 | * @return Card
391 | */
392 | public Card addType(String type) {
393 | this.type = type;
394 | return this;
395 | }
396 |
397 | /**
398 | * Helper method to add a {@link CardType}.
399 | *
400 | * @param type
401 | * @return Card
402 | */
403 | public Card addType(CardType type) {
404 | this.type = type.getType();
405 | return this;
406 | }
407 |
408 | /**
409 | * Get a sanitised version of the card number displaying only the first six and last four digits.
410 | *
411 | * @return String
412 | */
413 | public String displayFirstSixLastFour() {
414 | StringBuffer result = new StringBuffer(this.number.substring(0, 6));
415 | result.append(SHORT_MASK);
416 | result.append(this.number.substring(this.number.length() - 4));
417 | return result.toString();
418 | }
419 |
420 | }
421 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/Country.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlAttribute;
6 | import javax.xml.bind.annotation.XmlValue;
7 |
8 | /**
9 | *
10 | * Domain object representing Country information to be passed to Realex.
11 | *
12 | *
13 | *
14 | *
15 | * Country country = new Country();
16 | * country.setCode("IE");
17 | * country.setName("Ireland");
18 | *
19 | *
20 | *
21 | * @author vicpada
22 | */
23 | @XmlAccessorType(XmlAccessType.FIELD)
24 | public class Country {
25 |
26 | /**
27 | * The country code. The list of country codes is available
28 | * in the realauth developers guide.
29 | */
30 | @XmlAttribute(name = "code")
31 | private String code;
32 |
33 | /**
34 | * The country name.
35 | */
36 | @XmlValue
37 | private String name;
38 |
39 | /**
40 | * Constructor
41 | */
42 | public Country() {
43 | }
44 |
45 | /**
46 | * Getter for code
47 | *
48 | * @return String
49 | */
50 | public String getCode() {
51 | return code;
52 | }
53 |
54 | /**
55 | * Setter for code
56 | *
57 | * @param code
58 | */
59 | public void setCode(String code) {
60 | this.code = code;
61 | }
62 |
63 | /**
64 | * Getter for name
65 | *
66 | * @return String
67 | */
68 | public String getName() {
69 | return name;
70 | }
71 |
72 | /**
73 | * Setter for name
74 | *
75 | * @param name
76 | */
77 | public void setName(String name) {
78 | this.name = name;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/Cvn.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlElement;
6 |
7 | /**
8 | *
9 | * Class representing the card verification details.
10 | *
11 | *
12 | * Helper methods are provided (prefixed with 'add') for object creation.
13 | *
14 | *
15 | * Example creation:
16 | *
17 | *
18 | * Cvn cvn = new Cvn().addNumber(123).addPresenceIndicator(PresenceIndicator.CVN_PRESENT);
19 | *
20 | *
21 | * @author markstanford
22 | *
23 | */
24 | @XmlAccessorType(XmlAccessType.FIELD)
25 | public class Cvn {
26 |
27 | /**
28 | *
29 | * Enumeration of the possible presence indicator values. 4 values are permitted:
30 | *
31 | * - cvn present
32 | * - cvn illegible
33 | * - cvn not on card
34 | * - cvn not requested
35 | *
36 | *
37 | */
38 | public enum PresenceIndicator {
39 | CVN_PRESENT("1"),
40 | CVN_ILLEGIBLE("2"),
41 | CVN_NOT_ON_CARD("3"),
42 | CVN_NOT_REQUESTED("4");
43 |
44 | /**
45 | * The indicator.
46 | */
47 | private String indicator;
48 |
49 | /**
50 | * Constructor for enum.
51 | */
52 | PresenceIndicator(String indicator) {
53 | this.indicator = indicator;
54 | }
55 |
56 | /**
57 | * Getter for indicator.
58 | *
59 | * @return String
60 | */
61 | public String getIndicator() {
62 | return this.indicator;
63 | }
64 | }
65 |
66 | /**
67 | * A three-digit number on the reverse of the card. It is called the CVC for VISA and the CVV2 for MasterCard.
68 | * For an AMEX card, it is a four digit number.
69 | */
70 | @XmlElement(name = "number")
71 | private String number;
72 |
73 | /**
74 | *
75 | * Presence indicator. 4 values are permitted:
76 | *
77 | * - cvn present
78 | * - cvn illegible
79 | * - cvn not on card
80 | * - cvn not requested
81 | *
82 | *
83 | */
84 | @XmlElement(name = "presind")
85 | private String presenceIndicator;
86 |
87 | /**
88 | * Cvn constructor
89 | */
90 | public Cvn() {
91 | }
92 |
93 | /**
94 | * Getter for verification number.
95 | *
96 | * @return String
97 | */
98 | public String getNumber() {
99 | return number;
100 | }
101 |
102 | /**
103 | * Setter for verification number.
104 | *
105 | * @param number
106 | */
107 | public void setNumber(String number) {
108 | this.number = number;
109 | }
110 |
111 | /**
112 | * Getter for the presence indicator.
113 | *
114 | * @return PresenceIndicator
115 | */
116 | public String getPresenceIndicator() {
117 | return presenceIndicator;
118 | }
119 |
120 | /**
121 | * Setter for the presence indicator.
122 | *
123 | * @param presenceIndicator
124 | */
125 | public void setPresenceIndicator(String presenceIndicator) {
126 | this.presenceIndicator = presenceIndicator;
127 | }
128 |
129 | /**
130 | * Helper method to add a verification number.
131 | *
132 | * @param number
133 | * @return Cvn
134 | */
135 | public Cvn addNumber(String number) {
136 | this.number = number;
137 | return this;
138 | }
139 |
140 | /**
141 | * Helper method to add a presence indicator.
142 | *
143 | * @param presenceIndicator
144 | * @return Cvn
145 | */
146 | public Cvn addPresenceIndicator(String presenceIndicator) {
147 | this.presenceIndicator = presenceIndicator;
148 | return this;
149 | }
150 |
151 | /**
152 | * Helper method to add a {@link PresenceIndicator}.
153 | *
154 | * @param presenceIndicator
155 | * @return Cvn
156 | */
157 | public Cvn addPresenceIndicator(PresenceIndicator presenceIndicator) {
158 | this.presenceIndicator = presenceIndicator.getIndicator();
159 | return this;
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/CvnNumber.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlElement;
6 |
7 | /**
8 | *
9 | * Domain object representing PaymentData CVN number information to be passed to
10 | * Realex Card Storage for Receipt-in transactions.
11 | * Contains the CVN number for the stored card
12 | *
13 | *
14 | *
15 | * CvnNumber cvnNumber = new CvnNumber()
16 | * .addNumber("123") ;
17 | *
18 | *
19 | * @author vicpada
20 | */
21 |
22 | @XmlAccessorType(XmlAccessType.FIELD)
23 | public class CvnNumber {
24 |
25 | /**
26 | * A three-digit number on the reverse of the card. It is called the CVC for VISA and the CVV2 for MasterCard.
27 | * For an AMEX card, it is a four digit number.
28 | */
29 | @XmlElement(name = "number")
30 | private String number;
31 |
32 |
33 | /**
34 | * CvnNumber constructor
35 | */
36 | public CvnNumber() {
37 | }
38 |
39 | /**
40 | * Getter for verification number.
41 | *
42 | * @return String
43 | */
44 | public String getNumber() {
45 | return number;
46 | }
47 |
48 | /**
49 | * Setter for verification number.
50 | *
51 | * @param number
52 | */
53 | public void setNumber(String number) {
54 | this.number = number;
55 | }
56 |
57 | /**
58 | * Helper method to add a verification number.
59 | *
60 | * @param number
61 | * @return CvnNumber
62 | */
63 | public CvnNumber addNumber(String number) {
64 | this.number = number;
65 | return this;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/DccInfo.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlElement;
6 |
7 | /**
8 | *
9 | * Domain object representing DCC information to be passed to Realex.
10 | *
11 | *
12 | *
13 | * Example dcc rate lookup:
14 | *
*
15 | *
16 | * DccInfo dccInfo = new DccInfo()
17 | * .addDccProcessor("fexco");
18 | *
19 | *
20 | *
21 | *
22 | * Example dcc rate lookup + auth:
23 | *
24 | *
25 | *
26 | * DccInfo dccInfo = new DccInfo()
27 | * .addDccProcessor("fexco")
28 | * .addRate(0.6868)
29 | * .addAmount(13049)
30 | * .addCurrency("GBP");
31 | *
32 | *
33 | *
34 | *
35 | * @author vicpada
36 | */
37 | @XmlAccessorType(XmlAccessType.FIELD)
38 | public class DccInfo {
39 |
40 | /**
41 | * The DCC processor (Currency Conversion Processor)
42 | */
43 | @XmlElement(name = "ccp")
44 | private String dccProcessor;
45 |
46 | /**
47 | * The type - always "1"
48 | */
49 | @XmlElement(name = "type")
50 | private String type;
51 |
52 |
53 | /**
54 | * The rate returned by DCC Info rate lookup request
55 | */
56 | @XmlElement(name = "rate")
57 | private double rate;
58 |
59 |
60 | /**
61 | * The rate type. Defaulted to S
62 | */
63 | @XmlElement(name = "ratetype")
64 | private String rateType;
65 |
66 | /**
67 | * The amount. As returned by DCC Info rate lookup request
68 | */
69 | @XmlElement(name = "amount")
70 | private Amount amount;
71 |
72 | /**
73 | * Constructor
74 | */
75 | public DccInfo() {
76 |
77 | // default type to 1 and rate type to "S"
78 | this.type = "1";
79 | this.rateType = "S";
80 |
81 | }
82 |
83 | /**
84 | * Getter for dccProcessor
85 | *
86 | * @return String
87 | */
88 | public String getDccProcessor() {
89 | return dccProcessor;
90 | }
91 |
92 | /**
93 | * Setter for dccProcessor
94 | *
95 | * @param dccProcessor
96 | */
97 | public void setDccProcessor(String dccProcessor) {
98 | this.dccProcessor = dccProcessor;
99 | }
100 |
101 | /**
102 | * Getter for type
103 | *
104 | * @return String
105 | */
106 | public String getType() {
107 | return type;
108 | }
109 |
110 | /**
111 | * Setter for type
112 | *
113 | * @param type
114 | */
115 | public void setType(String type) {
116 | this.type = type;
117 | }
118 |
119 |
120 | /**
121 | * Getter for rate
122 | *
123 | * @return Double
124 | */
125 | public Double getRate() {
126 | return rate;
127 | }
128 |
129 | /**
130 | * Setter for rate
131 | *
132 | * @param rate
133 | */
134 | public void setRate(Double rate) {
135 | this.rate = rate;
136 | }
137 |
138 |
139 | /**
140 | * Getter for rateType
141 | *
142 | * @return String
143 | */
144 | public String getRateType() {
145 | return rateType;
146 | }
147 |
148 | /**
149 | * Setter for rateType
150 | *
151 | * @param rateType
152 | */
153 | public void setRateType(String rateType) {
154 | this.rateType = rateType;
155 | }
156 |
157 |
158 | /**
159 | * Getter for amount
160 | *
161 | * @return Amount
162 | */
163 | public Amount getAmount() {
164 | return amount;
165 | }
166 |
167 | /**
168 | * Setter for amount
169 | *
170 | * @param amount
171 | */
172 | public void setAmount(Amount amount) {
173 | this.amount = amount;
174 | }
175 |
176 | /**
177 | * Helper method for adding a dcc processor.
178 | *
179 | * @param dccProcessor
180 | * @return DccInfo
181 | */
182 | public DccInfo addDccProcessor(String dccProcessor) {
183 | this.dccProcessor = dccProcessor;
184 | return this;
185 | }
186 |
187 | /**
188 | * Helper method for adding a type.
189 | *
190 | * @param type
191 | * @return DccInfo
192 | */
193 | public DccInfo addType(String type) {
194 | this.type = type;
195 | return this;
196 | }
197 |
198 | /**
199 | * Helper method for adding a rate.
200 | *
201 | * @param rate
202 | * @return DccInfo
203 | */
204 | public DccInfo addRate(Double rate) {
205 | this.rate = rate;
206 | return this;
207 | }
208 |
209 | /**
210 | * Helper method for adding a rate type.
211 | *
212 | * @param rateType
213 | * @return DccInfo
214 | */
215 | public DccInfo addRateType(String rateType) {
216 | this.rateType = rateType;
217 | return this;
218 | }
219 |
220 | /**
221 | * Helper method for adding an amount.
222 | *
223 | * @param amount
224 | * @return DccInfo
225 | */
226 | public DccInfo addAmount(long amount) {
227 | if (null == this.amount) {
228 | this.amount = new Amount().addAmount(amount);
229 | } else {
230 | this.amount.addAmount(amount);
231 | }
232 | return this;
233 | }
234 |
235 | /**
236 | * Helper method for adding a currency.
237 | *
238 | * @param currency
239 | * @return DccInfo
240 | */
241 | public DccInfo addCurrency(String currency) {
242 | if (null == this.amount) {
243 | this.amount = new Amount().addCurrency(currency);
244 | } else {
245 | this.amount.addCurrency(currency);
246 | }
247 | return this;
248 | }
249 | }
250 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/DccInfoResult.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlElement;
6 |
7 | /**
8 | *
9 | * Domain object representing DCC information returned by Realex.
10 | *
11 | *
12 | *
13 | * DccInfoResult dccInfo = new DccInfoResult();
14 | * dccInfo.setCardHolderCurrency("GBP");
15 | * dccInfo.setCardHolderAmount(13049);
16 | * dccInfo.setCardHolderRate(0.6868);
17 | * dccInfo.setMerchantCurrency("EUR");
18 | * dccInfo.setMerchantAmount("19000");
19 | *
20 | *
21 | *
22 | *
23 | * @author vicpada
24 | */
25 | @XmlAccessorType(XmlAccessType.FIELD)
26 | public class DccInfoResult{
27 |
28 | /**
29 | * The currency of the card holder
30 | */
31 | @XmlElement(name = "cardholdercurrency")
32 | private String cardHolderCurrency;
33 |
34 | /**
35 | * The amount on the card holder currency
36 | */
37 | @XmlElement(name = "cardholderamount")
38 | private Long cardHolderAmount;
39 |
40 | /**
41 | * The rate used to calculate the card holder amount
42 | */
43 | @XmlElement(name = "cardholderrate")
44 | private Double cardHolderRate;
45 |
46 | /**
47 | * The currency used by the merchant
48 | */
49 | @XmlElement(name = "merchantcurrency")
50 | private String merchantCurrency;
51 |
52 | /**
53 | * The amount in the currency of the merchant
54 | */
55 | @XmlElement(name = "merchantamount")
56 | private Long merchantAmount;
57 |
58 | /**
59 | * Percentage of the margin rate
60 | */
61 | @XmlElement(name = "marginratepercentage")
62 | private String marginRatePercentage;
63 |
64 | /**
65 | * Name of the source that provides the exchange rate
66 | */
67 | @XmlElement(name = "exchangeratesourcename")
68 | private String exchangeRateSourceName;
69 |
70 | /**
71 | * Commission Percentage
72 | */
73 | @XmlElement(name = "commissionpercentage")
74 | private String commissionPercentage;
75 |
76 | /**
77 | * Timestamp for the exchange rate
78 | */
79 | @XmlElement(name = "exchangeratesourcetimestamp")
80 | private String exchangeRateSourceTimestamp;
81 |
82 | /**
83 | * Getter for the card holder currency
84 | *
85 | * @return String
86 | */
87 | public String getCardHolderCurrency() {
88 | return cardHolderCurrency;
89 | }
90 |
91 | /**
92 | * Setter for card holder currency.
93 | *
94 | * @param currency
95 | */
96 | public void setCardHolderCurrency(String currency) {
97 | this.cardHolderCurrency = currency;
98 | }
99 |
100 | /**
101 | * Getter for card holder amount
102 | *
103 | * @return Long
104 | */
105 | public Long getCardHolderAmount() {
106 | return cardHolderAmount;
107 | }
108 |
109 | /**
110 | * Setter for card holder amount.
111 | *
112 | * @param amount
113 | */
114 | public void setCardHolderAmount(Long amount) {
115 | this.cardHolderAmount = amount;
116 | }
117 |
118 | /**
119 | * Getter for card holder rate
120 | *
121 | * @return Double
122 | */
123 | public Double getCardHolderRate() {
124 | return cardHolderRate;
125 | }
126 |
127 | /**
128 | * Setter for card holder rate
129 | *
130 | * @param rate
131 | */
132 | public void setCardHolderRate(Double rate) {
133 | this.cardHolderRate = rate;
134 | }
135 |
136 | /**
137 | * Getter for merchant currency
138 | *
139 | * @return String
140 | */
141 | public String getMerchantCurrency() {
142 | return merchantCurrency;
143 | }
144 |
145 | /**
146 | * Setter for merchant currency.
147 | *
148 | * @param currency
149 | */
150 | public void setMerchantCurrency(String currency) {
151 | this.merchantCurrency = currency;
152 | }
153 |
154 | /**
155 | * Getter merchant amount
156 | *
157 | * @return Long
158 | */
159 | public Long getMerchantAmount() {
160 | return merchantAmount;
161 | }
162 |
163 | /**
164 | * Setter for amount.
165 | *
166 | * @param amount
167 | */
168 | public void setMerchantAmount(Long amount) {
169 | this.merchantAmount = amount;
170 | }
171 |
172 |
173 |
174 | /**
175 | * Getter for margin rate percentage
176 | *
177 | * @return String
178 | */
179 | public String getMarginRatePercentage() {
180 | return marginRatePercentage;
181 | }
182 |
183 | /**
184 | * Setter for margin rate percentage.
185 | *
186 | * @param marginRatePercentage
187 | */
188 | public void setMarginRatePercentage(String marginRatePercentage) {
189 | this.marginRatePercentage = marginRatePercentage;
190 | }
191 |
192 | /**
193 | * Getter for exchange rate source name
194 | *
195 | * @return String
196 | */
197 | public String getExchangeRateSourceName() {
198 | return exchangeRateSourceName;
199 | }
200 |
201 | /**
202 | * Setter for exchange rate source name
203 | *
204 | * @param exchangeRateSourceName
205 | */
206 | public void setExchangeRateSourceName(String exchangeRateSourceName) {
207 | this.exchangeRateSourceName = exchangeRateSourceName;
208 | }
209 |
210 | /**
211 | * Getter for commission percentage
212 | *
213 | * @return String
214 | */
215 | public String getCommissionPercentage() {
216 | return commissionPercentage;
217 | }
218 |
219 | /**
220 | * Setter for commission percentage
221 | *
222 | * @param commissionPercentage
223 | */
224 | public void setCommissionPercentage(String commissionPercentage) {
225 | this.commissionPercentage = commissionPercentage;
226 | }
227 |
228 | /**
229 | * Getter for exchange rate source timestamp
230 | *
231 | * @return String
232 | */
233 | public String getExchangeRateSourceTimestamp() {
234 | return exchangeRateSourceTimestamp;
235 | }
236 |
237 | /**
238 | * Setter for exchange rate source timestamp
239 | *
240 | * @param exchangeRateSourceTimestamp
241 | */
242 | public void setExchangeRateSourceTimestamp(String exchangeRateSourceTimestamp) {
243 | this.exchangeRateSourceTimestamp = exchangeRateSourceTimestamp;
244 | }
245 |
246 | }
247 |
248 |
249 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/Payer.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain;
2 |
3 | import com.realexpayments.remote.sdk.domain.payment.Comment;
4 |
5 | import javax.xml.bind.annotation.*;
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | *
11 | * Domain object representing Payer information to be passed to Realex.
12 | *
13 | *
14 | *
15 | * Payer payer = new Payer()
16 | * .addType("Business")
17 | * .addRef("smithj01")
18 | * .addTitle("Mr")
19 | * .addFirstName("John")
20 | * .addSurname("Smith")
21 | * .addCompany("Acme")
22 | * .addAddress(address)
23 | * .addHomePhoneNumber("+35317285355")
24 | * .addWorkPhoneNumber("+35317433923")
25 | * .addFaxPhoneNumber("+35317893248")
26 | * .addMobilePhoneNumber("+353873748392")
27 | * .addEmail("jsmith@acme.com")
28 | * .addComment("Comment1")
29 | * .addComment("Comment2");
30 | *
31 | *
32 | *
33 | * @author vicpada
34 | *
35 | */
36 | @XmlAccessorType(XmlAccessType.FIELD)
37 | public class Payer {
38 |
39 | /**
40 | * The payer type can be used to identify the category of the Payer.
41 | * This can be defaulted to “Business”
42 | */
43 | @XmlAttribute(name = "type")
44 | private String type;
45 |
46 | /**
47 | * The payer ref is the reference for this customer. It must be unique.
48 | */
49 | @XmlAttribute(name = "ref")
50 | private String ref;
51 |
52 | /**
53 | * The payer’s title
54 | */
55 | @XmlElement(name = "title")
56 | private String title;
57 |
58 | /**
59 | * First name of payer.
60 | */
61 | @XmlElement(name = "firstname")
62 | private String firstName;
63 |
64 | /**
65 | * Surname of payer
66 | */
67 | @XmlElement(name = "surname")
68 | private String surname;
69 |
70 | /**
71 | * Company Name
72 | */
73 | @XmlElement(name = "company")
74 | private String company;
75 |
76 | /**
77 | * {@link PayerAddress} object containing the payer address.
78 | */
79 | @XmlElement(name = "address")
80 | private PayerAddress address;
81 |
82 | /**
83 | * {@link PhoneNumbers} object containing the payer phone numbers.
84 | */
85 | @XmlElement(name = "phonenumbers")
86 | private PhoneNumbers phoneNumbers;
87 |
88 | /**
89 | * The payer email
90 | */
91 | @XmlElement(name = "email")
92 | private String email;
93 |
94 | /**
95 | * List of {@link Comment} objects to be passed in request.
96 | * Optionally, up to two comments can be associated with any payer.
97 | */
98 | @XmlElementWrapper(name = "comments")
99 | @XmlElements(@XmlElement(name = "comment", type = Comment.class))
100 | private List comments;
101 |
102 | /**
103 | * Constructor
104 | */
105 | public Payer() {
106 | }
107 |
108 | /**
109 | * Getter for type
110 | *
111 | * @return String
112 | */
113 | public String getType() {
114 | return type;
115 | }
116 |
117 | /**
118 | * Setter for type
119 | *
120 | * @param type
121 | */
122 | public void setType(String type) {
123 | this.type = type;
124 | }
125 |
126 | /**
127 | * Getter for ref
128 | *
129 | * @return String
130 | */
131 | public String getRef() {
132 | return ref;
133 | }
134 |
135 | /**
136 | * Setter for ref
137 | *
138 | * @param ref
139 | */
140 | public void setRef(String ref) {
141 | this.ref = ref;
142 | }
143 |
144 | /**
145 | *
146 | * Getter for title
147 | *
148 | * @return String
149 | */
150 | public String getTitle() {
151 | return title;
152 | }
153 |
154 | /**
155 | * Setter for title
156 | *
157 | * @param title
158 | */
159 | public void setTitle(String title) {
160 | this.title = title;
161 | }
162 |
163 | /**
164 | * Getter for firstName
165 | *
166 | * @return String
167 | */
168 | public String getFirstName() {
169 | return firstName;
170 | }
171 |
172 | /**
173 | * Setter for firstName
174 | *
175 | * @param firstName
176 | */
177 | public void setFirstName(String firstName) {
178 | this.firstName = firstName;
179 | }
180 |
181 | /**
182 | * Getter for surname
183 | *
184 | * @return String
185 | */
186 | public String getSurname() {
187 | return surname;
188 | }
189 |
190 | /**
191 | * Setter for surname
192 | *
193 | * @param surname
194 | */
195 | public void setSurname(String surname) {
196 | this.surname = surname;
197 | }
198 |
199 | /**
200 | * Getter for company
201 | *
202 | * @return String
203 | */
204 | public String getCompany() {
205 | return company;
206 | }
207 |
208 | /**
209 | * Setter for company
210 | *
211 | * @param company
212 | */
213 | public void setCompany(String company) {
214 | this.company = company;
215 | }
216 |
217 | /**
218 | * Getter for address
219 | *
220 | * @return Address
221 | */
222 | public PayerAddress getAddress() {
223 | return address;
224 | }
225 |
226 | /**
227 | * Setter for address
228 | *
229 | * @param address
230 | */
231 | public void setAddress(PayerAddress address) {
232 | this.address = address;
233 | }
234 |
235 | /**
236 | * Getter for phoneNumbers
237 | *
238 | * @return PhoneNumbers
239 | */
240 | public PhoneNumbers getPhoneNumbers() {
241 | return phoneNumbers;
242 | }
243 |
244 | /**
245 | * Setter for phoneNumbers
246 | *
247 | * @param phoneNumbers
248 | */
249 | public void setPhoneNumbers(PhoneNumbers phoneNumbers) {
250 | this.phoneNumbers = phoneNumbers;
251 | }
252 |
253 | /**
254 | * Getter for email
255 | *
256 | * @return String
257 | */
258 | public String getEmail() {
259 | return email;
260 | }
261 |
262 | /**
263 | * Setter for email
264 | *
265 | * @param email
266 | */
267 | public void setEmail(String email) {
268 | this.email = email;
269 | }
270 |
271 | /**
272 | * Getter for {@link Comment} list.
273 | *
274 | * @return List
275 | */
276 | public List getComments() {
277 | return comments;
278 | }
279 |
280 | /**
281 | * Setter for comments
282 | *
283 | * @param comments
284 | */
285 | public void setComments(List comments) {
286 | this.comments = comments;
287 | }
288 |
289 | /**
290 | * Helper method for adding a payer home phone number.
291 | *
292 | * @param phoneNumber
293 | * @return Payer
294 | */
295 | public Payer addHomePhoneNumber(String phoneNumber) {
296 |
297 | //create new comments array list if null
298 | if (null == this.phoneNumbers) {
299 | this.phoneNumbers = new PhoneNumbers();
300 | }
301 |
302 | this.phoneNumbers.setHomePhoneNumber(phoneNumber);
303 | return this;
304 | }
305 |
306 | /**
307 | * Helper method for adding a payer work phone number.
308 | *
309 | * @param phoneNumber
310 | * @return Payer
311 | */
312 | public Payer addWorkPhoneNumber(String phoneNumber) {
313 |
314 | //create new comments array list if null
315 | if (null == this.phoneNumbers) {
316 | this.phoneNumbers = new PhoneNumbers();
317 | }
318 |
319 | this.phoneNumbers.setWorkPhoneNumber(phoneNumber);
320 | return this;
321 | }
322 |
323 | /**
324 | * Helper method for adding a payer fax phone number.
325 | *
326 | * @param phoneNumber
327 | * @return Payer
328 | */
329 | public Payer addFaxPhoneNumber(String phoneNumber) {
330 |
331 | //create new comments array list if null
332 | if (null == this.phoneNumbers) {
333 | this.phoneNumbers = new PhoneNumbers();
334 | }
335 |
336 | this.phoneNumbers.setFaxPhoneNumber(phoneNumber);
337 | return this;
338 | }
339 |
340 | /**
341 | * Helper method for adding a payer mobile phone number.
342 | *
343 | * @param phoneNumber
344 | * @return Payer
345 | */
346 | public Payer addMobilePhoneNumber(String phoneNumber) {
347 |
348 | //create new comments array list if null
349 | if (null == this.phoneNumbers) {
350 | this.phoneNumbers = new PhoneNumbers();
351 | }
352 |
353 | this.phoneNumbers.setMobilePhoneNumber(phoneNumber);
354 | return this;
355 | }
356 |
357 |
358 | /**
359 | * Helper method for adding a payer ref.
360 | *
361 | * @param ref
362 | * @return Payer
363 | */
364 | public Payer addRef(String ref) {
365 | this.ref = ref;
366 | return this;
367 | }
368 |
369 | /**
370 | * Helper method for adding a payer title.
371 | *
372 | * @param title
373 | * @return Payer
374 | */
375 | public Payer addTitle(String title) {
376 | this.title = title;
377 | return this;
378 | }
379 |
380 | /**
381 | * Helper method for adding a payer first name.
382 | *
383 | * @param firstName
384 | * @return Payer
385 | */
386 | public Payer addFirstName(String firstName) {
387 | this.firstName = firstName;
388 | return this;
389 | }
390 |
391 | /**
392 | * Helper method for adding a payer type.
393 | *
394 | * @param surname
395 | * @return Payer
396 | */
397 | public Payer addSurname(String surname) {
398 | this.surname = surname;
399 | return this;
400 | }
401 |
402 | /**
403 | * Helper method for adding a payer type.
404 | *
405 | * @param company
406 | * @return Payer
407 | */
408 | public Payer addCompany(String company) {
409 | this.company = company;
410 | return this;
411 | }
412 |
413 | /**
414 | * Helper method for adding a payer type.
415 | *
416 | * @param address
417 | * @return Payer
418 | */
419 | public Payer addPayerAddress(PayerAddress address) {
420 | this.address = address;
421 | return this;
422 | }
423 |
424 | /**
425 | * Helper method for adding a payer type.
426 | *
427 | * @param type
428 | * @return Payer
429 | */
430 | public Payer addType(String type) {
431 | this.type = type;
432 | return this;
433 | }
434 |
435 | /**
436 | * Helper method for adding a payer type.
437 | *
438 | * @param email
439 | * @return Payer
440 | */
441 | public Payer addEmail(String email) {
442 | this.email = email;
443 | return this;
444 | }
445 |
446 | /**
447 | * Helper method for adding a comment. NB Only 2 comments will be accepted by Realex.
448 | *
449 | * @param comment
450 | * @return Payer
451 | */
452 | public Payer addComment(String comment) {
453 | //create new comments array list if null
454 | if (null == this.comments) {
455 | this.comments = new ArrayList();
456 | }
457 |
458 | int size = comments.size();
459 | this.comments.add(new Comment().addComment(comment).addId(++size));
460 | return this;
461 | }
462 |
463 |
464 | }
465 |
466 |
467 |
468 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/PayerAddress.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlAttribute;
6 | import javax.xml.bind.annotation.XmlElement;
7 |
8 | /**
9 | *
10 | * Domain object representing Payer information to be passed to Realex.
11 | *
12 | *
13 | *
14 | *
15 | * PayerAddress address = new PayerAddress()
16 | * .addLine1("Apt 167 Block 10")
17 | * .addLine2("The Hills")
18 | * .addLine3("67-69 High St")
19 | * .addCity("Hytown")
20 | * .addCounty("Dunham")
21 | * .addPostCode("3")
22 | * .addCountryCode("IE")
23 | * .addCountryName("Ireland");
24 | *
25 | *
26 | *
27 | * @author vicpada
28 | */
29 | @XmlAccessorType(XmlAccessType.FIELD)
30 | public class PayerAddress {
31 |
32 | /**
33 | * Address line 1
34 | */
35 | @XmlElement(name = "line1")
36 | private String line1;
37 |
38 | /**
39 | * Address line 2
40 | */
41 | @XmlElement(name = "line2")
42 | private String line2;
43 |
44 | /**
45 | * Address line 3
46 | */
47 | @XmlElement(name = "line3")
48 | private String line3;
49 |
50 | /**
51 | * Address city
52 | */
53 | @XmlElement(name = "city")
54 | private String city;
55 |
56 | /**
57 | * Address county
58 | */
59 | @XmlElement(name = "county")
60 | private String county;
61 |
62 | /**
63 | * Address postcode
64 | */
65 | @XmlElement(name = "postcode")
66 | private String postcode;
67 |
68 | /**
69 | * Address country
70 | */
71 | @XmlElement(name = "country")
72 | private Country country;
73 |
74 | /**
75 | * Constructor
76 | */
77 | public PayerAddress() {
78 | }
79 |
80 | /**
81 | * Getter for line 1
82 | *
83 | * @return String
84 | */
85 | public String getLine1() {
86 | return line1;
87 | }
88 |
89 | /**
90 | * Setter for line 1
91 | *
92 | * @param line1
93 | */
94 | public void setLine1(String line1) {
95 | this.line1 = line1;
96 | }
97 |
98 | /**
99 | * Getter for line 2
100 | *
101 | * @return String
102 | */
103 | public String getLine2() {
104 | return line2;
105 | }
106 |
107 | /**
108 | * Setter for line 2
109 | *
110 | * @param line2
111 | */
112 | public void setLine2(String line2) {
113 | this.line2 = line2;
114 | }
115 |
116 | /**
117 | * Getter for line 3
118 | *
119 | * @return String
120 | */
121 | public String getLine3() {
122 | return line3;
123 | }
124 |
125 | /**
126 | * Setter for line 3
127 | *
128 | * @param line3
129 | */
130 | public void setLine3(String line3) {
131 | this.line3 = line3;
132 | }
133 |
134 | /**
135 | * Getter for city
136 | *
137 | * @return String
138 | */
139 | public String getCity() {
140 | return city;
141 | }
142 |
143 | /**
144 | * Setter for city
145 | *
146 | * @param city
147 | */
148 | public void setCity(String city) {
149 | this.city = city;
150 | }
151 |
152 | /**
153 | * Getter for county
154 | *
155 | * @return String
156 | */
157 | public String getCounty() {
158 | return county;
159 | }
160 |
161 | /**
162 | * Setter for county
163 | *
164 | * @param county
165 | */
166 | public void setCounty(String county) {
167 | this.county = county;
168 | }
169 |
170 | /**
171 | * Getter for postcode
172 | *
173 | * @return String
174 | */
175 | public String getPostcode() {
176 | return postcode;
177 | }
178 |
179 | /**
180 | * Setter for postcode
181 | *
182 | * @param postcode
183 | */
184 | public void setPostcode(String postcode) {
185 | this.postcode = postcode;
186 | }
187 |
188 | /**
189 | * Getter for country
190 | *
191 | * @return Country
192 | */
193 | public Country getCountry() {
194 | return country;
195 | }
196 |
197 | /**
198 | * Setter for country
199 | *
200 | * @param country
201 | */
202 | public void setCountry(Country country) {
203 | this.country = country;
204 | }
205 |
206 | /**
207 | * Helper method for adding address line 1
208 | *
209 | * @param line1
210 | * @return PayerAddress
211 | */
212 | public PayerAddress addLine1(String line1) {
213 | this.line1 = line1;
214 | return this;
215 | }
216 |
217 | /**
218 | * Helper method for adding address line 2
219 | *
220 | * @param line2
221 | * @return PayerAddress
222 | */
223 | public PayerAddress addLine2(String line2) {
224 | this.line2 = line2;
225 | return this;
226 | }
227 |
228 |
229 | /**
230 | * Helper method for adding address line 3
231 | *
232 | * @param line3
233 | * @return PayerAddress
234 | */
235 | public PayerAddress addLine3(String line3) {
236 | this.line3 = line3;
237 | return this;
238 | }
239 |
240 |
241 | /**
242 | * Helper method for adding City
243 | *
244 | * @param city
245 | * @return PayerAddress
246 | */
247 | public PayerAddress addCity(String city) {
248 | this.city = city;
249 | return this;
250 | }
251 |
252 |
253 | /**
254 | * Helper method for adding address county
255 | *
256 | * @param county
257 | * @return PayerAddress
258 | */
259 | public PayerAddress addCounty(String county) {
260 | this.county = county;
261 | return this;
262 | }
263 |
264 |
265 | /**
266 | * Helper method for adding address postcode
267 | *
268 | * @param postcode
269 | * @return PayerAddress
270 | */
271 | public PayerAddress addPostcode(String postcode) {
272 | this.postcode = postcode;
273 | return this;
274 | }
275 |
276 | /**
277 | * Helper method for adding address country Code. The list of country
278 | * codes is available in the realauth developers guide.
279 | *
280 | * @param countryCode
281 | * @return PayerAddress
282 | */
283 | public PayerAddress addCountryCode(String countryCode) {
284 | if (null == this.country)
285 | {
286 | this.country = new Country();
287 | }
288 |
289 | country.setCode(countryCode);
290 | return this;
291 | }
292 |
293 | /**
294 | * Helper method for adding address country name.
295 | *
296 | * @param countryName
297 | * @return PayerAddress
298 | */
299 | public PayerAddress addCountryName(String countryName) {
300 | if (null == this.country)
301 | {
302 | this.country = new Country();
303 | }
304 |
305 | country.setName(countryName);
306 | return this;
307 | }
308 |
309 | }
310 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/PaymentData.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlElement;
6 |
7 | /**
8 | *
9 | * Domain object representing PaymentData information to be passed to Realex Card Storage
10 | * for Receipt-in transactions.
11 | * Payment data contains the CVN number for the stored card
12 | *
13 | *
14 | *
15 | * PaymentData paymentData = new PaymentData()
16 | * .addCvnNumber("123") ;
17 | *
18 | *
19 | * @author vicpada
20 | */
21 | @XmlAccessorType(XmlAccessType.FIELD)
22 | public class PaymentData {
23 |
24 |
25 | /**
26 | * A container for the CVN number
27 | */
28 | @XmlElement(name = "cvn")
29 | private CvnNumber cvnNumber;
30 |
31 | /**
32 | * PaymentData constructor
33 | */
34 | public PaymentData() {
35 | }
36 |
37 | /**
38 | * Getter for verification number.
39 | *
40 | * @return CvnNumber
41 | */
42 | public CvnNumber getCvnNumber() {
43 | return cvnNumber;
44 | }
45 |
46 | /**
47 | * Setter for verification number.
48 | *
49 | * @param cvnNumber
50 | */
51 | public void setCvnNumber(CvnNumber cvnNumber) {
52 | this.cvnNumber = cvnNumber;
53 | }
54 |
55 | /**
56 | * Helper method to add a verification number.
57 | *
58 | * @param number
59 | * @return PaymentData
60 | */
61 | public PaymentData addCvnNumber(String number) {
62 | if (this.cvnNumber == null) {
63 | this.cvnNumber = new CvnNumber();
64 | }
65 |
66 | this.cvnNumber.addNumber(number);
67 | return this;
68 | }
69 |
70 | /**
71 | * Helper method to add a verification number.
72 | *
73 | * @param cvnNumber
74 | * @return PaymentData
75 | */
76 | public PaymentData addCvnNumber(CvnNumber cvnNumber) {
77 | this.cvnNumber = cvnNumber;
78 | return this;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/PhoneNumbers.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain;
2 |
3 | import javax.xml.bind.annotation.*;
4 |
5 | /**
6 | *
7 | * Domain object representing Payer phone numbers information to be passed to Realex.
8 | *
9 | *
10 | *
11 | * PhoneNumbers phoneNumbers = new PhoneNumbers();
12 | * phoneNumbers.setHomePhoneNumber("+35317285355");
13 | * phoneNumbers.setWorkPhoneNumber("+35317433923");
14 | * phoneNumbers.setFaxPhoneNumber("+35317893248");
15 | * phoneNumbers.setMobilePhoneNumber("+353873748392")
16 | *
17 | *
18 | *
19 | * @author vicpada
20 | *
21 | */
22 | @XmlAccessorType(XmlAccessType.FIELD)
23 | public class PhoneNumbers {
24 |
25 | /**
26 | * Home phone number
27 | */
28 | @XmlElement(name = "home")
29 | private String homePhoneNumber;
30 |
31 | /**
32 | * Work phone number
33 | */
34 | @XmlElement(name = "work")
35 | private String workPhoneNumber;
36 |
37 | /**
38 | * Fax phone number
39 | */
40 | @XmlElement(name = "fax")
41 | private String faxPhoneNumber;
42 |
43 | /**
44 | * Mobile phone number
45 | */
46 | @XmlElement(name = "mobile")
47 | private String mobilePhoneNumber;
48 |
49 | /**
50 | * Constructor
51 | */
52 | public PhoneNumbers() {
53 | }
54 |
55 | /**
56 | * Getter for home phone number
57 | *
58 | * @return String
59 | */
60 | public String getHomePhoneNumber() {
61 | return homePhoneNumber;
62 | }
63 |
64 | /**
65 | * Setter for home phone number
66 | *
67 | * @param homePhoneNumber
68 | */
69 | public void setHomePhoneNumber(String homePhoneNumber) {
70 | this.homePhoneNumber = homePhoneNumber;
71 | }
72 |
73 | /**
74 | * Getter for work phone number
75 | *
76 | * @return String
77 | */
78 | public String getWorkPhoneNumber() {
79 | return workPhoneNumber;
80 | }
81 |
82 | /**
83 | * Setter for work phone number
84 | *
85 | * @param workPhoneNumber
86 | */
87 | public void setWorkPhoneNumber(String workPhoneNumber) {
88 | this.workPhoneNumber = workPhoneNumber;
89 | }
90 |
91 | /**
92 | * Getter for fax phone number
93 | *
94 | * @return String
95 | */
96 | public String getFaxPhoneNumber() {
97 | return faxPhoneNumber;
98 | }
99 |
100 | /**
101 | * Setter for fax phone number
102 | *
103 | * @param faxPhoneNumber
104 | */
105 | public void setFaxPhoneNumber(String faxPhoneNumber) {
106 | this.faxPhoneNumber = faxPhoneNumber;
107 | }
108 |
109 | /**
110 | * Getter for mobile phone number
111 | *
112 | * @return String
113 | */
114 | public String getMobilePhoneNumber() {
115 | return mobilePhoneNumber;
116 | }
117 |
118 | /**
119 | * Setter for mobile phone number
120 | *
121 | * @param mobilePhoneNumber
122 | */
123 | public void setMobilePhoneNumber(String mobilePhoneNumber) {
124 | this.mobilePhoneNumber = mobilePhoneNumber;
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/Request.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain;
2 |
3 | import javax.xml.transform.Source;
4 |
5 | /**
6 | * Interface to be implemented by all classes which represent Realex requests.
7 | *
8 | * @author markstanford
9 | *
10 | */
11 | public interface Request> {
12 |
13 | /**
14 | *
15 | * Method returns an XML representation of the interface implementation.
16 | *
17 | *
18 | * @return String
19 | */
20 | String toXml();
21 |
22 | /**
23 | *
24 | * Method returns a concrete implementation of the request class from an XML source.
25 | *
26 | *
27 | * @param xml
28 | * @return T
29 | */
30 | T fromXml(Source xml);
31 |
32 | /**
33 | *
34 | * Generates default values for fields such as hash, timestamp and order ID.
35 | *
36 | *
37 | * @param secret
38 | * @return T
39 | */
40 | T generateDefaults(String secret);
41 |
42 | /**
43 | *
44 | * Method returns a concrete implementation of the response class from an XML source.
45 | *
46 | *
47 | * @param xml
48 | * @return U
49 | */
50 | U responseFromXml(Source xml);
51 |
52 | }
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/Response.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain;
2 |
3 | import javax.xml.transform.Source;
4 |
5 | /**
6 | * Interface to be implemented by all classes which represent Realex responses.
7 | *
8 | * @author markstanford
9 | *
10 | */
11 | public interface Response {
12 |
13 | /**
14 | * Defines the result code which represents success
15 | */
16 | String RESULT_CODE_SUCCESS = "00";
17 |
18 | /**
19 | * Realex error result codes in the range 3xx to 5xx will not return a full response message.
20 | * Instead a short response will be returned with only the result code and message populated.
21 | */
22 | Integer RESULT_CODE_PREFIX_ERROR_RESPONSE_START = 3;
23 |
24 | /**
25 | *
26 | * Method returns a concrete implementation of the response class from an XML source.
27 | *
28 | *
29 | * @param xml
30 | * @return T
31 | */
32 | T fromXml(Source xml);
33 |
34 | /**
35 | *
36 | * Method returns an XML representation of the interface's implementing class.
37 | *
38 | *
39 | * @return String
40 | */
41 | String toXml();
42 |
43 | /**
44 | *
45 | * Validates the hash in the response is correct. Returns true
if valid,
46 | * false
if not.
47 | *
48 | *
49 | * @param secret
50 | * @return boolean
51 | */
52 | boolean isHashValid(String secret);
53 |
54 | /**
55 | * Returns the result from the response.
56 | *
57 | * @return String
58 | */
59 | String getResult();
60 |
61 | /**
62 | * Returns the message from the response.
63 | *
64 | * @return String
65 | */
66 | String getMessage();
67 |
68 | /**
69 | * Returns the orderId from the response.
70 | *
71 | * @return String
72 | */
73 | String getOrderId();
74 |
75 | /**
76 | * Returns the timestamp from the response.
77 | *
78 | * @return String
79 | */
80 | String getTimeStamp();
81 |
82 | /**
83 | * Returns true
if response message has processed successfully.
84 | *
85 | * @return boolean
86 | */
87 | boolean isSuccess();
88 | }
89 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/Address.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlAttribute;
6 | import javax.xml.bind.annotation.XmlElement;
7 |
8 | /**
9 | *
10 | * The Address of the customer.
11 | *
12 | *
13 | *
14 | * Helper methods are provided (prefixed with 'add') for object creation.
15 | *
16 | *
17 | * Address address = new Address().addCode("D2").addCountry("IE").addType(AddressType.BILLING);
18 | *
19 | *
20 | * @author markstanford
21 | *
22 | */
23 | @XmlAccessorType(XmlAccessType.FIELD)
24 | public class Address {
25 |
26 | /**
27 | * The address type enum. Can be shipping or billing.
28 | */
29 | public enum AddressType {
30 | NONE(""),
31 | SHIPPING("shipping"),
32 | BILLING("billing");
33 |
34 | /**
35 | * The type value
36 | */
37 | private String addressType;
38 |
39 | /**
40 | * Constructor for enum.
41 | *
42 | * @param type
43 | */
44 | AddressType(String addressType) {
45 | this.addressType = addressType;
46 | }
47 |
48 | /**
49 | * Returns String value for the type
50 | *
51 | * @return String
52 | */
53 | public String getAddressType() {
54 | return this.addressType;
55 | }
56 | }
57 |
58 | /**
59 | * The address type. Can be shipping or billing.
60 | */
61 | @XmlAttribute(name = "type")
62 | private String type;
63 |
64 | /**
65 | * The ZIP|Postal code of the address. This can be checked (in conjunction with the country)
66 | * against a table of high-risk area codes. This field is used address verification with certain acquirers.
67 | */
68 | @XmlElement(name = "code")
69 | private String code;
70 |
71 | /**
72 | * The country of the address. This can be checked against a table of high-risk countries.
73 | */
74 | @XmlElement(name = "country")
75 | private String country;
76 |
77 | /**
78 | * Address constructor.
79 | */
80 | public Address() {
81 | }
82 |
83 | /**
84 | * Getter for the code.
85 | *
86 | * @return String
87 | */
88 | public String getCode() {
89 | return code;
90 | }
91 |
92 | /**
93 | * Setter for the code.
94 | *
95 | * @param code
96 | */
97 | public void setCode(String code) {
98 | this.code = code;
99 | }
100 |
101 | /**
102 | * Getter for the country.
103 | *
104 | * @return String
105 | */
106 | public String getCountry() {
107 | return country;
108 | }
109 |
110 | /**
111 | * Setter for the country.
112 | *
113 | * @param country
114 | */
115 | public void setCountry(String country) {
116 | this.country = country;
117 | }
118 |
119 | /**
120 | * Getter for the type.
121 | *
122 | * @return String
123 | */
124 | public String getType() {
125 | return type;
126 | }
127 |
128 | /**
129 | * Setter for the type.
130 | *
131 | * @param type
132 | */
133 | public void setType(String type) {
134 | this.type = type;
135 | }
136 |
137 | /**
138 | * Helper method for setting the code.
139 | *
140 | * @param code
141 | * @return Address
142 | */
143 | public Address addCode(String code) {
144 | this.code = code;
145 | return this;
146 | }
147 |
148 | /**
149 | * Helper method for setting the country.
150 | *
151 | * @param country
152 | * @return Address
153 | */
154 | public Address addCountry(String country) {
155 | this.country = country;
156 | return this;
157 | }
158 |
159 | /**
160 | * Helper method for setting the type.
161 | *
162 | * @param type
163 | * @return Address
164 | */
165 | public Address addType(String type) {
166 | this.type = type;
167 | return this;
168 | }
169 |
170 | /**
171 | * Helper method for setting the type.
172 | *
173 | * @param type
174 | * @return Address
175 | */
176 | public Address addType(AddressType type) {
177 | this.type = type.getAddressType();
178 | return this;
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/AutoSettle.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlAttribute;
6 |
7 | /**
8 | *
9 | * Class representing the AutoSettle flag in a Realex request. If set to TRUE (1),
10 | * then the transaction will be included in today's settlement file. If set to FALSE (0), then the
11 | * transaction will be authorised but not settled. Merchants must manually settle delayed
12 | * transactions within 28 days of authorisation.
13 | *
14 | *
15 | * Helper methods are provided (prefixed with 'add') for object creation.
16 | *
17 | *
18 | * Example creation:
19 | *
20 | *
21 | * AutoSettle autoSettle = new AutoSettle().addFlag(AutoSettleTrue.TRUE);
22 | *
23 | *
24 | * @author markstanford
25 | *
26 | */
27 | @XmlAccessorType(XmlAccessType.FIELD)
28 | public class AutoSettle {
29 |
30 | /**
31 | * Enumeration representing the auto settle flag (true (1), false (0) or multi-settle (MULTI)).
32 | */
33 | public enum AutoSettleFlag {
34 | TRUE("1"),
35 | FALSE("0"),
36 | MULTI("MULTI");
37 |
38 | /**
39 | * The flag field.
40 | */
41 | private String flag;
42 |
43 | /**
44 | * The enum constructor.
45 | *
46 | * @param flag
47 | */
48 | AutoSettleFlag(String flag) {
49 | this.flag = flag;
50 | }
51 |
52 | /**
53 | * Getter for the flag.
54 | *
55 | * @return String
56 | */
57 | public String getFlag() {
58 | return flag;
59 | }
60 | }
61 |
62 | /**
63 | * The AutoSettle flag value.
64 | */
65 | @XmlAttribute(name = "flag")
66 | private String flag;
67 |
68 | /**
69 | * AutoSettle constructor
70 | */
71 | public AutoSettle() {
72 | }
73 |
74 | /**
75 | * Getter for flag
76 | *
77 | * @return AutoSettleFlag
78 | */
79 | public String getFlag() {
80 | return flag;
81 | }
82 |
83 | /**
84 | * Setter for flag
85 | *
86 | * @param flag
87 | */
88 | public void setFlag(String flag) {
89 | this.flag = flag;
90 | }
91 |
92 | /**
93 | * Helper method for adding the flag value.
94 | *
95 | * @param autoSettleFlag
96 | * @return AutoSettle
97 | */
98 | public AutoSettle addFlag(String autoSettleFlag) {
99 | this.flag = autoSettleFlag;
100 | return this;
101 | }
102 |
103 | /**
104 | * Helper method for adding the {@link AutoSettle} value.
105 | *
106 | * @param autoSettleFlag
107 | * @return AutoSettle
108 | */
109 | public AutoSettle addFlag(AutoSettleFlag autoSettleFlag) {
110 | this.flag = autoSettleFlag.getFlag();
111 | return this;
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/CardIssuer.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlElement;
6 |
7 | /**
8 | *
9 | * Class representing details of the card holder's bank (if available).
10 | *
11 | *
12 | * @author markstanford
13 | */
14 | @XmlAccessorType(XmlAccessType.FIELD)
15 | public class CardIssuer {
16 |
17 | /**
18 | * The Bank Name (e.g. First Data Bank).
19 | */
20 | @XmlElement(name = "bank")
21 | private String bank;
22 |
23 | /**
24 | * The Bank Country in English (e.g. UNITED STATES).
25 | */
26 | @XmlElement(name = "country")
27 | private String country;
28 |
29 | /**
30 | * The country code of the issuing bank (e.g. US).
31 | */
32 | @XmlElement(name = "countrycode")
33 | private String countryCode;
34 |
35 | /**
36 | * The region the card was issued (e.g. US) Can be MEA (Middle East/Asia), LAT (Latin America), US (United States),
37 | * EUR (Europe), CAN (Canada), A/P (Asia/Pacific).
38 | */
39 | @XmlElement(name = "region")
40 | private String region;
41 |
42 | /**
43 | * Getter for the bank.
44 | *
45 | * @return String
46 | */
47 | public String getBank() {
48 | return bank;
49 | }
50 |
51 | /**
52 | * Setter for the bank.
53 | *
54 | * @param bank
55 | */
56 | public void setBank(String bank) {
57 | this.bank = bank;
58 | }
59 |
60 | /**
61 | * Getter for the country.
62 | *
63 | * @return String
64 | */
65 | public String getCountry() {
66 | return country;
67 | }
68 |
69 | /**
70 | * Setter for the country.
71 | *
72 | * @param country
73 | */
74 | public void setCountry(String country) {
75 | this.country = country;
76 | }
77 |
78 | /**
79 | * Getter for the country code.
80 | *
81 | * @return String
82 | */
83 | public String getCountryCode() {
84 | return countryCode;
85 | }
86 |
87 | /**
88 | * Setter for the country code.
89 | *
90 | * @param countryCode
91 | */
92 | public void setCountryCode(String countryCode) {
93 | this.countryCode = countryCode;
94 | }
95 |
96 | /**
97 | * Getter for the region.
98 | *
99 | * @return String
100 | */
101 | public String getRegion() {
102 | return region;
103 | }
104 |
105 | /**
106 | * Setter for the region.
107 | *
108 | * @param region
109 | */
110 | public void setRegion(String region) {
111 | this.region = region;
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/Comment.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlAttribute;
6 | import javax.xml.bind.annotation.XmlValue;
7 |
8 | /**
9 | *
10 | * Class representing a Comment in a Realex request.
11 | *
12 | *
13 | * Helper methods are provided (prefixed with 'add') for object creation.
14 | *
15 | *
16 | * Example creation:
17 | *
18 | *
19 | * Comment comment = new Comment().addId(1).addComment("My Comment");
20 | *
21 | *
22 | * @author markstanford
23 | */
24 | @XmlAccessorType(XmlAccessType.FIELD)
25 | public class Comment {
26 |
27 | /**
28 | * A free text comment.
29 | */
30 | @XmlValue
31 | private String comment;
32 |
33 | /**
34 | * The comment ID (1 or 2)
35 | */
36 | @XmlAttribute(name = "id")
37 | private Integer id;
38 |
39 | /**
40 | * Comment constructor.
41 | */
42 | public Comment() {
43 | }
44 |
45 | /**
46 | * Getter for comment.
47 | *
48 | * @return String
49 | */
50 | public String getComment() {
51 | return comment;
52 | }
53 |
54 | /**
55 | * Setter for comment.
56 | *
57 | * @param comment
58 | */
59 | public void setComment(String comment) {
60 | this.comment = comment;
61 | }
62 |
63 | /**
64 | * Getter for ID.
65 | *
66 | * @return Integer
67 | */
68 | public Integer getId() {
69 | return id;
70 | }
71 |
72 | /**
73 | * Setter for ID.
74 | *
75 | * @param id
76 | */
77 | public void setId(Integer id) {
78 | this.id = id;
79 | }
80 |
81 | /**
82 | * Helper method for adding a comment.
83 | *
84 | * @param comment
85 | * @return Comment
86 | */
87 | public Comment addComment(String comment) {
88 | this.comment = comment;
89 | return this;
90 | }
91 |
92 | /**
93 | * Helper for adding an ID.
94 | *
95 | * @param id
96 | * @return Comment
97 | */
98 | public Comment addId(Integer id) {
99 | this.id = id;
100 | return this;
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/FinalTransactionIndicator.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 | import javax.xml.bind.annotation.XmlAccessType;
3 | import javax.xml.bind.annotation.XmlAccessorType;
4 | import javax.xml.bind.annotation.XmlAttribute;
5 |
6 | /**
7 | *
8 | * Represents the flag wrapper that indicates whether this is the final capture or not
9 | *
10 | *
11 | * Helper methods are provided (prefixed with 'add') for object creation.
12 | *
13 | *
14 | * Example creation:
15 | *
16 | *
17 | * FinalTransactionIndicator indicator = new FinalTransactionIndicator()
18 | * .addFinalTransactionFlag("1")
19 | *
20 | *
21 | *
22 | */
23 | @XmlAccessorType(XmlAccessType.FIELD)
24 | public class FinalTransactionIndicator {
25 |
26 | /**
27 | * Attribute that indicates whether this is the final capture or not
28 | *
29 | * Value range: 0 or 1
30 | */
31 | @XmlAttribute(name = "flag")
32 | private String isFinalTransaction;
33 |
34 | /**
35 | * Constructor for FinalTransactionIndicator.
36 | */
37 | public FinalTransactionIndicator() {
38 | }
39 |
40 | /**
41 | * Getter for isFinalTransaction flag.
42 | */
43 | public String getIsFinalTransaction() {
44 | return isFinalTransaction;
45 | }
46 |
47 | /**
48 | * Setter for isFinalTransaction flag.
49 | */
50 | public void setIsFinalTransaction(final String isFinalTransaction) {
51 | this.isFinalTransaction = isFinalTransaction;
52 | }
53 |
54 | /**
55 | * Helper method for adding a isFinalTransaction flag.
56 | */
57 | public FinalTransactionIndicator addFinalTransactionFlag(final String isFinalTransaction) {
58 | this.isFinalTransaction = isFinalTransaction;
59 | return this;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/FraudFilter.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | import javax.xml.bind.annotation.*;
4 | import java.util.*;
5 |
6 | /**
7 | *
8 | * Class representing the FraudFilter mode in a Realex request. This optional XML element is used to
9 | * determine to what degree Fraud Filter executes. If the field is not present, Fraud Filter
10 | * will behave in accordance with the RealControl mode configuration. Please note values are case sensitive.
11 | *
12 | *
13 | * Helper methods are provided (prefixed with 'add') for object creation.
14 | *
15 | *
16 | *
17 | * Example creation:
18 | *
19 | *
20 | * FraudFilter fraudFilter = new FraudFilter().addMode(FraudFilterMode.ACTIVE);
21 | *
22 | *
23 | * @author alessandro
24 | *
25 | */
26 | @XmlAccessorType(XmlAccessType.FIELD)
27 | public class FraudFilter {
28 |
29 | /**
30 | * Enumeration representing the mode filter .
31 | */
32 | public enum FraudFilterMode {
33 | ACTIVE("ACTIVE"),
34 | PASSIVE("PASSIVE"),
35 | OFF("OFF"),
36 | ERROR("ERROR");
37 |
38 | /**
39 | * The mode field.
40 | */
41 | private String mode;
42 |
43 | /**
44 | * The enum constructor.
45 | *
46 | * @param mode
47 | */
48 | FraudFilterMode(String mode) {
49 | this.mode = mode;
50 | }
51 |
52 | /**
53 | * Getter for the mode.
54 | *
55 | * @return String
56 | */
57 | public String toString() {
58 | return mode;
59 | }
60 | }
61 |
62 | /**
63 | * Enumeration representing the mode filter .
64 | */
65 | public enum FraudFilterResult {
66 | BLOCK("BLOCK"),
67 | PASS("PASS"),
68 | HOLD("HOLD"),
69 | NOT_SUPPORTED("NOT SUPPORTED"),
70 | NOT_EXECUTED("NOT_EXECUTED");
71 |
72 | /**
73 | * The result field.
74 | */
75 | private String result;
76 |
77 | /**
78 | * The enum constructor.
79 | *
80 | * @param result
81 | */
82 | FraudFilterResult(String result) {
83 | this.result = result;
84 | }
85 |
86 | /**
87 | * Getter for the result.
88 | *
89 | * @return String
90 | */
91 | public String toString() {
92 | return result;
93 | }
94 | }
95 | /**
96 | * The FraudFilter mode value.
97 | */
98 | @XmlAttribute(name = "mode")
99 | private String mode;
100 |
101 | /**
102 | * The FraudFilter mode value.
103 | */
104 | @XmlElement(name = "result")
105 | private String result;
106 |
107 | /**
108 | * The FraudFilter mode value.
109 | */
110 | @XmlElementWrapper(name = "rules")
111 | @XmlElement(name = "rule", type = FraudFilterRule.class)
112 | private List rules;
113 | /**
114 | * FraudFilter constructor
115 | */
116 | public FraudFilter() {
117 | }
118 |
119 | /**
120 | * Getter for mode
121 | *
122 | * @return FraudFilterMode
123 | */
124 | public String getMode() {
125 | return mode;
126 | }
127 |
128 | /**
129 | * Setter for mode
130 | *
131 | * @param mode
132 | */
133 | public void setMode(String mode) {
134 | this.mode = mode;
135 | }
136 |
137 | /**
138 | * Helper method for adding the mode value.
139 | *
140 | * @param mode
141 | * @return FraudFilter
142 | */
143 | public FraudFilter addMode(FraudFilterMode mode) {
144 | this.mode = mode.toString();
145 | return this;
146 | }
147 |
148 | /**
149 | * Helper method for adding the mode value.
150 | *
151 | * @param mode
152 | * @return FraudFilter
153 | */
154 | public FraudFilter addMode(String mode) {
155 | this.mode = mode;
156 | return this;
157 | }
158 |
159 |
160 | /**
161 | * Setter for result
162 | *
163 | * @param result
164 | */
165 | public void setResult(String result) {
166 | this.result = result;
167 | }
168 |
169 | /**
170 | * Getter for result
171 | *
172 | * @return result
173 | */
174 | public String getResult() {
175 | return result;
176 | }
177 |
178 | /**
179 | * Helper method for adding the {@link FraudFilter} value.
180 | *
181 | * @param result
182 | * @return FraudFilter
183 | */
184 | public FraudFilter addResult(FraudFilterResult result) {
185 | this.result = result.toString();
186 | return this;
187 | }
188 |
189 | /**
190 | * Helper method for adding the {@link FraudFilter} value.
191 | *
192 | * @param result
193 | * @return FraudFilter
194 | */
195 | public FraudFilter addResult(String result) {
196 | this.result = result;
197 | return this;
198 | }
199 |
200 |
201 | /**
202 | * Getter for FraudFilter rules.
203 | *
204 | * @return List
205 | */
206 | public List getRules() {
207 | return rules;
208 | }
209 |
210 | /**
211 | * Setter for FraudFilter rules.
212 | *
213 | * @param rules
214 | */
215 | public void setRules(List rules) {
216 | this.rules = rules;
217 | }
218 |
219 | /**
220 | * Convert to string representation
221 | *
222 | * @return string representation in format of :--;...
223 | */
224 | @Override
225 | public String toString() {
226 | if (this.getResult() == null || this.getRules() == null)
227 | return "";
228 |
229 |
230 | StringBuffer rules = new StringBuffer(this.getResult().toString());
231 | rules.append(":");
232 | for (FraudFilterRule check : this.getRules()) {
233 | rules.append(check.getId());
234 | rules.append("-");
235 | rules.append(check.getName());
236 | rules.append("-");
237 | rules.append(check.getAction());
238 | rules.append(";");
239 | }
240 | return rules.toString();
241 | }
242 |
243 |
244 | }
245 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/FraudFilterRule.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | import javax.xml.bind.annotation.*;
4 |
5 | /**
6 | * Created by alessandro on 17/06/2016.
7 | */
8 |
9 | @XmlRootElement(name = "rule")
10 | @XmlAccessorType(XmlAccessType.FIELD)
11 | public class FraudFilterRule {
12 |
13 | /**
14 | * The FraudFilterRule id action.
15 | */
16 | @XmlAttribute(name = "id")
17 | private String id;
18 |
19 | /**
20 | * The FraudFilterRule name action.
21 | */
22 | @XmlAttribute(name = "name")
23 | private String name;
24 |
25 | /**
26 | * The FraudFilterRule action action.
27 | */
28 | @XmlElement(name = "action")
29 | private String action;
30 |
31 | /**
32 | * Getter for id
33 | *
34 | * @return string
35 | */
36 | public String getId() {
37 | return this.id;
38 | }
39 |
40 | /**
41 | * Setter for id
42 | *
43 | * @param id
44 | */
45 | public void setId( String id ) {
46 | this.id = id;
47 | }
48 |
49 | /**
50 | * Getter for action
51 | *
52 | * @return string
53 | */
54 | public String getAction() {
55 | return this.action;
56 | }
57 |
58 | /**
59 | * Setter for action
60 | *
61 | * @param action
62 | */
63 | public void setAction(String action) {
64 | this.action = action;
65 | }
66 |
67 | /**
68 | * Setter for name
69 | *
70 | * @param name
71 | */
72 | public void setName(String name ) {
73 | this.name = name;
74 | }
75 |
76 | /**
77 | * Getter for name
78 | *
79 | * @return string
80 | */
81 | public String getName() {
82 | return this.name;
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/Mpi.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlElement;
6 |
7 | /**
8 | *
9 | * Domain object representing MPI (realmpi) information to be passed to Realex.
10 | * Realmpi is Realex's product to implement card scheme-certified payer authentication via the bank
11 | * and the 3D Secure system (Verified by Visa for Visa, Secure Code for Mastercard and SafeKey for Amex).
12 | *
13 | *
14 | *
15 | * Mpi mpi = new Mpi()
16 | * .addCavv("cavv")
17 | * .addXid("xid")
18 | * .addEci("eci");
19 | *
20 | *
21 | * @author thomasduffy
22 | *
23 | */
24 | @XmlAccessorType(XmlAccessType.FIELD)
25 | public class Mpi {
26 |
27 | /**
28 | * The CAVV(Visa)/UCAF(Mastercard) if present.
29 | */
30 | @XmlElement(name = "cavv")
31 | private String cavv;
32 |
33 | /**
34 | * The XID.
35 | */
36 | @XmlElement(name = "xid")
37 | private String xid;
38 |
39 | /**
40 | * The e-commerce indicator.
41 | *
42 | * | Visa | MC | ECI |
43 | *
44 | *
45 | * 5 | 2 | Fully secure, card holder enrolled |
46 | *
47 | *
48 | * 6 | 1 | Merchant secure, card holder not enrolled or attempt ACS server was used |
49 | *
50 | *
51 | * 7 | 0 | Transaction not secure |
52 | *
53 | *
54 | */
55 | @XmlElement(name = "eci")
56 | private String eci;
57 |
58 | /**
59 | * Getter for the CAVV.
60 | *
61 | * @return the cavv
62 | */
63 | public String getCavv() {
64 | return cavv;
65 | }
66 |
67 | /**
68 | * Setter for the CAVV.
69 | *
70 | * @param cavv the cavv to set
71 | */
72 | public void setCavv(String cavv) {
73 | this.cavv = cavv;
74 | }
75 |
76 | /**
77 | * Getter for the XID.
78 | *
79 | * @return the xid
80 | */
81 | public String getXid() {
82 | return xid;
83 | }
84 |
85 | /**
86 | * Setter for the XID.
87 | *
88 | * @param xid the xid to set
89 | */
90 | public void setXid(String xid) {
91 | this.xid = xid;
92 | }
93 |
94 | /**
95 | * Getter for the ECI.
96 | *
97 | * @return the eci
98 | */
99 | public String getEci() {
100 | return eci;
101 | }
102 |
103 | /**
104 | * Setter for the ECI.
105 | *
106 | * @param eci the eci to set
107 | */
108 | public void setEci(String eci) {
109 | this.eci = eci;
110 | }
111 |
112 | /**
113 | * Helper method for adding the CAVV.
114 | *
115 | * @param cavv
116 | * @return Mpi
117 | */
118 | public Mpi addCavv(String cavv) {
119 | this.cavv = cavv;
120 | return this;
121 | }
122 |
123 | /**
124 | * Helper method for adding the xid.
125 | *
126 | * @param xid
127 | * @return Mpi
128 | */
129 | public Mpi addXid(String xid) {
130 | this.xid = xid;
131 | return this;
132 | }
133 |
134 | /**
135 | * Helper method for adding the ECI.
136 | *
137 | * @param eci
138 | * @return Mpi
139 | */
140 | public Mpi addEci(String eci) {
141 | this.eci = eci;
142 | return this;
143 | }
144 |
145 | }
146 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/ReasonCode.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | /**
4 | * Created by alessandro on 07/06/2016.
5 | */
6 | public enum ReasonCode {
7 |
8 | // @formatter:off
9 | FRAUD("FRAUD"),
10 | OUT_OF_STOCK("OUTOFSTOCK"),
11 | OTHER("OTHER"),
12 | FALSE_POSITIVE("FALSEPOSITIVE"),
13 | IN_STOCK("INSTOCK"),
14 | NOT_GIVEN("NOTGIVEN");
15 | // @formatter:on
16 |
17 | /**
18 | * The card type.
19 | */
20 | private String reason;
21 |
22 | /**
23 | * Constructor for enum.
24 | * @param reason
25 | */
26 | ReasonCode(String reason) {
27 | this.reason = reason;
28 | }
29 |
30 | /**
31 | * Getter for reason type.
32 | *
33 | * @return String
34 | */
35 | public String getType() {
36 | return this.reason;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/Recurring.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlAttribute;
6 |
7 | /**
8 | *
9 | * If you are configured for recurring/continuous authority transactions, you must set the recurring values.
10 | *
11 | *
12 | *
13 | * Helper methods are provided (prefixed with 'add') for object creation.
14 | *
15 | *
16 | * Recurring recurring = new Recurring().addFlag(RecurringFlag.ONE).addSequence(RecurringSequence.FIRST).addType(RecurringType.FIXED);
17 | *
18 | *
19 | * @author markstanford
20 | *
21 | */
22 | @XmlAccessorType(XmlAccessType.FIELD)
23 | public class Recurring {
24 |
25 | /**
26 | * Enum for recurring type. Type can be either fixed or variable depending on whether you will be changing
27 | * the amounts or not.
28 | */
29 | public enum RecurringType {
30 | NONE(""),
31 | VARIABLE("variable"),
32 | FIXED("fixed");
33 |
34 | /**
35 | * The type value
36 | */
37 | private String type;
38 |
39 | /**
40 | * Constructor for enum.
41 | *
42 | * @param type
43 | */
44 | RecurringType(String type) {
45 | this.type = type;
46 | }
47 |
48 | /**
49 | * Returns String value for the type
50 | *
51 | * @return String
52 | */
53 | public String getType() {
54 | return this.type;
55 | }
56 | }
57 |
58 | /**
59 | * Enumeration representing the recurring sequence. Must be first for the first transaction for this card,
60 | * subsequent for transactions after that, and last for the final transaction of the set.
61 | * Only supported by some acquirers.
62 | */
63 | public enum RecurringSequence {
64 | NONE(""),
65 | FIRST("first"),
66 | SUBSEQUENT("subsequent"),
67 | LAST("last");
68 |
69 | /**
70 | * The sequence value
71 | */
72 | private String sequence;
73 |
74 | /**
75 | * Constructor for enum.
76 | *
77 | * @param sequence
78 | */
79 | RecurringSequence(String sequence) {
80 | this.sequence = sequence;
81 | }
82 |
83 | /**
84 | * Returns String value for sequence
85 | *
86 | * @return String
87 | */
88 | public String getSequence() {
89 | return this.sequence;
90 | }
91 |
92 | }
93 |
94 | /**
95 | * Enumeration representing the recurring flag.
96 | */
97 | public enum RecurringFlag {
98 | NONE(""),
99 | ZERO("0"),
100 | ONE("1"),
101 | TWO("2");
102 |
103 | /**
104 | * The flag value
105 | */
106 | private String recurringFlag;
107 |
108 | /**
109 | * The RecurringFlag constructor
110 | *
111 | * @param recurringFlag
112 | */
113 | RecurringFlag(String recurringFlag) {
114 | this.recurringFlag = recurringFlag;
115 | }
116 |
117 | /**
118 | * Getter for the flag value
119 | *
120 | * @return String
121 | */
122 | public String getRecurringFlag() {
123 | return this.recurringFlag;
124 | }
125 | }
126 |
127 | /**
128 | * Type can be either fixed or variable depending on whether you will be changing the amounts or not.
129 | */
130 | @XmlAttribute(name = "type")
131 | private String type;
132 |
133 | /**
134 | * The recurring sequence. Must be first for the first transaction for this card,
135 | * subsequent for transactions after that, and last for the final transaction of the set.
136 | * Only supported by some acquirers.
137 | */
138 | @XmlAttribute(name = "sequence")
139 | private String sequence;
140 |
141 | /**
142 | * The recurring flag. Optional field taking values 0, 1 or 2.
143 | */
144 | @XmlAttribute(name = "flag")
145 | private String flag;
146 |
147 | /**
148 | * Getter for the type
149 | *
150 | * @return String
151 | */
152 | public String getType() {
153 | return this.type;
154 | }
155 |
156 | /**
157 | * Setter for the type
158 | *
159 | * @param type
160 | */
161 | public void setType(String type) {
162 | this.type = type;
163 | }
164 |
165 | /**
166 | * Getter for the sequence
167 | *
168 | * @return String
169 | */
170 | public String getSequence() {
171 | return this.sequence;
172 | }
173 |
174 | /**
175 | * Setter for the sequence
176 | *
177 | * @param sequence
178 | */
179 | public void setSequence(String sequence) {
180 | this.sequence = sequence;
181 | }
182 |
183 | /**
184 | * Getter for the flag
185 | *
186 | * @return String
187 | */
188 | public String getFlag() {
189 | return this.flag;
190 | }
191 |
192 | /**
193 | * Setter for the flag
194 | *
195 | * @param flag
196 | */
197 | public void setFlag(String flag) {
198 | this.flag = flag;
199 | }
200 |
201 | /**
202 | * Helper method for adding a type
203 | *
204 | * @param type
205 | */
206 | public Recurring addType(String type) {
207 | this.type = type;
208 | return this;
209 | }
210 |
211 | /**
212 | * Helper method for adding a type
213 | *
214 | * @param type
215 | */
216 | public Recurring addType(RecurringType type) {
217 | this.type = type.getType();
218 | return this;
219 | }
220 |
221 | /**
222 | * Helper method for adding a sequence
223 | *
224 | * @param sequence
225 | */
226 | public Recurring addSequence(RecurringSequence sequence) {
227 | this.sequence = sequence.getSequence();
228 | return this;
229 | }
230 |
231 | /**
232 | * Helper method for adding a sequence
233 | *
234 | * @param sequence
235 | * @return Recurring
236 | */
237 | public Recurring addSequence(String sequence) {
238 | this.sequence = sequence;
239 | return this;
240 | }
241 |
242 | /**
243 | * Helper method for adding a flag
244 | *
245 | * @param flag
246 | * @return Recurring
247 | */
248 | public Recurring addFlag(RecurringFlag flag) {
249 | this.flag = flag.getRecurringFlag();
250 | return this;
251 | }
252 |
253 | /**
254 | * Helper method for adding a flag
255 | *
256 | * @param flag
257 | * @return Recurring
258 | */
259 | public Recurring addFlag(String flag) {
260 | this.flag = flag;
261 | return this;
262 | }
263 | }
264 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/TransactionSequence.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlElement;
6 |
7 | /**
8 | *
9 | * Domain object representing transaction sequence information.
10 | *
11 | *
12 | *
13 | * TransactionSequence sequence = new TransactionSequence();
14 | * sequence.setCardHolderCurrency(finalTransactionIndicator);
15 | *
16 | *
17 | *
18 | */
19 | @XmlAccessorType(XmlAccessType.FIELD)
20 | public class TransactionSequence {
21 |
22 | /**
23 | * Attribute wrapper that indicates whether this is the final capture or not
24 | */
25 | @XmlElement(name = "final")
26 | private FinalTransactionIndicator finalTransactionIndicator;
27 |
28 | /**
29 | * Constructor for TransactionSequence.
30 | */
31 | public TransactionSequence() {
32 | }
33 |
34 | /**
35 | * Getter for finalTransactionIndicator.
36 | */
37 | public FinalTransactionIndicator getFinalTransactionIndicator() {
38 | return finalTransactionIndicator;
39 | }
40 |
41 | /**
42 | * Setter for finalTransactionIndicator.
43 | */
44 | public void setFinalTransactionIndicator(final FinalTransactionIndicator finalTransactionIndicator) {
45 | this.finalTransactionIndicator = finalTransactionIndicator;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/TssInfo.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import javax.xml.bind.annotation.XmlAccessType;
7 | import javax.xml.bind.annotation.XmlAccessorType;
8 | import javax.xml.bind.annotation.XmlElement;
9 | import javax.xml.bind.annotation.XmlElements;
10 |
11 | /**
12 | *
13 | * Domain object representing TSS (realscore) information to be passed to Realex.
14 | * Realscore is a real time transaction screening and data checking system to assist a merchant
15 | * with the identification of potentially high-risk transactions.
16 | *
17 | *
18 | *
19 | * TssInfo tssInfo = new TssInfo()
20 | * .addCustomerNumber("customer number")
21 | * .addProductId("product ID")
22 | * .addVariableReference("variable ref")
23 | * .addCustomerIpAddress("127.0.0.1")
24 | * .addAddress(
25 | * new Address()
26 | * .addType("billing")
27 | * .addCode("12|123")
28 | * .addCountry("IE"))
29 | * .addAddress(
30 | * new Address()
31 | * .addType("shipping")
32 | * .addCountry("GB"));
33 | *
34 | *
35 | * @author markstanford
36 | *
37 | */
38 | @XmlAccessorType(XmlAccessType.FIELD)
39 | public class TssInfo {
40 |
41 | /**
42 | * The number you assign to the customer. This can allow checking of previous transactions by this customer.
43 | */
44 | @XmlElement(name = "custnum")
45 | private String customerNumber;
46 |
47 | /**
48 | * The product code you assign to the product.
49 | */
50 | @XmlElement(name = "prodid")
51 | private String productId;
52 |
53 | /**
54 | * Any reference you also would like to assign to the customer. This can allow checking, using realscore, of previous
55 | * transactions by this customer.
56 | */
57 | @XmlElement(name = "varref")
58 | private String variableReference;
59 |
60 | /**
61 | * The IP address of the customer.
62 | */
63 | @XmlElement(name = "custipaddress")
64 | private String customerIpAddress;
65 |
66 | /**
67 | * The address of the customer.
68 | */
69 | @XmlElements(@XmlElement(name = "address", type = Address.class))
70 | private List addresses;
71 |
72 | /**
73 | * Getter for customer number.
74 | *
75 | * @return String
76 | */
77 | public String getCustomerNumber() {
78 | return customerNumber;
79 | }
80 |
81 | /**
82 | * Setter for customer number.
83 | *
84 | * @param customerNumber
85 | */
86 | public void setCustomerNumber(String customerNumber) {
87 | this.customerNumber = customerNumber;
88 | }
89 |
90 | /**
91 | * Getter for product ID.
92 | *
93 | * @return String
94 | */
95 | public String getProductId() {
96 | return productId;
97 | }
98 |
99 | /**
100 | * Setter for product ID.
101 | *
102 | * @param productId
103 | */
104 | public void setProductId(String productId) {
105 | this.productId = productId;
106 | }
107 |
108 | /**
109 | * Getter for variable reference.
110 | *
111 | * @return String
112 | */
113 | public String getVariableReference() {
114 | return variableReference;
115 | }
116 |
117 | /**
118 | * Setter for variable reference.
119 | *
120 | * @param variableReference
121 | */
122 | public void setVariableReference(String variableReference) {
123 | this.variableReference = variableReference;
124 | }
125 |
126 | /**
127 | * Getter for customer IP address.
128 | *
129 | * @return String
130 | */
131 | public String getCustomerIpAddress() {
132 | return customerIpAddress;
133 | }
134 |
135 | /**
136 | * Setter for customer IP address.
137 | *
138 | * @param customerIpAddress
139 | */
140 | public void setCustomerIpAddress(String customerIpAddress) {
141 | this.customerIpAddress = customerIpAddress;
142 | }
143 |
144 | /**
145 | * Getter for addresses.
146 | *
147 | * @return String
148 | */
149 | public List getAddresses() {
150 | return addresses;
151 | }
152 |
153 | /**
154 | * Setter for address list.
155 | *
156 | * @param addresses
157 | */
158 | public void setAddresses(List addresses) {
159 | this.addresses = addresses;
160 | }
161 |
162 | /**
163 | * Helper method for adding a customer number.
164 | *
165 | * @param customerNumber
166 | * @return TssInfo
167 | */
168 | public TssInfo addCustomerNumber(String customerNumber) {
169 | this.customerNumber = customerNumber;
170 | return this;
171 | }
172 |
173 | /**
174 | * Helper method for adding a product ID.
175 | *
176 | * @param productId
177 | * @return TssInfo
178 | */
179 | public TssInfo addProductId(String productId) {
180 | this.productId = productId;
181 | return this;
182 | }
183 |
184 | /**
185 | * Helper method for adding a variable reference.
186 | *
187 | * @param variableReference
188 | * @return TssInfo
189 | */
190 | public TssInfo addVariableReference(String variableReference) {
191 | this.variableReference = variableReference;
192 | return this;
193 | }
194 |
195 | /**
196 | * Helper method for adding a customer IP address.
197 | *
198 | * @param customerIpAddress
199 | * @return TssInfo
200 | */
201 | public TssInfo addCustomerIpAddress(String customerIpAddress) {
202 | this.customerIpAddress = customerIpAddress;
203 | return this;
204 | }
205 |
206 | /**
207 | * Helper method for adding an address.
208 | *
209 | * @param address
210 | * @return TssInfo
211 | */
212 | public TssInfo addAddress(Address address) {
213 | if (null == this.addresses) {
214 | this.addresses = new ArrayList();
215 | }
216 | this.addresses.add(address);
217 | return this;
218 | }
219 |
220 | }
221 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/TssResult.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | import java.util.List;
4 |
5 | import javax.xml.bind.annotation.XmlAccessType;
6 | import javax.xml.bind.annotation.XmlAccessorType;
7 | import javax.xml.bind.annotation.XmlElement;
8 | import javax.xml.bind.annotation.XmlElements;
9 |
10 | /**
11 | * The results of realscore checks.
12 | *
13 | * @author markstanford
14 | *
15 | */
16 | @XmlAccessorType(XmlAccessType.FIELD)
17 | public class TssResult {
18 |
19 | /**
20 | * The weighted total score of realscore. The weights can be adjusted in the realcontrol application.
21 | */
22 | @XmlElement(name = "result")
23 | private String result;
24 |
25 | /**
26 | * The list of realscore check results.
27 | */
28 | @XmlElements(@XmlElement(name = "check", type = TssResultCheck.class))
29 | private List checks;
30 |
31 | /**
32 | * Getter for realscore result.
33 | *
34 | * @return String
35 | */
36 | public String getResult() {
37 | return result;
38 | }
39 |
40 | /**
41 | * Setter for realscore result.
42 | *
43 | * @param result
44 | */
45 | public void setResult(String result) {
46 | this.result = result;
47 | }
48 |
49 | /**
50 | * Getter for realscore checks.
51 | *
52 | * @return List
53 | */
54 | public List getChecks() {
55 | return checks;
56 | }
57 |
58 | /**
59 | * Setter for realscore checks.
60 | *
61 | * @param checks
62 | */
63 | public void setChecks(List checks) {
64 | this.checks = checks;
65 | }
66 |
67 | /**
68 | * Convert to string representation
69 | *
70 | * @return string representation in format of :-;-;...
71 | */
72 | @Override
73 | public String toString() {
74 |
75 | StringBuffer result = new StringBuffer(this.getResult());
76 | result.append(":");
77 | for (TssResultCheck check : this.getChecks()) {
78 | result.append(check.getId());
79 | result.append("-");
80 | result.append(check.getValue());
81 | result.append(";");
82 | }
83 | return result.toString();
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/payment/TssResultCheck.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlAttribute;
6 | import javax.xml.bind.annotation.XmlValue;
7 |
8 | /**
9 | * Domain object representing the results of an individual realscore check.
10 | *
11 | * @author markstanford
12 | *
13 | */
14 | @XmlAccessorType(XmlAccessType.FIELD)
15 | public class TssResultCheck {
16 |
17 | /**
18 | * The ID of the realscore check
19 | */
20 | @XmlAttribute(name = "id")
21 | private String id;
22 |
23 | /**
24 | * The value of the realscore check
25 | */
26 | @XmlValue
27 | private String value;
28 |
29 | /**
30 | * Getter for check ID.
31 | *
32 | * @return String
33 | */
34 | public String getId() {
35 | return id;
36 | }
37 |
38 | /**
39 | * Setter for check ID.
40 | *
41 | * @param id
42 | */
43 | public void setId(String id) {
44 | this.id = id;
45 | }
46 |
47 | /**
48 | * Getter for check value.
49 | *
50 | * @return String
51 | */
52 | public String getValue() {
53 | return value;
54 | }
55 |
56 | /**
57 | * Setter for check value.
58 | *
59 | * @param value
60 | */
61 | public void setValue(String value) {
62 | this.value = value;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/threeDSecure/ThreeDSecure.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.threeDSecure;
2 |
3 | import javax.xml.bind.annotation.XmlAccessType;
4 | import javax.xml.bind.annotation.XmlAccessorType;
5 | import javax.xml.bind.annotation.XmlElement;
6 |
7 | /**
8 | *
9 | * Domain object representing 3D Secure (realmpi) information passed back from Realex.
10 | * Realmpi is a real time card holder verification system to assist a merchant with the
11 | * identification of potentially fraudulent transactions.
12 | *
13 | *
14 | * @author thomasduffy
15 | *
16 | */
17 | @XmlAccessorType(XmlAccessType.FIELD)
18 | public class ThreeDSecure {
19 |
20 | /**
21 | * The outcome of the authentication, required for the authorisation request.
22 | */
23 | @XmlElement(name = "status")
24 | private String status;
25 |
26 | /**
27 | * The e-commerce indicator, required for the authorisation request.
28 | */
29 | @XmlElement(name = "eci")
30 | private String eci;
31 |
32 | /**
33 | * The XID field, required for the authorisation request.
34 | */
35 | @XmlElement(name = "xid")
36 | private String xid;
37 |
38 | /**
39 | * The CAVV or UCAF, required for the authorisation request.
40 | */
41 | @XmlElement(name = "cavv")
42 | private String cavv;
43 |
44 | /**
45 | * The address of the customer.
46 | */
47 | @XmlElement(name = "algorithm")
48 | private String algorithm;
49 |
50 | /**
51 | * Getter for the status.
52 | *
53 | * @return the status
54 | */
55 | public String getStatus() {
56 | return status;
57 | }
58 |
59 | /**
60 | * Setter for the status.
61 | *
62 | * @param status the status to set
63 | */
64 | public void setStatus(String status) {
65 | this.status = status;
66 | }
67 |
68 | /**
69 | * Getter for the ECI.
70 | *
71 | * @return the eci
72 | */
73 | public String getEci() {
74 | return eci;
75 | }
76 |
77 | /**
78 | * Setter for the ECI.
79 | *
80 | * @param eci the eci to set
81 | */
82 | public void setEci(String eci) {
83 | this.eci = eci;
84 | }
85 |
86 | /**
87 | * Getter for the XID.
88 | *
89 | * @return the xid
90 | */
91 | public String getXid() {
92 | return xid;
93 | }
94 |
95 | /**
96 | * Setter for the XID.
97 | *
98 | * @param xid the xid to set
99 | */
100 | public void setXid(String xid) {
101 | this.xid = xid;
102 | }
103 |
104 | /**
105 | * Getter for the CAVV.
106 | *
107 | * @return the cavv
108 | */
109 | public String getCavv() {
110 | return cavv;
111 | }
112 |
113 | /**
114 | * Setter for the CAVV.
115 | *
116 | * @param cavv the cavv to set
117 | */
118 | public void setCavv(String cavv) {
119 | this.cavv = cavv;
120 | }
121 |
122 | /**
123 | * Getter for the algorithm.
124 | *
125 | * @return the algorithm
126 | */
127 | public String getAlgorithm() {
128 | return algorithm;
129 | }
130 |
131 | /**
132 | * Setter for the algorithm.
133 | *
134 | * @param algorithm the algorithm to set
135 | */
136 | public void setAlgorithm(String algorithm) {
137 | this.algorithm = algorithm;
138 | }
139 |
140 | /**
141 | * Helper method for adding the status.
142 | *
143 | * @param status
144 | * @return ThreeDSecure
145 | */
146 | public ThreeDSecure addStatus(String status) {
147 | this.status = status;
148 | return this;
149 | }
150 |
151 | /**
152 | * Helper method for adding the ECI.
153 | *
154 | * @param eci
155 | * @return ThreeDSecure
156 | */
157 | public ThreeDSecure addEci(String eci) {
158 | this.eci = eci;
159 | return this;
160 | }
161 |
162 | /**
163 | * Helper method for adding the XID.
164 | *
165 | * @param xid
166 | * @return ThreeDSecure
167 | */
168 | public ThreeDSecure addXid(String xid) {
169 | this.xid = xid;
170 | return this;
171 | }
172 |
173 | /**
174 | * Helper method for adding the CAVV/UCAF.
175 | *
176 | * @param cavv
177 | * @return ThreeDSecure
178 | */
179 | public ThreeDSecure addCavv(String cavv) {
180 | this.cavv = cavv;
181 | return this;
182 | }
183 |
184 | /**
185 | * Helper method to add the algorithm.
186 | *
187 | * @param algorithm
188 | * @return ThreeDSecure
189 | */
190 | public ThreeDSecure addAlgorithm(String algorithm) {
191 | this.algorithm = algorithm;
192 | return this;
193 | }
194 |
195 | }
196 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/domain/threeDSecure/ThreeDSecureResponse.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.threeDSecure;
2 |
3 | import java.io.StringReader;
4 |
5 | import javax.xml.bind.annotation.XmlAccessType;
6 | import javax.xml.bind.annotation.XmlAccessorType;
7 | import javax.xml.bind.annotation.XmlAttribute;
8 | import javax.xml.bind.annotation.XmlElement;
9 | import javax.xml.bind.annotation.XmlRootElement;
10 | import javax.xml.transform.Source;
11 | import javax.xml.transform.stream.StreamSource;
12 |
13 | import com.realexpayments.remote.sdk.domain.Response;
14 | import com.realexpayments.remote.sdk.utils.GenerationUtils;
15 | import com.realexpayments.remote.sdk.utils.ResponseUtils;
16 | import com.realexpayments.remote.sdk.utils.XmlUtils;
17 | import com.realexpayments.remote.sdk.utils.XmlUtils.MessageType;
18 |
19 | /**
20 | *
21 | * Class representing a 3DSecure response received from Realex.
22 | *
23 | *
24 | * @author markstanford
25 | *
26 | */
27 | @XmlRootElement(name = "response")
28 | @XmlAccessorType(XmlAccessType.FIELD)
29 | public class ThreeDSecureResponse implements Response {
30 |
31 | /**
32 | * Time stamp in the format YYYYMMDDHHMMSS, which represents the time in the format year
33 | * month date hour minute second.
34 | */
35 | @XmlAttribute(name = "timestamp")
36 | private String timeStamp;
37 |
38 | /**
39 | * Represents Realex Payments assigned merchant id.
40 | */
41 | @XmlElement(name = "merchantid")
42 | private String merchantId;
43 |
44 | /**
45 | * Represents the Realex Payments subaccount to use. If you omit this element then we will use your default account.
46 | */
47 | @XmlElement(name = "account")
48 | private String account;
49 |
50 | /**
51 | * Represents the unique order id of this transaction. Must be unique across all of your accounts.
52 | */
53 | @XmlElement(name = "orderid")
54 | private String orderId;
55 |
56 | /**
57 | * The result codes returned by the Realex Payments system.
58 | */
59 | @XmlElement(name = "result")
60 | private String result;
61 |
62 | /**
63 | * If successful an authcode is returned from the bank. Used when referencing this transaction in refund and void requests.
64 | */
65 | @XmlElement(name = "authcode")
66 | private String authCode;
67 |
68 | /**
69 | * The text of the response.
70 | */
71 | @XmlElement(name = "message")
72 | private String message;
73 |
74 | /**
75 | * The Realex payments reference (pasref) for the transaction. Used when referencing this transaction in refund and void requests.
76 | */
77 | @XmlElement(name = "pasref")
78 | private String paymentsReference;
79 |
80 | /**
81 | * The time taken.
82 | */
83 | @XmlElement(name = "timetaken")
84 | private Long timeTaken;
85 |
86 | /**
87 | * The AUTH time taken.
88 | */
89 | @XmlElement(name = "authtimetaken")
90 | private Long authTimeTaken;
91 |
92 | /**
93 | * The pre-encoded PaReq that you must post to the Issuer's ACS url.
94 | */
95 | @XmlElement(name = "pareq")
96 | private String pareq;
97 |
98 | /**
99 | * The URL of the Issuer ACS.
100 | */
101 | @XmlElement(name = "url")
102 | private String url;
103 |
104 | /**
105 | * Enrolment response from ACS.
106 | */
107 | @XmlElement(name = "enrolled")
108 | private String enrolled;
109 |
110 | /**
111 | * XID from ACS.
112 | */
113 | @XmlElement(name = "xid")
114 | private String xid;
115 |
116 | /**
117 | * The 3D Secure details.
118 | */
119 | @XmlElement(name = "threedsecure")
120 | private ThreeDSecure threeDSecure;
121 |
122 | /**
123 | * The SHA-1 hash of certain elements of the response. The details of this are to be found in the realmpi developer's guide.
124 | */
125 | @XmlElement(name = "sha1hash")
126 | private String hash;
127 |
128 | /**
129 | * ThreeDSecureResponse constructor.
130 | */
131 | public ThreeDSecureResponse() {
132 | }
133 |
134 | /**
135 | * Getter for time stamp.
136 | *
137 | * @return String
138 | */
139 | @Override
140 | public String getTimeStamp() {
141 | return timeStamp;
142 | }
143 |
144 | /**
145 | * Setter for time stamp.
146 | *
147 | * @param timeStamp
148 | */
149 | public void setTimeStamp(String timeStamp) {
150 | this.timeStamp = timeStamp;
151 | }
152 |
153 | /**
154 | * Getter for merchant ID.
155 | *
156 | * @return String
157 | */
158 | public String getMerchantId() {
159 | return merchantId;
160 | }
161 |
162 | /**
163 | * Setter for merchant ID.
164 | *
165 | * @param merchantId
166 | */
167 | public void setMerchantId(String merchantId) {
168 | this.merchantId = merchantId;
169 | }
170 |
171 | /**
172 | * Setter for account.
173 | *
174 | * @return String
175 | */
176 | public String getAccount() {
177 | return account;
178 | }
179 |
180 | /**
181 | * Setter for account.
182 | *
183 | * @param account
184 | */
185 | public void setAccount(String account) {
186 | this.account = account;
187 | }
188 |
189 | /**
190 | * Getter for order ID.
191 | *
192 | * @return String
193 | */
194 | @Override
195 | public String getOrderId() {
196 | return orderId;
197 | }
198 |
199 | /**
200 | * Setter for order ID.
201 | *
202 | * @param orderId
203 | */
204 | public void setOrderId(String orderId) {
205 | this.orderId = orderId;
206 | }
207 |
208 | /**
209 | * Getter for result.
210 | *
211 | * @return String
212 | */
213 | @Override
214 | public String getResult() {
215 | return result;
216 | }
217 |
218 | /**
219 | * Setter for result.
220 | *
221 | * @param result
222 | */
223 | public void setResult(String result) {
224 | this.result = result;
225 | }
226 |
227 | /**
228 | * Getter for auth code.
229 | *
230 | * @return String
231 | */
232 | public String getAuthCode() {
233 | return authCode;
234 | }
235 |
236 | /**
237 | * Setter for auth code.
238 | *
239 | * @param authCode
240 | */
241 | public void setAuthCode(String authCode) {
242 | this.authCode = authCode;
243 | }
244 |
245 | /**
246 | * Getter for message.
247 | *
248 | * @return String
249 | */
250 | @Override
251 | public String getMessage() {
252 | return message;
253 | }
254 |
255 | /**
256 | * Setter for message.
257 | *
258 | * @param message
259 | */
260 | public void setMessage(String message) {
261 | this.message = message;
262 | }
263 |
264 | /**
265 | * Getter for payments reference.
266 | *
267 | * @return paymentsReference
268 | */
269 | public String getPaymentsReference() {
270 | return paymentsReference;
271 | }
272 |
273 | /**
274 | * Setter for payments reference.
275 | *
276 | * @param paymentsReference
277 | */
278 | public void setPaymentsReference(String paymentsReference) {
279 | this.paymentsReference = paymentsReference;
280 | }
281 |
282 | /**
283 | * Getter for time taken.
284 | *
285 | * @return Long
286 | */
287 | public Long getTimeTaken() {
288 | return timeTaken;
289 | }
290 |
291 | /**
292 | * Setter for time taken.
293 | *
294 | * @param timeTaken
295 | */
296 | public void setTimeTaken(Long timeTaken) {
297 | this.timeTaken = timeTaken;
298 | }
299 |
300 | /**
301 | * Getter for AUTH time taken.
302 | *
303 | * @return Long
304 | */
305 | public Long getAuthTimeTaken() {
306 | return authTimeTaken;
307 | }
308 |
309 | /**
310 | * Setter for AUTH time taken.
311 | *
312 | * @param authTimeTaken
313 | */
314 | public void setAuthTimeTaken(Long authTimeTaken) {
315 | this.authTimeTaken = authTimeTaken;
316 | }
317 |
318 | /**
319 | * Getter for PAReq.
320 | *
321 | * @return String
322 | */
323 | public String getPareq() {
324 | return pareq;
325 | }
326 |
327 | /**
328 | * Setter for PAReq.
329 | *
330 | * @param pareq
331 | */
332 | public void setPareq(String pareq) {
333 | this.pareq = pareq;
334 | }
335 |
336 | /**
337 | * Getter for ACS URL.
338 | *
339 | * @return String
340 | */
341 | public String getUrl() {
342 | return url;
343 | }
344 |
345 | /**
346 | * Setter for ACS URL.
347 | *
348 | * @param url
349 | */
350 | public void setUrl(String url) {
351 | this.url = url;
352 | }
353 |
354 | /**
355 | * Getter for enrolled.
356 | *
357 | * @return String
358 | */
359 | public String getEnrolled() {
360 | return enrolled;
361 | }
362 |
363 | /**
364 | * Setter for enrolled.
365 | *
366 | * @param enrolled
367 | */
368 | public void setEnrolled(String enrolled) {
369 | this.enrolled = enrolled;
370 | }
371 |
372 | /**
373 | * Getter for XID.
374 | *
375 | * @return String
376 | */
377 | public String getXid() {
378 | return xid;
379 | }
380 |
381 | /**
382 | * Setter for XID.
383 | *
384 | * @param xid
385 | */
386 | public void setXid(String xid) {
387 | this.xid = xid;
388 | }
389 |
390 | /**
391 | * Getter for the 3D Secure details.
392 | *
393 | * @return threeDSecure
394 | */
395 | public ThreeDSecure getThreeDSecure() {
396 | return threeDSecure;
397 | }
398 |
399 | /**
400 | * Setter for the 3D Secure details.
401 | *
402 | * @param threeDSecure the threeDSecure to set
403 | */
404 | public void setThreeDSecure(ThreeDSecure threeDSecure) {
405 | this.threeDSecure = threeDSecure;
406 | }
407 |
408 | /**
409 | * Getter for SHA1 hash.
410 | *
411 | * @return String
412 | */
413 | public String getHash() {
414 | return hash;
415 | }
416 |
417 | /**
418 | * Setter for SHA1 hash.
419 | *
420 | * @param hash
421 | */
422 | public void setHash(String hash) {
423 | this.hash = hash;
424 | }
425 |
426 | /**
427 | * {@inheritDoc}
428 | */
429 | @Override
430 | public ThreeDSecureResponse fromXml(Source xml) {
431 | return (ThreeDSecureResponse) XmlUtils.fromXml(xml, MessageType.THREE_D_SECURE);
432 | }
433 |
434 | /**
435 | * Helper method which unmarshals the passed XML to a ThreeDSecureResponse object.
436 | *
437 | * @param xml
438 | * @return ThreeDSecureResponse
439 | */
440 | public ThreeDSecureResponse fromXml(String xml) {
441 | return fromXml(new StreamSource(new StringReader(xml)));
442 | }
443 |
444 | /**
445 | * {@inheritDoc}
446 | */
447 | @Override
448 | public String toXml() {
449 | return XmlUtils.toXml(this, MessageType.THREE_D_SECURE);
450 | }
451 |
452 | /**
453 | *
454 | * {@inheritDoc}
455 | */
456 | @Override
457 | public boolean isHashValid(String secret) {
458 |
459 | boolean hashValid = false;
460 |
461 | //check for any null values and set them to empty string for hashing
462 | String timeStamp = null == this.timeStamp ? "" : this.timeStamp;
463 | String merchantId = null == this.merchantId ? "" : this.merchantId;
464 | String orderId = null == this.orderId ? "" : this.orderId;
465 | String result = null == this.result ? "" : this.result;
466 | String message = null == this.message ? "" : this.message;
467 | String paymentsReference = null == this.paymentsReference ? "" : this.paymentsReference;
468 | String authCode = null == this.authCode ? "" : this.authCode;
469 |
470 | //create String to hash
471 | String toHash = new StringBuilder().append(timeStamp)
472 | .append(".")
473 | .append(merchantId)
474 | .append(".")
475 | .append(orderId)
476 | .append(".")
477 | .append(result)
478 | .append(".")
479 | .append(message)
480 | .append(".")
481 | .append(paymentsReference)
482 | .append(".")
483 | .append(authCode)
484 | .toString();
485 |
486 | //check if calculated hash matches returned value
487 | String expectedHash = GenerationUtils.generateHash(toHash, secret);
488 | if (expectedHash.equals(this.hash)) {
489 | hashValid = true;
490 | }
491 |
492 | return hashValid;
493 | }
494 |
495 | /**
496 | *
497 | * {@inheritDoc}
498 | */
499 | @Override
500 | public boolean isSuccess() {
501 | return ResponseUtils.isSuccess(this);
502 | }
503 |
504 | }
505 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/http/HttpConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.http;
2 |
3 | /**
4 | * Object containing all configurable HTTP settings.
5 | */
6 | public class HttpConfiguration {
7 |
8 | /**
9 | * The default endpoint for all requests
10 | */
11 | private static final String DEFAULT_ENDPOINT = "https://api.realexpayments.com/epage-remote.cgi";
12 |
13 | /**
14 | * The default timeout in milliseconds.
15 | */
16 | private static final int DEFAULT_TIMEOUT = 65000;
17 |
18 | /** The URL of the Realex service. */
19 | private String endpoint;
20 |
21 | /** The timeout, in milli-seconds, for sending a request to Realex. */
22 | private int timeout;
23 |
24 | /** Whether only HTTPS is allowed for the endpoint. */
25 | private boolean onlyAllowHttps = true;
26 |
27 | /* Constructors/Getters/Setters */
28 |
29 | /**
30 | * Create a HttpConfiguration object with all defaults in place.
31 | *
32 | */
33 | public HttpConfiguration() {
34 | // Set defaults
35 | this.endpoint = DEFAULT_ENDPOINT;
36 | this.timeout = DEFAULT_TIMEOUT;
37 | }
38 |
39 | /**
40 | * Get the endpoint/destination for the request.
41 | *
42 | * @return the endpoint
43 | */
44 | public String getEndpoint() {
45 | return endpoint;
46 | }
47 |
48 | /**
49 | * Set the endpoint/destination for the request.
50 | *
51 | * @param endpoint the endpoint to set
52 | */
53 | public void setEndpoint(String endpoint) {
54 | this.endpoint = endpoint;
55 | }
56 |
57 | /**
58 | * The timeout for a request to Realex.
59 | *
60 | * @return the timeout
61 | */
62 | public int getTimeout() {
63 | return timeout;
64 | }
65 |
66 | /**
67 | * Set the timeout, in milli-seconds, for sending a request to Realex.
68 | *
69 | * @param timeout the timeout to set
70 | */
71 | public void setTimeout(int timeout) {
72 | this.timeout = timeout;
73 | }
74 |
75 | /**
76 | * Check is HTTPS the only allowed scheme (protocol) to the endpoint.
77 | * @return the onlyAllowHttps
78 | */
79 | public boolean isOnlyAllowHttps() {
80 | return onlyAllowHttps;
81 | }
82 |
83 | /**
84 | * Set whether (true) or not (false) HTTPS is the only allowed scheme (protocol) to the endpoint.
85 | *
86 | * @param onlyAllowHttps the onlyAllowHttps to set
87 | */
88 | public void setOnlyAllowHttps(boolean onlyAllowHttps) {
89 | this.onlyAllowHttps = onlyAllowHttps;
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/http/HttpUtils.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.http;
2 |
3 | import java.io.Closeable;
4 | import java.io.IOException;
5 |
6 | import org.apache.http.ConnectionReuseStrategy;
7 | import org.apache.http.HttpHeaders;
8 | import org.apache.http.HttpResponse;
9 | import org.apache.http.HttpStatus;
10 | import org.apache.http.client.HttpClient;
11 | import org.apache.http.client.config.RequestConfig;
12 | import org.apache.http.client.methods.HttpPost;
13 | import org.apache.http.conn.HttpClientConnectionManager;
14 | import org.apache.http.entity.ContentType;
15 | import org.apache.http.entity.StringEntity;
16 | import org.apache.http.impl.NoConnectionReuseStrategy;
17 | import org.apache.http.impl.client.CloseableHttpClient;
18 | import org.apache.http.impl.client.HttpClients;
19 | import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
20 | import org.apache.http.util.EntityUtils;
21 | import org.slf4j.Logger;
22 | import org.slf4j.LoggerFactory;
23 |
24 | import com.realexpayments.remote.sdk.RealexException;
25 |
26 | /**
27 | * HTTP Utils class for dealing with HTTP and actual message sending.
28 | *
29 | * @author thomasduffy
30 | */
31 | public class HttpUtils {
32 |
33 | private final static String HTTPS_PROTOCOL = "https";
34 | private final static String UTF_8 = "UTF-8";
35 |
36 | private final static Logger logger = LoggerFactory.getLogger(HttpUtils.class);
37 |
38 | /**
39 | * Get a default HttpClient based on the HttpConfiguration object. If required the defaults can
40 | * be altered to meet the requirements of the SDK user. The default client does not use connection
41 | * pooling and does not reuse connections. Timeouts for connection and socket are taken from the
42 | * {@link HttpConfiguration} object.
43 | *
44 | * @param httpConfiguration
45 | * @return CloseableHttpClient
46 | */
47 | public static CloseableHttpClient getDefaultClient(HttpConfiguration httpConfiguration) {
48 |
49 | RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(httpConfiguration.getTimeout())
50 | .setSocketTimeout(httpConfiguration.getTimeout()).build();
51 |
52 | HttpClientConnectionManager connectionManager = new BasicHttpClientConnectionManager();
53 | ConnectionReuseStrategy connectionResuseStrategy = new NoConnectionReuseStrategy();
54 |
55 | logger.debug("Creating HttpClient with simple no pooling/no connection reuse default settings.");
56 | CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig).setConnectionManager(connectionManager)
57 | .setConnectionReuseStrategy(connectionResuseStrategy).build();
58 | return httpClient;
59 | }
60 |
61 | /**
62 | * Perform the actual send of the message, according to the HttpConfiguration, and get the response.
63 | * This will also check if only HTTPS is allowed, based on the {@link HttpConfiguration}, and will
64 | * throw a {@link RealexException} if HTTP is used when only HTTPS is allowed. A {@link RealexException}
65 | * is also thrown if the response from Realex is not success (ie. if it's not 200 status code).
66 | *
67 | *
68 | * @param xml
69 | * @param httpClient
70 | * @param httpConfiguration
71 | * @return the xml response
72 | */
73 | public static String sendMessage(String xml, HttpClient httpClient, HttpConfiguration httpConfiguration) {
74 |
75 | logger.debug("Setting endpoint of: " + httpConfiguration.getEndpoint());
76 | HttpPost httpPost = new HttpPost(httpConfiguration.getEndpoint());
77 | httpPost.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_XML.getMimeType());
78 | HttpResponse response = null;
79 |
80 | // Confirm protocol is HTTPS (ie. secure) if such is configured
81 | if (httpConfiguration.isOnlyAllowHttps()) {
82 | String scheme = httpPost.getURI().getScheme();
83 | if (!scheme.equalsIgnoreCase(HTTPS_PROTOCOL)) {
84 | logger.error("Protocol must be " + HTTPS_PROTOCOL);
85 | throw new RealexException("Protocol must be " + HTTPS_PROTOCOL);
86 | }
87 | } else {
88 | logger.warn("Allowed send message over HTTP. This should NEVER be allowed in a production environment.");
89 | }
90 |
91 | try {
92 | logger.debug("Setting entity in POST message.");
93 | httpPost.setEntity(new StringEntity(xml, UTF_8));
94 |
95 | logger.debug("Executing HTTP Post message to: " + httpPost.getURI());
96 | response = httpClient.execute(httpPost);
97 |
98 | logger.debug("Checking the HTTP response status code.");
99 | int statusCode = (response.getStatusLine().getStatusCode());
100 | if (statusCode != HttpStatus.SC_OK) {
101 | throw new RealexException("Unexpected http status code [" + statusCode + "]");
102 | }
103 |
104 | logger.debug("Converting HTTP entity (the xml response) back into a string.");
105 | String xmlResponse = EntityUtils.toString(response.getEntity());
106 | EntityUtils.consume(response.getEntity());
107 | return xmlResponse;
108 | } catch (IOException ioe) {
109 | // Also catches ClientProtocolException (from httpClient.execute()) and UnsupportedEncodingException (from response.getEntity()
110 | logger.error("Exception communicating with Realex.", ioe.getMessage());
111 | throw new RealexException("Exception communicating with Realex.", ioe);
112 | } finally {
113 | // Test if response Closeable
114 | if (response instanceof Closeable) {
115 | try {
116 | ((Closeable) response).close();
117 | } catch (IOException ioe) {
118 | // Ignore
119 | }
120 | }
121 | }
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/utils/CardValidationUtils.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.utils;
2 |
3 | import java.text.DateFormat;
4 | import java.text.ParseException;
5 | import java.text.SimpleDateFormat;
6 | import java.util.Calendar;
7 |
8 | import com.realexpayments.remote.sdk.domain.Card;
9 |
10 | /**
11 | * @author thomasduffy
12 | *
13 | */
14 | public class CardValidationUtils {
15 |
16 | private static final String EXPIRY_DATE_PATTERN = "MMyy";
17 | private static final String EXP_DATE_REG_EXP = "\\d\\d\\d\\d";
18 |
19 | /**
20 | * Method to perform a Luhn check on the card number. This allows the SDK user to perform
21 | * basic validation on the card number. The card number may contain whitespace or '-' which will
22 | * be stripped before validation.
23 | *
24 | * @param cardNumber
25 | *
26 | * @return true if a valid card number and false otherwise
27 | */
28 | public static boolean performLuhnCheck(String cardNumber) {
29 |
30 | if (cardNumber == null || cardNumber.equalsIgnoreCase("")) {
31 | return false;
32 | }
33 |
34 | /** If string has alpha characters it is not a valid credit card **/
35 | if (!cardNumber.matches("\\d*")) {
36 | return false;
37 | }
38 |
39 | /** Check length of credit card is valid (between 12 and 19 digits) **/
40 | int length = cardNumber.length();
41 | if (length < 12 || length > 19) {
42 | return false;
43 | }
44 |
45 | /** Perform luhn check **/
46 | int sum = 0;
47 | int digit = 0;
48 | int addend = 0;
49 | boolean timesTwo = false;
50 |
51 | for (int i = cardNumber.length() - 1; i >= 0; i--) {
52 | digit = Integer.parseInt(cardNumber.substring(i, i + 1));
53 | if (timesTwo) {
54 | addend = digit * 2;
55 | if (addend > 9) {
56 | addend -= 9;
57 | }
58 | } else {
59 | addend = digit;
60 | }
61 | sum += addend;
62 | timesTwo = !timesTwo;
63 | }
64 |
65 | int modulus = sum % 10;
66 | return modulus == 0;
67 | }
68 |
69 | /**
70 | * Method to perform an expiry date check. This allows the SDK user to perform basic validation
71 | * on the card number. The expiry date may contain whitespace, '-' or '/' separators, should be
72 | * two digits for the month followed by two digits for the year and may not be in the past.
73 | *
74 | * @param expiryDate
75 | *
76 | * @return true if a valid expiry date and false otherwise
77 | */
78 | public static boolean performExpiryDateCheck(String expiryDate) {
79 |
80 | DateFormat df = new SimpleDateFormat(EXPIRY_DATE_PATTERN);
81 | df.setLenient(false);
82 |
83 | //Length should be four digits long
84 | if (!expiryDate.matches(EXP_DATE_REG_EXP)) {
85 | return false;
86 | }
87 |
88 | Calendar currentCal = Calendar.getInstance();
89 | Calendar expiryDateCal = Calendar.getInstance();
90 |
91 | //Expiry date matches the pattern
92 | try {
93 | expiryDateCal.setTime(df.parse(expiryDate));
94 | } catch (ParseException pe) {
95 | return false;
96 | }
97 |
98 | // Date is not in the past
99 | if (expiryDateCal.get(Calendar.YEAR) < currentCal.get(Calendar.YEAR)) {
100 | return false;
101 | }
102 |
103 | if ((expiryDateCal.get(Calendar.MONTH) < currentCal.get(Calendar.MONTH))
104 | && (expiryDateCal.get(Calendar.YEAR) == currentCal.get(Calendar.YEAR))) {
105 | return false;
106 | }
107 | return true;
108 | }
109 |
110 | /**
111 | * Method to perform a CVV number check. The CVV must be 4 digits for AMEX and 3 digits for
112 | * all other cards.
113 | *
114 | * @param cvvNumber
115 | * @param cardType
116 | *
117 | * @return true if a valid CVV number and false otherwise
118 | */
119 | public static boolean performCvvCheck(String cvvNumber, String cardType) {
120 |
121 | /* If string has alpha characters it is not a CVV number */
122 | if (!cvvNumber.matches("\\d*")) {
123 | return false;
124 | }
125 |
126 | /* Length should be four digits long for AMEX */
127 | if (cardType.equalsIgnoreCase(Card.CardType.AMEX.getType())) {
128 | if (cvvNumber.length() != 4) {
129 | return false;
130 | }
131 | }
132 | /* Otherwise the length should be three digits */
133 | else if (cvvNumber.length() != 3) {
134 | return false;
135 | }
136 |
137 | return true;
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/utils/GenerationUtils.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.utils;
2 |
3 | import java.nio.ByteBuffer;
4 | import java.text.SimpleDateFormat;
5 | import java.util.Date;
6 | import java.util.UUID;
7 |
8 | import org.apache.commons.codec.binary.Base64;
9 | import org.apache.commons.codec.digest.DigestUtils;
10 |
11 | /**
12 | * Utils for the auto-generation of fields, for example the SHA1 hash.
13 | *
14 | * @author thomasduffy
15 | */
16 | public class GenerationUtils {
17 |
18 | /**
19 | * Each message sent to Realex should have a hash, attached. For a message using the remote
20 | * interface this is generated using the This is generated from the TIMESTAMP, MERCHANT_ID,
21 | * ORDER_ID, AMOUNT, and CURRENCY fields concatenated together with "." in between each field.
22 | * This confirms the message comes
23 | * from the client and
24 | * Generate a hash, required for all messages sent to IPS to prove it was not tampered with.
25 | *
26 | * Hashing takes a string as input, and produce a fixed size number (160 bits for SHA-1 which
27 | * this implementation uses). This number is a hash of the input, and a small change in the
28 | * input results in a substantial change in the output. The functions are thought to be secure
29 | * in the sense that it requires an enormous amount of computing power and time to find a string
30 | * that hashes to the same value. In others words, there's no way to decrypt a secure hash.
31 | * Given the larger key size, this implementation uses SHA-1 which we prefer that you, but Realex
32 | * has retained compatibilty with MD5 hashing for compatibility with older systems.
33 | *
34 | *
35 | * To construct the hash for the remote interface follow this procedure:
36 | *
37 | * To construct the hash for the remote interface follow this procedure:
38 | * Form a string by concatenating the above fields with a period ('.') in the following order
39 | *
40 | * (TIMESTAMP.MERCHANT_ID.ORDER_ID.AMOUNT.CURRENCY)
41 | *
42 | * Like so (where a field is empty an empty string "" is used):
43 | *
44 | * (20120926112654.thestore.ORD453-11.29900.EUR)
45 | *
46 | * Get the hash of this string (SHA-1 shown below).
47 | *
48 | * (b3d51ca21db725f9c7f13f8aca9e0e2ec2f32502)
49 | *
50 | * Create a new string by concatenating this string and your shared secret using a period.
51 | *
52 | * (b3d51ca21db725f9c7f13f8aca9e0e2ec2f32502.mysecret )
53 | *
54 | * Get the hash of this value. This is the value that you send to Realex Payments.
55 | *
56 | * (3c3cac74f2b783598b99af6e43246529346d95d1)
57 | *
58 | * This method takes the pre-built string of concatenated fields and the secret and returns the
59 | * SHA-1 hash to be placed in the request sent to Realex.
60 | *
61 | * @param toHash
62 | * @param secret
63 | * @return the hash as a hex string
64 | */
65 | static public String generateHash(String toHash, String secret) {
66 | //first pass hashes the String of required fields
67 | String toHashFirstPass = DigestUtils.sha1Hex(toHash);
68 |
69 | //second pass takes the first hash, adds the secret and hashes again
70 | String toHashSecondPass = new StringBuilder().append(toHashFirstPass).append(".").append(secret).toString();
71 | return DigestUtils.sha1Hex(toHashSecondPass);
72 | }
73 |
74 | /**
75 | * Generate the current datetimestamp in the string formaat (YYYYMMDDHHSS) required in a
76 | * request to Realex.
77 | *
78 | * @return current timestamp in YYYYMMDDHHSS format
79 | */
80 | static public String generateTimestamp() {
81 | return new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
82 | }
83 |
84 | /**
85 | * Order Id for a initial request should be unique per client ID. This method generates a unique
86 | * order Id using the Java UUID class and then convert it to base64 to shorten the length to 22
87 | * characters. Order Id for a subsequent request (void, rebate, settle ect.) should use the
88 | * order Id of the initial request.
89 | *
90 | * * the order ID uses the Java UUID (universally unique identifier) so in theory it may not
91 | * be unique but the odds of this are extremely remote (see
92 | * http://en.wikipedia.org/wiki/Universally_unique_identifier#Random_UUID_probability_of_duplicates)
93 | *
94 | * @return orderId as a String
95 | */
96 | static public String generateOrderId() {
97 | UUID uuid = UUID.randomUUID();
98 | ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
99 |
100 | bb.putLong(uuid.getMostSignificantBits());
101 | bb.putLong(uuid.getLeastSignificantBits());
102 | return Base64.encodeBase64URLSafeString(bb.array());
103 | }
104 |
105 | }
106 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/utils/ResponseUtils.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.utils;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 |
6 | import com.realexpayments.remote.sdk.RealexException;
7 | import com.realexpayments.remote.sdk.RealexServerException;
8 | import com.realexpayments.remote.sdk.domain.Response;
9 |
10 | /**
11 | * Utils class offering methods which act on the Realex response.
12 | *
13 | * @author markstanford
14 | *
15 | */
16 | public class ResponseUtils {
17 |
18 | /**
19 | * Logger
20 | */
21 | private static final Logger LOGGER = LoggerFactory.getLogger(ResponseUtils.class);
22 |
23 | /**
24 | *
25 | * Realex responses can be basic or full. A basic response indicates the request could not
26 | * be processed. In this case a {@link RealexServerException} will be thrown by the SDK containing the
27 | * result code and message from the response.
28 | *
29 | *
30 | *
31 | * A full response indicates the request could be processed and the response object will return fully populated.
32 | *
33 | *
34 | *
35 | * Please note, full responses may still contain errors e.g. Bank errors (1xx). The result code should be
36 | * checked for success. For example a full response with a result code of 101 will not throw an exception and will return
37 | * a fully populated response object.
38 | *
39 | *
40 | * @param result
41 | * @return boolean
42 | */
43 | public static boolean isBasicResponse(String result) {
44 | boolean inErrorRange = false;
45 |
46 | try {
47 | int initialNumber = Integer.parseInt(result.substring(0, 1));
48 | inErrorRange = initialNumber >= Response.RESULT_CODE_PREFIX_ERROR_RESPONSE_START;
49 | } catch (Exception ex) {
50 | LOGGER.error("Error parsing result {}", result, ex);
51 | throw new RealexException("Error parsing result.", ex);
52 | }
53 |
54 | return inErrorRange;
55 | }
56 |
57 | /**
58 | * Returns true
if the response contains a result code representing success.
59 | *
60 | * @return boolean
61 | */
62 | public static > boolean isSuccess(Response response) {
63 | return Response.RESULT_CODE_SUCCESS.equals(response.getResult());
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/com/realexpayments/remote/sdk/utils/XmlUtils.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.utils;
2 |
3 | import java.io.StringWriter;
4 | import java.util.HashMap;
5 | import java.util.Map;
6 |
7 | import javax.xml.bind.JAXBContext;
8 | import javax.xml.bind.JAXBException;
9 | import javax.xml.bind.Marshaller;
10 | import javax.xml.bind.Unmarshaller;
11 | import javax.xml.transform.Source;
12 |
13 | import org.slf4j.Logger;
14 | import org.slf4j.LoggerFactory;
15 |
16 | import com.realexpayments.remote.sdk.RealexException;
17 | import com.realexpayments.remote.sdk.domain.payment.PaymentRequest;
18 | import com.realexpayments.remote.sdk.domain.payment.PaymentResponse;
19 | import com.realexpayments.remote.sdk.domain.threeDSecure.ThreeDSecureRequest;
20 | import com.realexpayments.remote.sdk.domain.threeDSecure.ThreeDSecureResponse;
21 |
22 | /**
23 | * XML helper class. Marshals/unmarshals XML.
24 | *
25 | * @author markstanford
26 | *
27 | */
28 | public class XmlUtils {
29 |
30 | /**
31 | * {@link JAXBContext} map used for XML marshalling, unmarshalling.
32 | */
33 | private static final Map JAXB_CONTEXT_MAP = new HashMap();
34 |
35 | /**
36 | * Enumeration for the message type.
37 | */
38 | public enum MessageType {
39 | PAYMENT, THREE_D_SECURE;
40 | }
41 |
42 | /**
43 | * Logger
44 | */
45 | private static final Logger LOGGER = LoggerFactory.getLogger(XmlUtils.class);
46 |
47 | static {
48 | try {
49 | //populate JAXBContext map for all message types
50 | JAXBContext paymentJaxbContext = JAXBContext.newInstance(PaymentRequest.class, PaymentResponse.class);
51 | JAXBContext threeDSecureJaxbContext = JAXBContext.newInstance(ThreeDSecureRequest.class, ThreeDSecureResponse.class);
52 |
53 | JAXB_CONTEXT_MAP.put(MessageType.PAYMENT, paymentJaxbContext);
54 | JAXB_CONTEXT_MAP.put(MessageType.THREE_D_SECURE, threeDSecureJaxbContext);
55 |
56 | } catch (Exception ex) {
57 | LOGGER.error("Error initialising JAXBContext", ex);
58 | throw new RealexException("Error initialising JAXBContext", ex);
59 | }
60 | }
61 |
62 | /**
63 | * Marshals object to XML.
64 | *
65 | * @param object
66 | * @param messageType
67 | * @return String
68 | */
69 | public static String toXml(Object object, MessageType messageType) {
70 |
71 | LOGGER.debug("Marshalling domain object to XML.");
72 |
73 | StringWriter result = new StringWriter();
74 |
75 | try {
76 | Marshaller jaxbMarshaller = JAXB_CONTEXT_MAP.get(messageType).createMarshaller();
77 | jaxbMarshaller.marshal(object, result);
78 | } catch (Exception ex) {
79 | LOGGER.error("Error marshalling to XML", ex);
80 | throw new RealexException("Error marshalling to XML", ex);
81 | }
82 |
83 | return result.toString();
84 | }
85 |
86 | /**
87 | * Unmarshals XML to request object.
88 | *
89 | * @param xml
90 | * @param messageType
91 | * @return Object
92 | */
93 | public static Object fromXml(Source xml, MessageType messageType) {
94 | LOGGER.debug("Unmarshalling XML to domain object.");
95 |
96 | Object response = null;
97 |
98 | try {
99 | Unmarshaller jaxbUnmarshaller = JAXB_CONTEXT_MAP.get(messageType).createUnmarshaller();
100 | response = jaxbUnmarshaller.unmarshal(xml);
101 | } catch (JAXBException ex) {
102 | LOGGER.error("Error unmarshalling from XML", ex);
103 | throw new RealexException("Error unmarshalling from XML", ex);
104 | }
105 |
106 | return response;
107 | }
108 |
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/test/java/com/realexpayments/remote/sdk/domain/payment/CardTest.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.payment;
2 |
3 | import com.realexpayments.remote.sdk.RealexClient;
4 | import com.realexpayments.remote.sdk.RealexException;
5 | import com.realexpayments.remote.sdk.domain.Cvn;
6 | import com.realexpayments.remote.sdk.http.HttpConfiguration;
7 |
8 | import org.junit.Assert;
9 | import org.junit.Test;
10 |
11 | import com.realexpayments.remote.sdk.domain.Card;
12 |
13 | public class CardTest {
14 |
15 | /**
16 | * Test method for displayFirstSixLastFour()
17 | */
18 | @Test
19 | public void testDisplayFirstSixLastFour() {
20 |
21 | Card card = new Card();
22 | card.setNumber("1234567890ABCDEF");
23 |
24 | String expectedResult = "123456******CDEF";
25 | String result = card.displayFirstSixLastFour();
26 |
27 | Assert.assertTrue("Results are not as expected.", expectedResult.equals(result));
28 | }
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/com/realexpayments/remote/sdk/domain/threeDSecure/ThreeDSecureRequestTest.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.domain.threeDSecure;
2 |
3 | import com.realexpayments.remote.sdk.domain.Card;
4 | import com.realexpayments.remote.sdk.domain.threeDSecure.ThreeDSecureRequest.ThreeDSecureType;
5 | import org.junit.Assert;
6 | import org.junit.Test;
7 |
8 | import static com.realexpayments.remote.sdk.utils.SampleXmlValidationUtils.*;
9 |
10 | /**
11 | * Unit test class for {@link ThreeDSecureRequest} utility methods.
12 | *
13 | * @author markstanford
14 | *
15 | */
16 | public class ThreeDSecureRequestTest {
17 |
18 | /**
19 | * Test hash calculation for 3DSecure Verify Enrolled.
20 | */
21 | @Test
22 | public void verifyEnrolledHashGenerationTest() {
23 | ThreeDSecureRequest request = new ThreeDSecureRequest().addType(ThreeDSecureType.VERIFY_ENROLLED).addTimeStamp(TIMESTAMP)
24 | .addMerchantId(MERCHANT_ID).addOrderId(ORDER_ID).addAmount(AMOUNT).addCurrency(CURRENCY).addCard(new Card().addNumber(CARD_NUMBER));
25 | request.hash(SECRET);
26 |
27 | Assert.assertEquals(REQUEST_HASH, request.getHash());
28 | }
29 |
30 | /**
31 | * Test hash calculation for 3DSecure Verify Sig.
32 | */
33 | @Test
34 | public void verifySigHashGenerationTest() {
35 | ThreeDSecureRequest request = new ThreeDSecureRequest().addType(ThreeDSecureType.VERIFY_SIG).addTimeStamp(TIMESTAMP)
36 | .addMerchantId(MERCHANT_ID).addOrderId(ORDER_ID).addAmount(AMOUNT).addCurrency(CURRENCY).addCard(new Card().addNumber(CARD_NUMBER));
37 | request.hash(SECRET);
38 |
39 | Assert.assertEquals(REQUEST_HASH, request.getHash());
40 | }
41 |
42 | /**
43 | * Tests the hash calculation for a card-update transaction.
44 | */
45 | @Test
46 | public void verifyCardEnrolledHashGenerationTest() {
47 |
48 | ThreeDSecureRequest request = new ThreeDSecureRequest().addType(ThreeDSecureType.VERIFY_STORED_CARD_ENROLLED)
49 | .addTimeStamp(CARD_VERIFY_TIMESTAMP)
50 | .addMerchantId(CARD_VERIFY_MERCHANT_ID)
51 | .addOrderId(CARD_VERIFY_ORDER_ID)
52 | .addAmount(Long.parseLong(CARD_VERIFY_AMOUNT))
53 | .addCurrency(CARD_VERIFY_CURRENCY)
54 | .addPayerReference(CARD_VERIFY_PAYER_REF);
55 |
56 | request.hash(SECRET);
57 |
58 | Assert.assertEquals(CARD_VERIFY_REQUEST_HASH, request.getHash());
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/java/com/realexpayments/remote/sdk/http/HttpUtilsTest.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.http;
2 |
3 | import static org.mockito.Mockito.mock;
4 | import static org.mockito.Mockito.when;
5 |
6 | import java.io.IOException;
7 |
8 | import org.apache.http.HttpResponse;
9 | import org.apache.http.ProtocolVersion;
10 | import org.apache.http.client.HttpClient;
11 | import org.apache.http.client.methods.HttpUriRequest;
12 | import org.apache.http.entity.StringEntity;
13 | import org.apache.http.message.BasicHttpResponse;
14 | import org.apache.http.message.BasicStatusLine;
15 | import org.junit.Assert;
16 | import org.junit.Rule;
17 | import org.junit.Test;
18 | import org.junit.rules.ExpectedException;
19 | import org.mockito.Matchers;
20 |
21 | import com.realexpayments.remote.sdk.RealexException;
22 |
23 | /**
24 | * HTTP Utils such as getting a default http client and sending a message.
25 | *
26 | * @author thomasduffy
27 | */
28 | public class HttpUtilsTest {
29 |
30 | @Rule
31 | public ExpectedException thrown = ExpectedException.none();
32 |
33 | /**
34 | * Test sending a message, expecting a successful response.
35 | */
36 | @Test
37 | public void sendMessageSuccessTest() {
38 |
39 | try {
40 | String endpoint = "https://some-test-endpoint";
41 | boolean onlyAllowHttps = true;
42 |
43 | String xml = "test response xml";
44 |
45 | // Dummy and Mock required objects
46 | ProtocolVersion protocolVersion = new ProtocolVersion("https", 1, 1);
47 | int statusCode = 200;
48 | String statusReason = "";
49 | HttpResponse httpResponse = new BasicHttpResponse(new BasicStatusLine(protocolVersion, statusCode, statusReason));
50 | httpResponse.setEntity(new StringEntity(xml));
51 |
52 | HttpConfiguration httpConfigurationMock = mock(HttpConfiguration.class);
53 | when(httpConfigurationMock.getEndpoint()).thenReturn(endpoint);
54 | when(httpConfigurationMock.isOnlyAllowHttps()).thenReturn(onlyAllowHttps);
55 |
56 | HttpClient httpClientMock = mock(HttpClient.class);
57 | when(httpClientMock.execute(Matchers.any(HttpUriRequest.class))).thenReturn(httpResponse);
58 |
59 | // Execute the method
60 | String response = HttpUtils.sendMessage(xml, httpClientMock, httpConfigurationMock);
61 |
62 | // Check the repsonse
63 | Assert.assertEquals(response, xml);
64 | } catch (Exception e) {
65 | Assert.fail("Unexpected exception: " + e.getMessage());
66 | }
67 | }
68 |
69 | /**
70 | * Test sending a message, expecting an exception due to failure response.
71 | */
72 | @Test
73 | public void sendMessageFailureTest() {
74 |
75 | // Dummy required objects
76 | ProtocolVersion protocolVersion = new ProtocolVersion("https", 1, 1);
77 | int statusCode = 400;
78 | String statusReason = "";
79 |
80 | thrown.expect(RealexException.class);
81 | thrown.expectMessage("Unexpected http status code [" + statusCode + "]");
82 |
83 | try {
84 | String endpoint = "https://some-test-endpoint";
85 | boolean onlyAllowHttps = true;
86 |
87 | String xml = "test response xml";
88 |
89 | // Mock required objects
90 | HttpResponse httpResponse = new BasicHttpResponse(new BasicStatusLine(protocolVersion, statusCode, statusReason));
91 | httpResponse.setEntity(new StringEntity(xml));
92 |
93 | HttpConfiguration httpConfigurationMock = mock(HttpConfiguration.class);
94 | when(httpConfigurationMock.getEndpoint()).thenReturn(endpoint);
95 | when(httpConfigurationMock.isOnlyAllowHttps()).thenReturn(onlyAllowHttps);
96 |
97 | HttpClient httpClientMock = mock(HttpClient.class);
98 | when(httpClientMock.execute(Matchers.any(HttpUriRequest.class))).thenReturn(httpResponse);
99 |
100 | // Execute the method
101 | String response = HttpUtils.sendMessage(xml, httpClientMock, httpConfigurationMock);
102 | } catch (IOException e) {
103 | Assert.fail("Unexpected exception: " + e.getMessage());
104 | }
105 | }
106 |
107 | /**
108 | * Test sending a message, expecting an exception due to failure response.
109 | */
110 | @Test
111 | public void sendMessageFailureHttpNotAllowedTest() {
112 |
113 | // Dummy required objects
114 | ProtocolVersion protocolVersion = new ProtocolVersion("http", 1, 1);
115 | int statusCode = 200;
116 | String statusReason = "";
117 |
118 | thrown.expect(RealexException.class);
119 | thrown.expectMessage("Protocol must be https");
120 |
121 | try {
122 | String endpoint = "http://some-test-endpoint";
123 | boolean onlyAllowHttps = true;
124 |
125 | String xml = "test response xml";
126 |
127 | // Mock required objects
128 | HttpResponse httpResponse = new BasicHttpResponse(new BasicStatusLine(protocolVersion, statusCode, statusReason));
129 | httpResponse.setEntity(new StringEntity(xml));
130 |
131 | HttpConfiguration httpConfigurationMock = mock(HttpConfiguration.class);
132 | when(httpConfigurationMock.getEndpoint()).thenReturn(endpoint);
133 | when(httpConfigurationMock.isOnlyAllowHttps()).thenReturn(onlyAllowHttps);
134 |
135 | HttpClient httpClientMock = mock(HttpClient.class);
136 | when(httpClientMock.execute(Matchers.any(HttpUriRequest.class))).thenReturn(httpResponse);
137 |
138 | // Execute the method
139 | String response = HttpUtils.sendMessage(xml, httpClientMock, httpConfigurationMock);
140 | } catch (IOException e) {
141 | Assert.fail("Unexpected exception: " + e.getMessage());
142 | }
143 | }
144 |
145 | }
146 |
--------------------------------------------------------------------------------
/src/test/java/com/realexpayments/remote/sdk/utils/CardValidationUtilsTest.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.utils;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Test;
5 |
6 | import java.util.Calendar;
7 |
8 | import static org.junit.Assert.assertFalse;
9 | import static org.junit.Assert.assertTrue;
10 |
11 | public class CardValidationUtilsTest {
12 |
13 | private static final String VALID_CARD_NUM = "4242424242424242";
14 | private static final String INVALID_CARD_NUM = "1234567890123456";
15 | private static final String VALID_CARD_NUM_WITH_SPACES = "4242 4242 4242 4242";
16 | private static final String INVALID_CARD_NUM_WITH_SPACES = "1234 5678 9012 3456";
17 | private static final String ALPHA_STRING = "abcdefghijklmop";
18 | private static final String EMPTY_STRING = "";
19 |
20 | @Test
21 | public void testValidCardNumber() {
22 | boolean cardIsValid = CardValidationUtils.performLuhnCheck(VALID_CARD_NUM);
23 | assertTrue("Test Valid Card Number " + VALID_CARD_NUM, cardIsValid);
24 | }
25 |
26 | @Test
27 | public void testInvalidCardNumber() {
28 | boolean cardIsValid = CardValidationUtils.performLuhnCheck(INVALID_CARD_NUM);
29 | assertFalse("Test Invalid Card Number " + INVALID_CARD_NUM, cardIsValid);
30 | }
31 |
32 | @Test
33 | public void testValidCardNumberWithSpaces() {
34 | boolean cardIsValid = CardValidationUtils.performLuhnCheck(VALID_CARD_NUM_WITH_SPACES);
35 | assertFalse("Test Valid Card Number " + VALID_CARD_NUM_WITH_SPACES, cardIsValid);
36 | }
37 |
38 | @Test
39 | public void testInvalidCardNumberWithSpaces() {
40 | boolean cardIsValid = CardValidationUtils.performLuhnCheck(INVALID_CARD_NUM_WITH_SPACES);
41 | assertFalse("Test Invalid Card Number " + INVALID_CARD_NUM_WITH_SPACES, cardIsValid);
42 | }
43 |
44 | @Test
45 | public void testAlphaStringAsCardNumber() {
46 | boolean cardIsValid = CardValidationUtils.performLuhnCheck(ALPHA_STRING);
47 | assertFalse("Test Invalid Card Number " + ALPHA_STRING, cardIsValid);
48 | }
49 |
50 | @Test
51 | public void testEmptyStringAsCardNumber() {
52 | boolean cardIsValid = CardValidationUtils.performLuhnCheck(EMPTY_STRING);
53 | assertFalse("Test Invalid Card Number " + EMPTY_STRING, cardIsValid);
54 | }
55 |
56 | @Test
57 | public void testValidAmexCvv() {
58 | String cvvNumber = "1234";
59 | String cardType = "AMEX";
60 |
61 | boolean cvvIsValid = CardValidationUtils.performCvvCheck(cvvNumber, cardType);
62 | assertTrue("Testing valid " + cardType + " card type with CVV number " + cvvNumber + EMPTY_STRING, cvvIsValid);
63 | }
64 |
65 | @Test
66 | public void testValidAmexLowerCaseCvv() {
67 | String cvvNumber = "1234";
68 | String cardType = "amex";
69 |
70 | boolean cvvIsValid = CardValidationUtils.performCvvCheck(cvvNumber, cardType);
71 | assertTrue("Testing valid " + cardType + " card type with CVV number " + cvvNumber + EMPTY_STRING, cvvIsValid);
72 | }
73 |
74 | @Test
75 | public void testInvalidAmexCvv() {
76 | String cvvNumber = "12345";
77 | String cardType = "AMEX";
78 |
79 | boolean cvvIsValid = CardValidationUtils.performCvvCheck(cvvNumber, cardType);
80 | assertFalse("Testing invalid " + cardType + " card type with CVV number " + cvvNumber + EMPTY_STRING, cvvIsValid);
81 | }
82 |
83 | @Test
84 | public void testValidVisaCvv() {
85 | String cvvNumber = "123";
86 | String cardType = "VISA";
87 |
88 | boolean cvvIsValid = CardValidationUtils.performCvvCheck(cvvNumber, cardType);
89 | assertTrue("Testing valid " + cardType + " card type with CVV number " + cvvNumber + EMPTY_STRING, cvvIsValid);
90 | }
91 |
92 | @Test
93 | public void testInvalidVisaCvv() {
94 | String cvvNumber = "1234";
95 | String cardType = "VISA";
96 |
97 | boolean cvvIsValid = CardValidationUtils.performCvvCheck(cvvNumber, cardType);
98 | assertFalse("Testing valid " + cardType + " card type with CVV number " + cvvNumber + EMPTY_STRING, cvvIsValid);
99 | }
100 |
101 | @Test
102 | public void testValidExpiryDateCurrentMonthThisYear() {
103 |
104 | String message = "Correct date MMYY - this month";
105 | int month = ((Calendar.getInstance().get(Calendar.MONTH)) + 1); // Current month
106 | int year = (Calendar.getInstance().get(Calendar.YEAR));
107 | String mm = (month < 10 ? ("0".concat(Integer.toString(month))) : Integer.toString(month));
108 | String yy = Integer.toString(year).substring(2);
109 | String expiryDate = mm + yy;
110 | boolean expectedResult = true;
111 |
112 | boolean result = CardValidationUtils.performExpiryDateCheck(expiryDate);
113 | Assert.assertEquals(message + " : " + expiryDate, expectedResult, result);
114 | }
115 |
116 | @Test
117 | public void testValidExpiryDateFutureMonthThisYear() {
118 |
119 | String message = "Correct date MMYY - this month";
120 | Calendar cal = Calendar.getInstance();
121 | cal.add(Calendar.MONTH, 1); // Move to next month (if December will be next year but will have to live with that
122 | int month = ((cal.get(Calendar.MONTH)) + 1);
123 | int year = (cal.get(Calendar.YEAR));
124 | String mm = (month < 10 ? ("0".concat(Integer.toString(month))) : Integer.toString(month));
125 | String yy = Integer.toString(year).substring(2);
126 | String expiryDate = mm + yy;
127 | boolean expectedResult = true;
128 |
129 | boolean result = CardValidationUtils.performExpiryDateCheck(expiryDate);
130 | Assert.assertEquals(message + " : " + expiryDate, expectedResult, result);
131 | }
132 |
133 | @Test
134 | public void testValidExpiryDatePastMonthThisYear() {
135 |
136 | String message = "Correct date MMYY - this month";
137 | Calendar cal = Calendar.getInstance();
138 | cal.add(Calendar.MONTH, -1); // Move to last month (if January will be last year but will have to live with that
139 | int month = ((cal.get(Calendar.MONTH)) + 1);
140 | int year = (cal.get(Calendar.YEAR));
141 | if (month == 1)
142 | {
143 | year++;
144 | }
145 |
146 | String mm = (month < 10 ? ("0".concat(Integer.toString(month))) : Integer.toString(month));
147 | String yy = Integer.toString(year).substring(2);
148 | String expiryDate = mm + yy;
149 | boolean expectedResult = true;
150 |
151 | boolean result = CardValidationUtils.performExpiryDateCheck(expiryDate);
152 | Assert.assertEquals(message + " : " + expiryDate, expectedResult, result);
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/src/test/java/com/realexpayments/remote/sdk/utils/CardValidationUtils_ExpiryDateTest.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.utils;
2 |
3 | import java.util.Arrays;
4 | import java.util.Collection;
5 |
6 | import org.junit.Assert;
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 | import org.junit.runners.Parameterized;
10 |
11 | @RunWith(Parameterized.class)
12 | public class CardValidationUtils_ExpiryDateTest {
13 |
14 | private final String message;
15 | private final String expiryDate;
16 | private final boolean expectedResult;
17 |
18 | @Parameterized.Parameters
19 | public static Collection testData() {
20 |
21 | Object[][] testCases = new Object[][] {
22 | { "Correct format MMYY", "1220", true },
23 | { "Correct format MM-YY", "12-20", false },
24 | { "Correct format MM/YY", "12/20", false },
25 | { "Correct format MM YY", "12 20", false },
26 | { "Incorrect format MM\\YY", "12\\20", false },
27 | { "Incorrect format AABB", "AABB", false },
28 | { "Correct future date MMYY", "1221", true },
29 | { "Incorrect date MMYY", "1221", true },
30 | { "Incorrect date MMYY", "1321", false },
31 | { "Incorrect date MMYY", "1212", false },
32 | { "Incorrect date MMYY", "0015", false },
33 | { "Incorrect date MMYY", "0415", false },
34 | { "Correct date MMYY", "1225", true },
35 | { "Incorrect date MMYY", "0021", false },
36 | };
37 | return Arrays.asList(testCases);
38 | }
39 |
40 | public CardValidationUtils_ExpiryDateTest(String message, String expiryDate, boolean expectedResult) {
41 | this.message = message;
42 | this.expiryDate = expiryDate;
43 | this.expectedResult = expectedResult;
44 | }
45 |
46 | @Test
47 | public void testExpiryDateFormats() {
48 | boolean result = CardValidationUtils.performExpiryDateCheck(expiryDate);
49 | Assert.assertEquals(message + " : " + expiryDate, expectedResult, result);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/java/com/realexpayments/remote/sdk/utils/GenerationUtilsTest.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.utils;
2 |
3 | import static org.junit.Assert.assertEquals;
4 | import static org.junit.Assert.assertTrue;
5 |
6 | import org.junit.Test;
7 |
8 | /**
9 | * GenerationUtils unit tests.
10 | *
11 | * @author thomasduffy
12 | */
13 | public class GenerationUtilsTest {
14 |
15 | /**
16 | * Test Hash generation success case.
17 | */
18 | @Test
19 | public void testGenerateHash() {
20 |
21 | String testString = "20120926112654.thestore.ORD453-11.00.Successful.3737468273643.79347";
22 | String secret = "mysecret";
23 | String expectedResult = "368df010076481d47a21e777871012b62b976339";
24 |
25 | String result = GenerationUtils.generateHash(testString, secret);
26 | assertTrue("Expected and resultant Hash do not match. expected: " + expectedResult + " result: " + result, expectedResult.equals(result));
27 | }
28 |
29 | /**
30 | * Test timestamp generation. Hard to test this in a meaningful way. Checking length and valid characters.
31 | *
32 | * @return current timestamp in YYYYMMDDHHSS format
33 | */
34 | @Test
35 | public void testGenerateTimestamp() {
36 | String result = GenerationUtils.generateTimestamp();
37 |
38 | assertTrue("Timestamp should be 14 digits: " + result, result.matches("[0-9]{14}"));
39 | }
40 |
41 | /**
42 | * Test order Id generation. Hard to test this in a meaningful way. Checking length and valid characters.
43 | */
44 | @Test
45 | public void testGenerateOrderId() {
46 | String result = GenerationUtils.generateOrderId();
47 |
48 | assertEquals("OrderId " + result + " should be 22 characters, is " + result.length() + " characters: " + result, "22",
49 | String.valueOf(result.length()));
50 | assertTrue("OrderId " + result + " - Regexp doesn't match [A-Za-z0-9-_]{22}", result.matches("[A-Za-z0-9-_]{22}"));
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/java/com/realexpayments/remote/sdk/utils/ResponseUtilsTest.java:
--------------------------------------------------------------------------------
1 | package com.realexpayments.remote.sdk.utils;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Test;
5 |
6 | import com.realexpayments.remote.sdk.domain.Response;
7 | import com.realexpayments.remote.sdk.domain.payment.PaymentResponse;
8 |
9 | /**
10 | * Unit test class for {@link ResponseUtils}.
11 | *
12 | * @author markstanford
13 | *
14 | */
15 | public class ResponseUtilsTest {
16 |
17 | /**
18 | * Test if the response is a basic response.
19 | */
20 | @Test
21 | public void isBasicResponseTest() {
22 | //test success response
23 | Assert.assertFalse(ResponseUtils.isBasicResponse(Response.RESULT_CODE_SUCCESS));
24 |
25 | //test 1xx code
26 | Assert.assertFalse(ResponseUtils.isBasicResponse("100"));
27 |
28 | //test 2xx code
29 | Assert.assertFalse(ResponseUtils.isBasicResponse("200"));
30 |
31 | //test 3xx code
32 | Assert.assertTrue(ResponseUtils.isBasicResponse("300"));
33 |
34 | //test 5xx code
35 | Assert.assertTrue(ResponseUtils.isBasicResponse("500"));
36 |
37 | }
38 |
39 | /**
40 | * Test if the full response is successful.
41 | */
42 | @Test
43 | public void isSuccessTest() {
44 | PaymentResponse response = new PaymentResponse();
45 |
46 | //test success
47 | response.setResult(Response.RESULT_CODE_SUCCESS);
48 | Assert.assertTrue(ResponseUtils.isSuccess(response));
49 |
50 | //test failure
51 | response.setResult("101");
52 | Assert.assertFalse(ResponseUtils.isSuccess(response));
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/3ds-verify-enrolled-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 | thestore
3 | internet
4 | ORD453-11
5 | 29900
6 |
7 | 420000000000000000
8 | 0119
9 | VISA
10 | Joe Smith
11 |
12 | 085f09727da50c2392b64894f962e7eb5050f762
13 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/3ds-verify-enrolled-response-sample-not-enrolled.xml:
--------------------------------------------------------------------------------
1 |
2 | thestore
3 | internet
4 | ORD453-11
5 | 79347
6 | 110
7 | Not Enrolled
8 | 3737468273643
9 | 54564
10 | 1001
11 | eJxVUttygkAM/ZUdnitZFlBw4na02tE6bR0vD+0bLlHpFFDASv++u6i1
12 | http://myurl.com
13 | N
14 | e9dafe706f7142469c45d4877aaf5984
15 | e553ff2510dec9bfee79bb0303af337d871c02ad
16 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/3ds-verify-enrolled-response-sample.xml:
--------------------------------------------------------------------------------
1 |
2 | thestore
3 | internet
4 | ORD453-11
5 | 79347
6 | 00
7 | Enrolled
8 | 3737468273643
9 | 54564
10 | 1001
11 | eJxVUttygkAM/ZUdnitZFlBw4na02tE6bR0vD+0bLlHpFFDASv++u6i1
12 | http://myurl.com
13 | Y
14 | e9dafe706f7142469c45d4877aaf5984
15 | 728cdbef90ff535ed818748f329ed8b1df6b8f5a
16 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/3ds-verify-sig-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 | thestore
3 | internet
4 | ORD453-11
5 | 29900
6 |
7 | 420000000000000000
8 | 0119
9 | VISA
10 | Joe Smith
11 |
12 | eJxVUttygkAM/ZUdnitZFlBw4na02tE6bR0vD+0bLlHpFFDASv++u6i1
13 | 085f09727da50c2392b64894f962e7eb5050f762
14 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/3ds-verify-sig-response-sample.xml:
--------------------------------------------------------------------------------
1 |
2 | thestore
3 | internet
4 | ORD453-11
5 | 79347
6 | 00
7 | Authentication Successful
8 |
9 | Y
10 | 5
11 | e9dafe706f7142469c45d4877aaf5984
12 | AAABASY3QHgwUVdEBTdAAAAAAAA=
13 | 1
14 |
15 | e5a7745da5dc32d234c3f52860132c482107e9ac
16 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/auth-mobile-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 8cdbf036-73e2-44ff-bf11-eba8cab33a14
6 | apple-pay
7 | {"version":"EC_v1","data":"Ft+dvmdfgnsdfnbg+zerKtkh/RWWjdfgdjhHGFHGFlkjdfgkljlkfs78678hEPnsbXZnMDy3o7qDg+iDHB0JVEjDHxjQIAPcNN1Cqdtq63nX4+VRU3eXzdo1QGqSptH6D5KW5SxZLAdnMEmCxG9vkVEdHTTlhVPddxiovAkFTBWBFTJ2uf5f2grXC/VnK0X/efAowXrhJIX1ngsGfAk3/EVRzADGHJFGHJKH78hjkhdfgih80UU05zSluzATidvvBoHBz/WpytSYyrUx1QI9nyH/Nbv8f8lOUjPzBFb+EFOzJaIf+fr0swKU6EB2/2Sm0Y20mD0IvyomtKQ7Tf3VHKA7zhFrDvZUdtX808oHnrqDFRAQZHWAppGUVstqkOyibA0C4suxnOQlsQNZT0r70Tz84=","signature":"MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCAMIID4jCCA4igAwIBAgIIJEPyqAad9XcwCgYIKoZIzj0EAwIwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTMB4XDTE0MDkyNTIyMDYxMVoXDTE5MDkyNDIyMDYxMVowXzElMCMGA1UEAwwcZWNjLXNtcC1icm9rZXItc2lnbl9VQzQtUFJPRDEUMBIGA1UECwwLaU9TIFN5c3RlbXMxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEwhV37evWx7Ihj2jdcJChIY3HsL1vLCg9hGCV2Ur0pUEbg0IO2BHzQH6DMx8cVMP36zIg1rrV1O/0komJPnwPE6OCAhEwggINMEUGCCsGAQUFBwEBBDkwNzA1BggrBgEFBQcwAYYpaHR0cDovL29jc3AuYXBwbGUuY29tL29jc3AwNC1hcHBsZWFpY2EzMDEwHQYDVR0OBBYEFJRX22/VdIGGiYl2L35XhQfnm1gkMAwGA1UdEwEB/wQCMAAwHwYDVR0jBBgwFoAUI/JJxE+T5O8n5sT2KGw/orv9LkswggEdBgNVHSAEggEUMIIBEDCCAQwGCSqGSIb3Y2QFATCB/jCBwwYIKwYBBQUHAgIwgbYMgbNSZWxpYW5jZSBvbiB0aGlzIGNlcnRpZmljYXRlIGJ5IGFueSBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJsZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRlIHBvbGljeSBhbmQgY2VydGlmaWNhdGlvbiBwcmFjdGljZSBzdGF0ZW1lbnRzLjA2BggrBgEFBQcCARYqaHR0cDovL3d3dy5hcHBsZS5jb20vY2VydGlmaWNhdGVhdXRob3JpdHkvMDQGA1UdHwQtMCswKaAnoCWGI2h0dHA6Ly9jcmwuYXBwbGUuY29tL2FwcGxlYWljYTMuY3JsMA4GA1UdDwEB/wQEAwIHgDAPBgkqhkiG92NkBh0EAgUAMAoGCCqGSM49BAMCA0gAMEUCIHKKnw+Soyq5mXQr1V62c0BXKpaHodYu9TWXEPUWPpbpAiEAkTecfW6+W5l0r0ADfzTCPq2YtbS39w01XIayqBNy8bEwggLuMIICdaADAgECAghJbS+/OpjalzAKBggqhkjOPQQDAjBnMRswGQYDVQQDDBJBcHBsZSBSb290IENBIC0gRzMxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMwEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUzAeFw0xNDA1MDYyMzQ2MzBaFw0yOTA1MDYyMzQ2MzBaMHoxLjAsBgNVBAMMJUFwcGxlIEFwcGxpY2F0aW9uIEludGVncmF0aW9uIENBIC0gRzMxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMwEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABPAXEYQZ12SF1RpeJYEHduiAou/ee65N4I38S5PhM1bVZls1riLQl3YNIk57ugj9dhfOiMt2u2ZwvsjoKYT/VEWjgfcwgfQwRgYIKwYBBQUHAQEEOjA4MDYGCCsGAQUFBzABhipodHRwOi8vb2NzcC5hcHBsZS5jb20vb2NzcDA0LWFwcGxlcm9vdGNhZzMwHQYDVR0OBBYEFCPyScRPk+TvJ+bE9ihsP6K7/S5LMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUu7DeoVgziJqkipnevr3rr9rLJKswNwYDVR0fBDAwLjAsoCqgKIYmaHR0cDovL2NybC5hcHBsZS5jb20vYXBwbGVyb290Y2FnMy5jcmwwDgYDVR0PAQH/BAQDAgEGMBAGCiqGSIb3Y2QGAg4EAgUAMAoGCCqGSM49BAMCA2cAMGQCMDrPcoNRFpmxhvs1w1bKYr/0F+3ZD3VNoo6+8ZyBXkK3ifiY95tZn5jVQQ2PnenC/gIwMi3VRCGwowV3bF3zODuQZ/0XfCwhbZZPxnJpghJvVPh6fRuZy5sJiSFhBpkPCZIdAAAxggFgMIIBXAIBATCBhjB6MS4wLAYDVQQDDCVBcHBsZSBBcHBsaWNhdGlvbiBJbnRlZ3JhdGlvbiBDQSAtIEczMSYwJAYDVQQLDB1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTETMBEGA1UECgwKQXBwbGUgSW5jLjELMAkGA1UEBhMCVVMCCCRD8qgGnfV3MA0GCWCGSAFlAwQCAQUAoGkwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTUxMDAzMTI1NjE0WjAvBgkqhkiG9w0BCQQxIgQgX2PuBLPWoqZa8uDvFenDTHTwXkeF3/XINbPpoQfbFe8wCgYIKoZIzj0EAwIESDBGAiEAkF4y5/FgTRquNdpi23Cqat7YV2kdYEC6Z+OJGB8JCgYCIQChUiQiTHgjzB7oTo7xfJWEzir2sDyzDkjIUJ0TFCQd/QAAAAAAAA==","header":{"ephemeralPublicKey":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWdNhNAHy9kO2Kol33kIh7k6wh6E/lxriM46MR1FUrn7SHugprkaeFmWKZPgGpWgZ+telY/G1+YSoaCbR57bdGA==","transactionId":"fd88874954acdb29976gfnjd784ng8ern8BDF8gT7G3fd4ebc22a864398684198644c3","publicKeyHash":"h7njghUJVz2gmpTSkHqETOWsskhsdfjj4mgf3sPTS2cBxgrk="}}
8 |
9 | b13f183cd3ea2a0b63033fb53bdeb4894c684643
10 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/card-delete-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 |
6 | [visa01]
7 | smithj01
8 |
9 | 02ea36d7c32ad272aa275be2f4cae5dd4af18280
10 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/card-edit-replace-card-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 |
6 | [visa01]
7 | smithj01
8 | 4988433008499991
9 | 0104
10 | John Smith
11 | visa
12 | 1
13 |
14 | 18eae35c4d680e945375a223ce026f1a74bc63f3
15 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/card-edit-update-ch-name-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 |
6 | [visa01]
7 | smithj01
8 | 0104
9 | John Smith
10 | visa
11 |
12 | 73ab20318d1977131eb41d7054c5549bce95228a
13 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/card-edit-update-issue-no-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 |
6 | [visa01]
7 | smithj01
8 | 0104
9 | John Smith
10 | visa
11 | 2
12 |
13 | 73ab20318d1977131eb41d7054c5549bce95228a
14 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/card-new-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 292af5fa-6cbc-43d5-b2f0-7fd134d78A99
6 |
7 | [visa01]
8 | smithj01
9 | 4988433008499991
10 | 0104
11 | John Smith
12 | visa
13 | 1
14 |
15 | fb85da792353786fda1bf4ddeb665fedb728af20
16 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/card-verify-enrolled-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 | thestore
3 | internet
4 | 292af5fa-6cbc-43d5-b2f0-7fd134d78A18
5 | 3000
6 | smithj01
7 | visa01
8 |
9 |
10 |
11 | 123
12 |
13 |
14 | 85cae325d558aad444341b69c1350c929738ce60
15 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/credit-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 6df026a7-15d6-4b92-86e1-9f7b2b1d97c5
6 | 13276780809852
7 | AP12346
8 | 3000
9 | 52ed08590ab0bb6c2e5e4c9584aca0f6e9635a3a
10 | c1319b2999608fcfa3e71d583627affaeb25d961
11 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/dcc-rate-auth-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 | yourmerchantid
3 |
4 | 201232-205
5 | 19000
6 |
7 | 4111111111111111
8 | 0415
9 | Peter Johnson
10 | VISA
11 |
12 |
13 |
14 | fexco
15 | 1
16 | 0.6868
17 | S
18 | 13049
19 |
20 | 116d9e19144cd6cec05a809c6d945582c7f10133
21 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/dcc-rate-lookup-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 | thestore
3 | internet
4 | 292af5fa-6cbc-43d5-b2f0-7fd134d78A80
5 | 3000
6 |
7 | 420000000000000000
8 | 0417
9 | Joe Smith
10 | VISA
11 |
12 |
13 |
14 | fexco
15 | 1
16 |
17 | dbe26dd81f6b39c0ad682bae1b882c9bdb696819
18 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/hold-payment-reason-falsepositive-request.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 292af5fa-6cbc-43d5-b2f0-7fd134d78d95
6 | ABC123456
7 | FALSEPOSITIVE
8 | eec6d1f5dcc51a6a2d2b59af5d2cdb965806d96c
9 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/hold-payment-reason-hold-request.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 292af5fa-6cbc-43d5-b2f0-7fd134d78d95
6 | ABC123456
7 | NOTGIVEN
8 | eec6d1f5dcc51a6a2d2b59af5d2cdb965806d96c
9 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/hold-payment-reason-release-request.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 292af5fa-6cbc-43d5-b2f0-7fd134d78d95
6 | ABC123456
7 | NOTGIVEN
8 | eec6d1f5dcc51a6a2d2b59af5d2cdb965806d96c
9 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/hold-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 292af5fa-6cbc-43d5-b2f0-7fd134d78d95
6 | ABC123456
7 | eec6d1f5dcc51a6a2d2b59af5d2cdb965806d96c
8 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/hold-payment-request-with-reasoncode-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 292af5fa-6cbc-43d5-b2f0-7fd134d78d95
6 | ABC123456
7 |
8 | eec6d1f5dcc51a6a2d2b59af5d2cdb965806d96c
9 | FRAUD
10 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/otb-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 3be87fe9-db95-470f-ab04-b82f965f5b17
6 |
7 | 420000000000000000
8 | 0119
9 | Joe Smith
10 | VISA
11 | 1
12 |
13 | 123
14 | 1
15 |
16 |
17 |
18 | c05460fa3d195c1ee6ac97d3594e8cace4449cb2
19 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/payer-edit-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | 292af5fa-6cbc-43d5-b2f0-7fd134d78A77
5 | internet
6 |
7 | Mr
8 | John
9 | Smith
10 | Acme Inc
11 |
12 | 123 Fake St.
13 |
14 |
15 | Hytown
16 | Dunham
17 | 3
18 | Ireland
19 |
20 |
21 |
22 | +35317433923
23 | +35317893248
24 | +353873748392
25 |
26 | jsmith@acme.com
27 |
28 | comment 1
29 |
30 |
31 |
32 | 9ac73a4c8e5d4904c1e6814f48aaeb9bcb4e2615
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/payer-new-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | 292af5fa-6cbc-43d5-b2f0-7fd134d78A77
5 | internet
6 |
7 | Mr
8 | John
9 | Smith
10 | Acme Inc
11 |
12 | Apt 167 Block 10
13 | The Hills
14 |
15 | Hytown
16 | Dunham
17 | 3
18 | Ireland
19 |
20 |
21 |
22 | +35317433923
23 | +35317893248
24 | +353873748392
25 |
26 | jsmith@acme.com
27 |
28 | comment 1
29 |
30 |
31 |
32 | fa007978fb6b897c56f25e9dd50f4f4ddeae822a
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/payment-out-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 292af5fa-6cbc-43d5-b2f0-7fd134d78A13
6 | 3000
7 | bloggsj01
8 | visa01
9 |
10 | 57b592b6a3a3e550b319dcc336b0a79faa976b86
11 | 52ed08590ab0bb6c2e5e4c9584aca0f6e9635a3a
12 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | ORD453-11
6 | yourChannel
7 | 29900
8 |
9 | 420000000000000000
10 | 0119
11 | Joe Smith
12 | VISA
13 | 1
14 |
15 | 123
16 | 1
17 |
18 |
19 |
20 | 085f09727da50c2392b64894f962e7eb5050f762
21 |
22 | comment 1
23 | comment 2
24 |
25 | 3737468273643
26 | 79347
27 | hjfdg78h34tyvklasjr89t
28 |
29 |
30 |
31 | cust num
32 | prod ID
33 | variable ref 1234
34 | 127.0.0.1
35 |
36 | 21|578
37 | IE
38 |
39 |
40 | 77|9876
41 | GB
42 |
43 |
44 |
45 | AAABASY3QHgwUVdEBTdAAAAAAAA=
46 | e9dafe706f7142469c45d4877aaf5984
47 | 5
48 |
49 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/payment-response-basic-error-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ORD453-11
4 | 508
5 | error message returned from system
6 |
7 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/payment-response-dcc-info.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | yourmerchantid
4 | internet
5 | 201232-205
6 |
7 | 00
8 | U
9 |
10 |
11 | 10782411922720
12 |
13 | GBP
14 | 13049
15 | 0.6868
16 | EUR
17 | 19000
18 |
19 | 9cbaaf034254315ceefa8c680ff8a773c83db140
20 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/payment-response-fraud-no-rules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | testMerchant
4 | internet
5 | OrderOne
6 | 071757
7 | 00
8 | M
9 | U
10 | U
11 | 3452232
12 | (00)AUTH CODE 071757
13 | 14247938905185175
14 | 2
15 | 2
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | NOT_EXECUTED
24 |
25 |
26 | bd5550299e4508873a2cf6e435ad74a5455ad648
27 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/payment-response-fraud.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | testMerchant
4 | internet
5 | OrderOne
6 | 071757
7 | 00
8 | M
9 | U
10 | U
11 | 3452232
12 | (00)AUTH CODE 071757
13 | 14247938905185175
14 | 2
15 | 2
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | PASS
24 |
25 |
26 | PASS
27 |
28 |
29 | PASS
30 |
31 |
32 |
33 | bd5550299e4508873a2cf6e435ad74a5455ad648
34 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/payment-response-full-error-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | ORD453-11
6 | 101
7 | 79347
8 | Bank Error
9 | 3737468273643
10 | M
11 | 54564
12 | 1001
13 | test acquirer response]]>
14 | -1
15 |
16 | bank
17 | Ireland
18 | IE
19 | Dublin
20 |
21 | 0ad8a9f121c4041b4b832ae8069e80674269e22f
22 |
23 | 67
24 | 99
25 | 199
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/payment-response-sample-unknown-element.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | ORD453-11
6 | 00
7 | 79347
8 | Successful
9 | 3737468273643
10 | M
11 | 54564
12 | 1001
13 | test acquirer response]]>
14 | -1
15 |
16 | bank
17 | Ireland
18 | IE
19 | Dublin
20 |
21 | 368df010076481d47a21e777871012b62b976339
22 |
23 | 67
24 | 99
25 | 199
26 |
27 | M
28 | P
29 | dklgj786hjbg487yeui9f8g7
30 |
31 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/payment-response-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | ORD453-11
6 | 00
7 | 79347
8 | Successful
9 | 3737468273643
10 | M
11 | 54564
12 | 1001
13 | test acquirer response]]>
14 | -1
15 |
16 | bank
17 | Ireland
18 | IE
19 | Dublin
20 |
21 | 368df010076481d47a21e777871012b62b976339
22 |
23 | 67
24 | 99
25 | 199
26 |
27 | M
28 | P
29 |
30 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/rebate-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 6df026a7-15d6-4b92-86e1-9f7b2b1d97c5
6 | 13276780809852
7 | AP12346
8 | 3000
9 | 52ed08590ab0bb6c2e5e4c9584aca0f6e9635a3a
10 | c1319b2999608fcfa3e71d583627affaeb25d961
11 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/receipt-in-otb-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 | thestore
3 | internet
4 | 292af5fa-6cbc-43d5-b2f0-7fd134d78d95
5 |
6 |
7 | 123
8 |
9 |
10 | 3000
11 | bloggsj01
12 | visa01
13 |
14 | ceeeb16edfeda0dc919db1be1b0e9db7b01b24cf
15 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/receipt-in-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 | thestore
3 | internet
4 | 292af5fa-6cbc-43d5-b2f0-7fd134d78d95
5 |
6 |
7 | 123
8 |
9 |
10 | 3000
11 | bloggsj01
12 | visa01
13 |
14 | 373a4a7ce0c2cf7613dee027112e66faf0233b6c
15 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/release-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 292af5fa-6cbc-43d5-b2f0-7fd134d78d95
6 | ABC123456
7 | eec6d1f5dcc51a6a2d2b59af5d2cdb965806d96c
8 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/release-payment-request-with-reasoncode-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 292af5fa-6cbc-43d5-b2f0-7fd134d78d95
6 | ABC123456
7 | OUTOFSTOCK
8 | eec6d1f5dcc51a6a2d2b59af5d2cdb965806d96c
9 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/settle-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | e3cf94c6-f674-4f99-b4db-7541254a8767
6 | 1000
7 | 13276780809850
8 | AP1234
9 | b2e110f78803ccb377e8f3f12730e41d0cb0ed66
10 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/storedcard-dccrate-request.xml:
--------------------------------------------------------------------------------
1 |
2 | yourmerchantid
3 | internet
4 | transaction01
5 | 9999
6 | smith01
7 | visa01
8 |
9 | fexco
10 | 1
11 |
12 |
13 | 500a6c67d7ec3e196b60efdfb4cdc5ab8366416a
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/test/resources/sample-xml/void-payment-request-sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | thestore
4 | internet
5 | 012bf34b-3ec9-4c9b-b3a5-700f2f28e67f
6 | 1000
7 | 13276780809851
8 | AP12345
9 | 9f61456cce6c90dcc13281e6b95734f5b91e628f
10 |
--------------------------------------------------------------------------------
/src/test/test.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------