Skip to content

Commit 315941b

Browse files
committed
Add Rapid API version support
1 parent c199fb5 commit 315941b

16 files changed

Lines changed: 367 additions & 39 deletions

File tree

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ jdk:
88
- openjdk7
99
- openjdk6
1010

11+
env:
12+
matrix:
13+
- APIVERSION='31'
14+
- APIVERSION='40'
15+
1116
install: mvn install -DskipTests=true -Dgpg.skip=true
1217

1318
script: mvn verify -Dgpg.skip=true -Dmaven.javadoc.skip=true

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All Notable changes will be documented in this file
44

5+
## 1.2.0
6+
7+
- Added ability to set the Rapid API version and new associated fields
8+
59
## 1.1.2
610

711
- Added SecuredCardData field and new messages for Secure Fields

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.ewaypayments</groupId>
77
<artifactId>eway-rapid-java</artifactId>
8-
<version>1.1.2</version>
8+
<version>1.2.0</version>
99
<packaging>jar</packaging>
1010

1111
<name>eWAY Rapid API Library</name>

src/main/java/com/eway/payment/rapid/sdk/RapidClient.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public interface RapidClient {
4444
*/
4545
void setDebug(boolean debug);
4646

47+
/**
48+
* Used to set the Rapid API version.
49+
*
50+
* @param version Rapid API version
51+
*/
52+
void setVersion(String version);
53+
4754
/**
4855
* Create a transaction.
4956
* Can be an authorisation, a responsive shared page, transparent redirect,

src/main/java/com/eway/payment/rapid/sdk/RapidClientImpl.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.eway.payment.rapid.sdk.output.RefundResponse;
3131
import com.eway.payment.rapid.sdk.output.ResponseOutput;
3232
import com.eway.payment.rapid.sdk.util.Constant;
33+
import com.eway.payment.rapid.sdk.util.RapidClientFilter;
3334
import com.eway.payment.rapid.sdk.util.ResourceUtil;
3435

3536
import com.sun.jersey.api.client.Client;
@@ -56,6 +57,7 @@ public class RapidClientImpl implements RapidClient {
5657
private String password;
5758
private String webUrl;
5859
private String rapidEndpoint;
60+
private String apiVersion;
5961
private boolean debug;
6062

6163
private boolean isValid;
@@ -101,6 +103,11 @@ public void setDebug(boolean debug) {
101103
this.debug = debug;
102104
}
103105

106+
public void setVersion(String version) {
107+
LOGGER.info("eWAY Rapid SDK version set to " + version);
108+
this.apiVersion = version;
109+
}
110+
104111
/**
105112
* Checks the API credentials are present and valid
106113
*/
@@ -375,21 +382,17 @@ private WebResource getEwayWebResource() {
375382
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
376383
Client client = Client.create(clientConfig);
377384
client.addFilter(new HTTPBasicAuthFilter(APIKey, password));
385+
378386
if (this.debug) {
379387
client.addFilter(new LoggingFilter(System.out));
380388
}
389+
390+
// Set additional headers
391+
RapidClientFilter rapidFilter = new RapidClientFilter();
392+
rapidFilter.setVersion(apiVersion);
393+
client.addFilter(rapidFilter);
394+
381395
WebResource resource = client.resource(webUrl);
382-
String userAgent = "";
383-
try {
384-
Properties prop = ResourceUtil.loadProperiesOnResourceFolder(Constant.RAPID_API_RESOURCE);
385-
userAgent = prop.getProperty(Constant.RAPID_SDK_USER_AGENT_PARAM);
386-
if (StringUtils.isBlank(userAgent)) {
387-
throw new Exception("Resource file " + Constant.RAPID_API_RESOURCE + " is invalid.");
388-
}
389-
} catch (Exception e) {
390-
LOGGER.error("User Agent could not be loaded", e);
391-
}
392-
resource.header("UserAgent", userAgent);
393396
return resource;
394397
}
395398

src/main/java/com/eway/payment/rapid/sdk/beans/external/CardDetails.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class CardDetails {
1616
private String startYear;
1717
private String issueNumber;
1818
private String CVN;
19+
private int cardType;
1920

2021
/**
2122
* Return name on the card
@@ -181,4 +182,24 @@ public String getCVN() {
181182
public void setCVN(String CVN) {
182183
this.CVN = CVN;
183184
}
185+
186+
/**
187+
* Get the card type (Rapid v40+ only)
188+
*
189+
* @return Card Type
190+
*/
191+
public int getCardType() {
192+
return cardType;
193+
}
194+
195+
/**
196+
* Set the card type (Rapid v40+ only)
197+
*
198+
* @param cardType Card Type
199+
*/
200+
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
201+
@JsonProperty("CardType")
202+
public void setCardType(int cardType) {
203+
this.cardType = cardType;
204+
}
184205
}

src/main/java/com/eway/payment/rapid/sdk/beans/external/Transaction.java

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ public class Transaction {
5858

5959
private boolean saveCustomer = false;
6060

61+
private String transactionDateTime;
62+
63+
private String currencyCode;
64+
65+
private int source;
66+
67+
private String maxRefund;
68+
69+
private String originalTransactionId;
70+
6171
/**
6272
* Return type of transaction (Purchase, MOTO,etc)
6373
*
@@ -265,7 +275,7 @@ public void setThirdPartyWalletID(String thirdPartyWalletID) {
265275
}
266276

267277
/**
268-
* Return the Secured Card Data - Card data ID, used for Secure Fields,
278+
* Return the Secured Card Data - Card data ID, used for Secure Fields,
269279
* Visa Checkout, AMEX Express Checkout and Android Pay (optional)
270280
*
271281
* @return the Secured Card Data
@@ -548,4 +558,104 @@ public void setSaveCustomer(boolean saveCustomer) {
548558
this.saveCustomer = saveCustomer;
549559
}
550560

561+
/**
562+
* Get the date and time the transaction took place
563+
* Rapid v40+ only
564+
*
565+
* @return the date and time of the transaction
566+
*/
567+
public String getTransactionDateTime() {
568+
return transactionDateTime;
569+
}
570+
571+
/**
572+
* Set the date and time the transaction took place
573+
* Rapid v40+ only
574+
*
575+
* @param transactionDateTime the date and time of the transaction
576+
*/
577+
public void setTransactionDateTime(String transactionDateTime) {
578+
this.transactionDateTime = transactionDateTime;
579+
}
580+
581+
/**
582+
* Get the ISO 4217 numeric currency code (e.g. AUD = 036)
583+
* Rapid v40+ only
584+
*
585+
* @return The currency code
586+
*/
587+
public String getCurrencyCode() {
588+
return currencyCode;
589+
}
590+
591+
/**
592+
* Set the ISO 4217 numeric currency code (e.g. AUD = 036)
593+
* Rapid v40+ only
594+
*
595+
* @param currencyCode The currency code
596+
*/
597+
public void setCurrencyCode(String currencyCode) {
598+
this.currencyCode = currencyCode;
599+
}
600+
601+
/**
602+
* Reserved for future use
603+
* Rapid v40+ only
604+
*
605+
* @return n/a
606+
*/
607+
public int getSource() {
608+
return source;
609+
}
610+
611+
/**
612+
* Reserved for future use
613+
* Rapid v40+ only
614+
*
615+
* @param source n/a
616+
*/
617+
public void setSource(int source) {
618+
this.source = source;
619+
}
620+
621+
/**
622+
* Get the maximum amount that could be refunded from this transaction
623+
* Rapid v40+ only
624+
*
625+
* @return the maximum refund amount
626+
*/
627+
public String getMaxRefund() {
628+
return maxRefund;
629+
}
630+
631+
/**
632+
* Get the maximum amount that could be refunded from this transaction
633+
* Rapid v40+ only
634+
*
635+
* @param maxRefund the maximum refund amount
636+
*/
637+
public void setMaxRefund(String maxRefund) {
638+
this.maxRefund = maxRefund;
639+
}
640+
641+
/**
642+
* Gets the original transaction ID if the queried transaction is a refund
643+
* Rapid v40+ only
644+
*
645+
* @return the original transaction ID
646+
*/
647+
public String getOriginalTransactionId() {
648+
return originalTransactionId;
649+
}
650+
651+
/**
652+
* Sets the original transaction ID
653+
* Rapid v40+ only
654+
*
655+
* @param originalTransactionId the original transaction ID
656+
*/
657+
public void setOriginalTransactionId(String originalTransactionId) {
658+
this.originalTransactionId = originalTransactionId;
659+
}
660+
551661
}

src/main/java/com/eway/payment/rapid/sdk/beans/internal/Transaction.java

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,28 @@ public class Transaction {
6060
@JsonProperty("errors")
6161
private String errors;
6262

63+
@JsonProperty("TransactionDateTime")
64+
private String transactionDateTime;
65+
66+
@JsonProperty("FraudAction")
67+
private String fraudAction;
68+
69+
@JsonProperty("TransactionCaptured")
70+
private boolean transactionCaptured;
71+
72+
@JsonProperty("CurrencyCode")
73+
private String currencyCode;
74+
75+
@JsonProperty("Source")
76+
private int source;
77+
78+
@JsonProperty("MaxRefund")
79+
private String maxRefund;
80+
81+
@JsonProperty("OriginalTransactionId")
82+
private String originalTransactionId;
83+
84+
6385
public String getAuthorisationCode() {
6486
return authorisationCode;
6587
}
@@ -196,4 +218,60 @@ public void setCustomerNote(String customerNote) {
196218
this.customerNote = customerNote;
197219
}
198220

221+
public String getTransactionDateTime() {
222+
return transactionDateTime;
223+
}
224+
225+
public void setTransactionDateTime(String transactionDateTime) {
226+
this.transactionDateTime = transactionDateTime;
227+
}
228+
229+
public String getFraudAction() {
230+
return fraudAction;
231+
}
232+
233+
public void setFraudAction(String fraudAction) {
234+
this.fraudAction = fraudAction;
235+
}
236+
237+
public boolean getTransactionCaptured() {
238+
return transactionCaptured;
239+
}
240+
241+
public void setTransactionCaptured(boolean transactionCaptured) {
242+
this.transactionCaptured = transactionCaptured;
243+
}
244+
245+
public String getCurrencyCode() {
246+
return currencyCode;
247+
}
248+
249+
public void setCurrencyCode(String currencyCode) {
250+
this.currencyCode = currencyCode;
251+
}
252+
253+
public int getSource() {
254+
return source;
255+
}
256+
257+
public void setSource(int source) {
258+
this.source = source;
259+
}
260+
261+
public String getMaxRefund() {
262+
return maxRefund;
263+
}
264+
265+
public void setMaxRefund(String maxRefund) {
266+
this.maxRefund = maxRefund;
267+
}
268+
269+
public String getOriginalTransactionId() {
270+
return originalTransactionId;
271+
}
272+
273+
public void setOriginalTransactionId(String originalTransactionId) {
274+
this.originalTransactionId = originalTransactionId;
275+
}
276+
199277
}

0 commit comments

Comments
 (0)