Skip to content

Commit

Permalink
Add Rapid API version support
Browse files Browse the repository at this point in the history
  • Loading branch information
incarnate committed Oct 25, 2016
1 parent c199fb5 commit 315941b
Show file tree
Hide file tree
Showing 16 changed files with 367 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ jdk:
- openjdk7
- openjdk6

env:
matrix:
- APIVERSION='31'
- APIVERSION='40'

install: mvn install -DskipTests=true -Dgpg.skip=true

script: mvn verify -Dgpg.skip=true -Dmaven.javadoc.skip=true
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All Notable changes will be documented in this file

## 1.2.0

- Added ability to set the Rapid API version and new associated fields

## 1.1.2

- Added SecuredCardData field and new messages for Secure Fields
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.ewaypayments</groupId>
<artifactId>eway-rapid-java</artifactId>
<version>1.1.2</version>
<version>1.2.0</version>
<packaging>jar</packaging>

<name>eWAY Rapid API Library</name>
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/eway/payment/rapid/sdk/RapidClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public interface RapidClient {
*/
void setDebug(boolean debug);

/**
* Used to set the Rapid API version.
*
* @param version Rapid API version
*/
void setVersion(String version);

/**
* Create a transaction.
* Can be an authorisation, a responsive shared page, transparent redirect,
Expand Down
25 changes: 14 additions & 11 deletions src/main/java/com/eway/payment/rapid/sdk/RapidClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.eway.payment.rapid.sdk.output.RefundResponse;
import com.eway.payment.rapid.sdk.output.ResponseOutput;
import com.eway.payment.rapid.sdk.util.Constant;
import com.eway.payment.rapid.sdk.util.RapidClientFilter;
import com.eway.payment.rapid.sdk.util.ResourceUtil;

import com.sun.jersey.api.client.Client;
Expand All @@ -56,6 +57,7 @@ public class RapidClientImpl implements RapidClient {
private String password;
private String webUrl;
private String rapidEndpoint;
private String apiVersion;
private boolean debug;

private boolean isValid;
Expand Down Expand Up @@ -101,6 +103,11 @@ public void setDebug(boolean debug) {
this.debug = debug;
}

public void setVersion(String version) {
LOGGER.info("eWAY Rapid SDK version set to " + version);
this.apiVersion = version;
}

/**
* Checks the API credentials are present and valid
*/
Expand Down Expand Up @@ -375,21 +382,17 @@ private WebResource getEwayWebResource() {
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
Client client = Client.create(clientConfig);
client.addFilter(new HTTPBasicAuthFilter(APIKey, password));

if (this.debug) {
client.addFilter(new LoggingFilter(System.out));
}

// Set additional headers
RapidClientFilter rapidFilter = new RapidClientFilter();
rapidFilter.setVersion(apiVersion);
client.addFilter(rapidFilter);

WebResource resource = client.resource(webUrl);
String userAgent = "";
try {
Properties prop = ResourceUtil.loadProperiesOnResourceFolder(Constant.RAPID_API_RESOURCE);
userAgent = prop.getProperty(Constant.RAPID_SDK_USER_AGENT_PARAM);
if (StringUtils.isBlank(userAgent)) {
throw new Exception("Resource file " + Constant.RAPID_API_RESOURCE + " is invalid.");
}
} catch (Exception e) {
LOGGER.error("User Agent could not be loaded", e);
}
resource.header("UserAgent", userAgent);
return resource;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class CardDetails {
private String startYear;
private String issueNumber;
private String CVN;
private int cardType;

/**
* Return name on the card
Expand Down Expand Up @@ -181,4 +182,24 @@ public String getCVN() {
public void setCVN(String CVN) {
this.CVN = CVN;
}

/**
* Get the card type (Rapid v40+ only)
*
* @return Card Type
*/
public int getCardType() {
return cardType;
}

/**
* Set the card type (Rapid v40+ only)
*
* @param cardType Card Type
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonProperty("CardType")
public void setCardType(int cardType) {
this.cardType = cardType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ public class Transaction {

private boolean saveCustomer = false;

private String transactionDateTime;

private String currencyCode;

private int source;

private String maxRefund;

private String originalTransactionId;

/**
* Return type of transaction (Purchase, MOTO,etc)
*
Expand Down Expand Up @@ -265,7 +275,7 @@ public void setThirdPartyWalletID(String thirdPartyWalletID) {
}

/**
* Return the Secured Card Data - Card data ID, used for Secure Fields,
* Return the Secured Card Data - Card data ID, used for Secure Fields,
* Visa Checkout, AMEX Express Checkout and Android Pay (optional)
*
* @return the Secured Card Data
Expand Down Expand Up @@ -548,4 +558,104 @@ public void setSaveCustomer(boolean saveCustomer) {
this.saveCustomer = saveCustomer;
}

/**
* Get the date and time the transaction took place
* Rapid v40+ only
*
* @return the date and time of the transaction
*/
public String getTransactionDateTime() {
return transactionDateTime;
}

/**
* Set the date and time the transaction took place
* Rapid v40+ only
*
* @param transactionDateTime the date and time of the transaction
*/
public void setTransactionDateTime(String transactionDateTime) {
this.transactionDateTime = transactionDateTime;
}

/**
* Get the ISO 4217 numeric currency code (e.g. AUD = 036)
* Rapid v40+ only
*
* @return The currency code
*/
public String getCurrencyCode() {
return currencyCode;
}

/**
* Set the ISO 4217 numeric currency code (e.g. AUD = 036)
* Rapid v40+ only
*
* @param currencyCode The currency code
*/
public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}

/**
* Reserved for future use
* Rapid v40+ only
*
* @return n/a
*/
public int getSource() {
return source;
}

/**
* Reserved for future use
* Rapid v40+ only
*
* @param source n/a
*/
public void setSource(int source) {
this.source = source;
}

/**
* Get the maximum amount that could be refunded from this transaction
* Rapid v40+ only
*
* @return the maximum refund amount
*/
public String getMaxRefund() {
return maxRefund;
}

/**
* Get the maximum amount that could be refunded from this transaction
* Rapid v40+ only
*
* @param maxRefund the maximum refund amount
*/
public void setMaxRefund(String maxRefund) {
this.maxRefund = maxRefund;
}

/**
* Gets the original transaction ID if the queried transaction is a refund
* Rapid v40+ only
*
* @return the original transaction ID
*/
public String getOriginalTransactionId() {
return originalTransactionId;
}

/**
* Sets the original transaction ID
* Rapid v40+ only
*
* @param originalTransactionId the original transaction ID
*/
public void setOriginalTransactionId(String originalTransactionId) {
this.originalTransactionId = originalTransactionId;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@ public class Transaction {
@JsonProperty("errors")
private String errors;

@JsonProperty("TransactionDateTime")
private String transactionDateTime;

@JsonProperty("FraudAction")
private String fraudAction;

@JsonProperty("TransactionCaptured")
private boolean transactionCaptured;

@JsonProperty("CurrencyCode")
private String currencyCode;

@JsonProperty("Source")
private int source;

@JsonProperty("MaxRefund")
private String maxRefund;

@JsonProperty("OriginalTransactionId")
private String originalTransactionId;


public String getAuthorisationCode() {
return authorisationCode;
}
Expand Down Expand Up @@ -196,4 +218,60 @@ public void setCustomerNote(String customerNote) {
this.customerNote = customerNote;
}

public String getTransactionDateTime() {
return transactionDateTime;
}

public void setTransactionDateTime(String transactionDateTime) {
this.transactionDateTime = transactionDateTime;
}

public String getFraudAction() {
return fraudAction;
}

public void setFraudAction(String fraudAction) {
this.fraudAction = fraudAction;
}

public boolean getTransactionCaptured() {
return transactionCaptured;
}

public void setTransactionCaptured(boolean transactionCaptured) {
this.transactionCaptured = transactionCaptured;
}

public String getCurrencyCode() {
return currencyCode;
}

public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}

public int getSource() {
return source;
}

public void setSource(int source) {
this.source = source;
}

public String getMaxRefund() {
return maxRefund;
}

public void setMaxRefund(String maxRefund) {
this.maxRefund = maxRefund;
}

public String getOriginalTransactionId() {
return originalTransactionId;
}

public void setOriginalTransactionId(String originalTransactionId) {
this.originalTransactionId = originalTransactionId;
}

}
Loading

0 comments on commit 315941b

Please sign in to comment.