diff --git a/README.md b/README.md
index 2df299ee6..baadf682f 100644
--- a/README.md
+++ b/README.md
@@ -1,21 +1,10 @@
# Adyen APIs Library for Java
The Adyen API Library for Java enables you to work with Adyen APIs and Hosted Payment Page.
-
+
## Requirements
-* Java 8 or higher
-
-## Installation
-
-
-## Usage
+* Java 7 or higher
-## Documentation
-
-## Support
-
-Explain how to get support.
-
## Licence
MIT license see LICENSE
diff --git a/pom.xml b/pom.xml
index 0611a56b1..9c3909232 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.adyen
- java-api-library
+ adyen-client
jar
0.0.1-SNAPSHOT
Adyen Java API Client Library
diff --git a/src/main/java/com/adyen/Util/Util.java b/src/main/java/com/adyen/Util/Util.java
index 5fc72e35e..efbd7d7a0 100644
--- a/src/main/java/com/adyen/Util/Util.java
+++ b/src/main/java/com/adyen/Util/Util.java
@@ -31,6 +31,7 @@ public static String implode(String glue, List list) {
return sb.toString();
}
+
/**
* Returns an Amount struct to use on requests
*
@@ -39,6 +40,17 @@ public static String implode(String glue, List list) {
* @return
*/
public static Amount createAmount(String amount, String currency) {
+ return createAmount(new BigDecimal(amount), currency);
+ }
+
+ /**
+ * Returns an Amount struct to use on requests
+ *
+ * @param amount
+ * @param currency
+ * @return
+ */
+ public static Amount createAmount(BigDecimal amount, String currency) {
Amount amountData = new Amount();
amountData.setCurrency(currency);
Long amountValue;
@@ -46,7 +58,7 @@ public static Amount createAmount(String amount, String currency) {
//Adding decimal point depending on the currency
amountValue = new BigDecimal(10)
.pow(getDecimalPlaces(currency))
- .multiply(new BigDecimal(amount))
+ .multiply(amount)
.longValue();
amountData.setValue(amountValue);
diff --git a/src/main/java/com/adyen/model/AbstractPaymentRequest.java b/src/main/java/com/adyen/model/AbstractPaymentRequest.java
index 447b473a2..fdd5528c4 100644
--- a/src/main/java/com/adyen/model/AbstractPaymentRequest.java
+++ b/src/main/java/com/adyen/model/AbstractPaymentRequest.java
@@ -15,6 +15,7 @@
import com.adyen.serializer.DateSerializer;
import com.adyen.serializer.DateTimeGMTSerializer;
+import com.adyen.model.recurring.Recurring;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
diff --git a/src/main/java/com/adyen/model/RecurringDetail.java b/src/main/java/com/adyen/model/RecurringDetail.java
deleted file mode 100644
index 2b790dc4c..000000000
--- a/src/main/java/com/adyen/model/RecurringDetail.java
+++ /dev/null
@@ -1,490 +0,0 @@
-/*
- * Adyen Wherever People Pay
- * This is the Adyen API Playground where you can test our API's.
You can find out more about Adyen at http://www.adyen.com.
- *
- * OpenAPI spec version: 1.0.0
- *
- *
- * NOTE: This class is auto generated by the swagger code generator program.
- * https://github.com/swagger-api/swagger-codegen.git
- * Do not edit the class manually.
- */
-
-
-package com.adyen.model;
-
-import com.google.gson.annotations.SerializedName;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Date;
-
-/**
- * RecurringDetail
- */
-@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2016-12-14T08:41:23.938Z")
-public class RecurringDetail {
- @SerializedName("name")
- private String name = null;
-
- @SerializedName("creationDate")
- private Date creationDate = null;
-
- @SerializedName("card")
- private Card card = null;
-
- @SerializedName("elv")
- private ELV elv = null;
-
- @SerializedName("billingAddress")
- private Address billingAddress = null;
-
- @SerializedName("additionalData")
- private String additionalData = null;
-
- @SerializedName("shopperName")
- private Name shopperName = null;
-
- @SerializedName("socialSecurityNumber")
- private String socialSecurityNumber = null;
-
- @SerializedName("recurringDetailReference")
- private String recurringDetailReference = null;
-
- @SerializedName("bank")
- private BankAccount bank = null;
-
- @SerializedName("alias")
- private String alias = null;
-
- @SerializedName("aliasType")
- private String aliasType = null;
-
- @SerializedName("tokenDetails")
- private TokenDetails tokenDetails = null;
-
- @SerializedName("variant")
- private String variant = null;
-
- @SerializedName("paymentMethodVariant")
- private String paymentMethodVariant = null;
-
- @SerializedName("firstPspReference")
- private String firstPspReference = null;
-
- @SerializedName("contractTypes")
- private List contractTypes = new ArrayList();
-
- @SerializedName("acquirer")
- private String acquirer = null;
-
- @SerializedName("acquirerAccount")
- private String acquirerAccount = null;
-
- public RecurringDetail name(String name) {
- this.name = name;
- return this;
- }
-
- /**
- * An optional descriptive name for this recurring detail
- * @return name
- **/
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public RecurringDetail creationDate(Date creationDate) {
- this.creationDate = creationDate;
- return this;
- }
-
- /**
- * Get creationDate
- * @return creationDate
- **/
- public Date getCreationDate() {
- return creationDate;
- }
-
- public void setCreationDate(Date creationDate) {
- this.creationDate = creationDate;
- }
-
- public RecurringDetail card(Card card) {
- this.card = card;
- return this;
- }
-
- /**
- * Get card
- * @return card
- **/
- public Card getCard() {
- return card;
- }
-
- public void setCard(Card card) {
- this.card = card;
- }
-
- public RecurringDetail elv(ELV elv) {
- this.elv = elv;
- return this;
- }
-
- /**
- * Get elv
- * @return elv
- **/
- public ELV getElv() {
- return elv;
- }
-
- public void setElv(ELV elv) {
- this.elv = elv;
- }
-
- public RecurringDetail billingAddress(Address billingAddress) {
- this.billingAddress = billingAddress;
- return this;
- }
-
- /**
- * Get billingAddress
- * @return billingAddress
- **/
- public Address getBillingAddress() {
- return billingAddress;
- }
-
- public void setBillingAddress(Address billingAddress) {
- this.billingAddress = billingAddress;
- }
-
- public RecurringDetail additionalData(String additionalData) {
- this.additionalData = additionalData;
- return this;
- }
-
- /**
- * Get additionalData
- * @return additionalData
- **/
- public String getAdditionalData() {
- return additionalData;
- }
-
- public void setAdditionalData(String additionalData) {
- this.additionalData = additionalData;
- }
-
- public RecurringDetail shopperName(Name shopperName) {
- this.shopperName = shopperName;
- return this;
- }
-
- /**
- * Get shopperName
- * @return shopperName
- **/
- public Name getShopperName() {
- return shopperName;
- }
-
- public void setShopperName(Name shopperName) {
- this.shopperName = shopperName;
- }
-
- public RecurringDetail socialSecurityNumber(String socialSecurityNumber) {
- this.socialSecurityNumber = socialSecurityNumber;
- return this;
- }
-
- /**
- * Get socialSecurityNumber
- * @return socialSecurityNumber
- **/
- public String getSocialSecurityNumber() {
- return socialSecurityNumber;
- }
-
- public void setSocialSecurityNumber(String socialSecurityNumber) {
- this.socialSecurityNumber = socialSecurityNumber;
- }
-
- public RecurringDetail recurringDetailReference(String recurringDetailReference) {
- this.recurringDetailReference = recurringDetailReference;
- return this;
- }
-
- /**
- * The reference that uniquely identifies the recurring detail
- * @return recurringDetailReference
- **/
- public String getRecurringDetailReference() {
- return recurringDetailReference;
- }
-
- public void setRecurringDetailReference(String recurringDetailReference) {
- this.recurringDetailReference = recurringDetailReference;
- }
-
- public RecurringDetail bank(BankAccount bank) {
- this.bank = bank;
- return this;
- }
-
- /**
- * Get bank
- * @return bank
- **/
- public BankAccount getBank() {
- return bank;
- }
-
- public void setBank(BankAccount bank) {
- this.bank = bank;
- }
-
- public RecurringDetail alias(String alias) {
- this.alias = alias;
- return this;
- }
-
- /**
- * Get alias
- * @return alias
- **/
- public String getAlias() {
- return alias;
- }
-
- public void setAlias(String alias) {
- this.alias = alias;
- }
-
- public RecurringDetail aliasType(String aliasType) {
- this.aliasType = aliasType;
- return this;
- }
-
- /**
- * Get aliasType
- * @return aliasType
- **/
- public String getAliasType() {
- return aliasType;
- }
-
- public void setAliasType(String aliasType) {
- this.aliasType = aliasType;
- }
-
- public RecurringDetail tokenDetails(TokenDetails tokenDetails) {
- this.tokenDetails = tokenDetails;
- return this;
- }
-
- /**
- * Get tokenDetails
- * @return tokenDetails
- **/
- public TokenDetails getTokenDetails() {
- return tokenDetails;
- }
-
- public void setTokenDetails(TokenDetails tokenDetails) {
- this.tokenDetails = tokenDetails;
- }
-
- public RecurringDetail variant(String variant) {
- this.variant = variant;
- return this;
- }
-
- /**
- * Get variant
- * @return variant
- **/
- public String getVariant() {
- return variant;
- }
-
- public void setVariant(String variant) {
- this.variant = variant;
- }
-
- public RecurringDetail paymentMethodVariant(String paymentMethodVariant) {
- this.paymentMethodVariant = paymentMethodVariant;
- return this;
- }
-
- /**
- * Get paymentMethodVariant
- * @return paymentMethodVariant
- **/
- public String getPaymentMethodVariant() {
- return paymentMethodVariant;
- }
-
- public void setPaymentMethodVariant(String paymentMethodVariant) {
- this.paymentMethodVariant = paymentMethodVariant;
- }
-
- public RecurringDetail firstPspReference(String firstPspReference) {
- this.firstPspReference = firstPspReference;
- return this;
- }
-
- /**
- * Get firstPspReference
- * @return firstPspReference
- **/
- public String getFirstPspReference() {
- return firstPspReference;
- }
-
- public void setFirstPspReference(String firstPspReference) {
- this.firstPspReference = firstPspReference;
- }
-
- public RecurringDetail contractTypes(List contractTypes) {
- this.contractTypes = contractTypes;
- return this;
- }
-
- public RecurringDetail addContractTypesItem(String contractTypesItem) {
- this.contractTypes.add(contractTypesItem);
- return this;
- }
-
- /**
- * Get contractTypes
- * @return contractTypes
- **/
- public List getContractTypes() {
- return contractTypes;
- }
-
- public void setContractTypes(List contractTypes) {
- this.contractTypes = contractTypes;
- }
-
- public RecurringDetail acquirer(String acquirer) {
- this.acquirer = acquirer;
- return this;
- }
-
- /**
- * Get acquirer
- * @return acquirer
- **/
- public String getAcquirer() {
- return acquirer;
- }
-
- public void setAcquirer(String acquirer) {
- this.acquirer = acquirer;
- }
-
- public RecurringDetail acquirerAccount(String acquirerAccount) {
- this.acquirerAccount = acquirerAccount;
- return this;
- }
-
- /**
- * Get acquirerAccount
- * @return acquirerAccount
- **/
- public String getAcquirerAccount() {
- return acquirerAccount;
- }
-
- public void setAcquirerAccount(String acquirerAccount) {
- this.acquirerAccount = acquirerAccount;
- }
-
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- RecurringDetail recurringDetail = (RecurringDetail) o;
- return Objects.equals(this.name, recurringDetail.name) &&
- Objects.equals(this.creationDate, recurringDetail.creationDate) &&
- Objects.equals(this.card, recurringDetail.card) &&
- Objects.equals(this.elv, recurringDetail.elv) &&
- Objects.equals(this.billingAddress, recurringDetail.billingAddress) &&
- Objects.equals(this.additionalData, recurringDetail.additionalData) &&
- Objects.equals(this.shopperName, recurringDetail.shopperName) &&
- Objects.equals(this.socialSecurityNumber, recurringDetail.socialSecurityNumber) &&
- Objects.equals(this.recurringDetailReference, recurringDetail.recurringDetailReference) &&
- Objects.equals(this.bank, recurringDetail.bank) &&
- Objects.equals(this.alias, recurringDetail.alias) &&
- Objects.equals(this.aliasType, recurringDetail.aliasType) &&
- Objects.equals(this.tokenDetails, recurringDetail.tokenDetails) &&
- Objects.equals(this.variant, recurringDetail.variant) &&
- Objects.equals(this.paymentMethodVariant, recurringDetail.paymentMethodVariant) &&
- Objects.equals(this.firstPspReference, recurringDetail.firstPspReference) &&
- Objects.equals(this.contractTypes, recurringDetail.contractTypes) &&
- Objects.equals(this.acquirer, recurringDetail.acquirer) &&
- Objects.equals(this.acquirerAccount, recurringDetail.acquirerAccount);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name, creationDate, card, elv, billingAddress, additionalData, shopperName, socialSecurityNumber, recurringDetailReference, bank, alias, aliasType, tokenDetails, variant, paymentMethodVariant, firstPspReference, contractTypes, acquirer, acquirerAccount);
- }
-
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("class RecurringDetail {\n");
-
- sb.append(" name: ").append(toIndentedString(name)).append("\n");
- sb.append(" creationDate: ").append(toIndentedString(creationDate)).append("\n");
- sb.append(" card: ").append(toIndentedString(card)).append("\n");
- sb.append(" elv: ").append(toIndentedString(elv)).append("\n");
- sb.append(" billingAddress: ").append(toIndentedString(billingAddress)).append("\n");
- sb.append(" additionalData: ").append(toIndentedString(additionalData)).append("\n");
- sb.append(" shopperName: ").append(toIndentedString(shopperName)).append("\n");
- sb.append(" socialSecurityNumber: ").append(toIndentedString(socialSecurityNumber)).append("\n");
- sb.append(" recurringDetailReference: ").append(toIndentedString(recurringDetailReference)).append("\n");
- sb.append(" bank: ").append(toIndentedString(bank)).append("\n");
- sb.append(" alias: ").append(toIndentedString(alias)).append("\n");
- sb.append(" aliasType: ").append(toIndentedString(aliasType)).append("\n");
- sb.append(" tokenDetails: ").append(toIndentedString(tokenDetails)).append("\n");
- sb.append(" variant: ").append(toIndentedString(variant)).append("\n");
- sb.append(" paymentMethodVariant: ").append(toIndentedString(paymentMethodVariant)).append("\n");
- sb.append(" firstPspReference: ").append(toIndentedString(firstPspReference)).append("\n");
- sb.append(" contractTypes: ").append(toIndentedString(contractTypes)).append("\n");
- sb.append(" acquirer: ").append(toIndentedString(acquirer)).append("\n");
- sb.append(" acquirerAccount: ").append(toIndentedString(acquirerAccount)).append("\n");
- sb.append("}");
- return sb.toString();
- }
-
- /**
- * Convert the given object to string with each line indented by 4 spaces
- * (except the first line).
- */
- private String toIndentedString(Object o) {
- if (o == null) {
- return "null";
- }
- return o.toString().replace("\n", "\n ");
- }
-
-}
-
diff --git a/src/main/java/com/adyen/model/RecurringDetailsRequest.java b/src/main/java/com/adyen/model/RecurringDetailsRequest.java
deleted file mode 100644
index 20fdd4947..000000000
--- a/src/main/java/com/adyen/model/RecurringDetailsRequest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Adyen Wherever People Pay
- * This is the Adyen API Playground where you can test our API's.
You can find out more about Adyen at http://www.adyen.com.
- *
- * OpenAPI spec version: 1.0.0
- *
- *
- * NOTE: This class is auto generated by the swagger code generator program.
- * https://github.com/swagger-api/swagger-codegen.git
- * Do not edit the class manually.
- */
-
-
-package com.adyen.model;
-
-import com.google.gson.annotations.SerializedName;
-
-import java.util.Objects;
-
-/**
- * RecurringDetailsRequest
- */
-@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2016-12-14T08:41:23.938Z")
-public class RecurringDetailsRequest {
- @SerializedName("merchantAccount")
- private String merchantAccount = null;
-
- @SerializedName("shopperReference")
- private String shopperReference = null;
-
- @SerializedName("recurring")
- private Recurring recurring = null;
-
- public RecurringDetailsRequest merchantAccount(String merchantAccount) {
- this.merchantAccount = merchantAccount;
- return this;
- }
-
- /**
- * the merchant account which will be used for processing this request
- * @return merchantAccount
- **/
- public String getMerchantAccount() {
- return merchantAccount;
- }
-
- public void setMerchantAccount(String merchantAccount) {
- this.merchantAccount = merchantAccount;
- }
-
- public RecurringDetailsRequest shopperReference(String shopperReference) {
- this.shopperReference = shopperReference;
- return this;
- }
-
- /**
- * a reference you use to uniquely identify the shopper (e.g. user ID or account ID)
- * @return shopperReference
- **/
- public String getShopperReference() {
- return shopperReference;
- }
-
- public void setShopperReference(String shopperReference) {
- this.shopperReference = shopperReference;
- }
-
- public RecurringDetailsRequest recurring(Recurring recurring) {
- this.recurring = recurring;
- return this;
- }
-
- /**
- * the type of recurring contract to be used.
- * @return recurring
- **/
- public Recurring getRecurring() {
- return recurring;
- }
-
- public void setRecurring(Recurring recurring) {
- this.recurring = recurring;
- }
-
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- RecurringDetailsRequest recurringDetailsRequest = (RecurringDetailsRequest) o;
- return Objects.equals(this.merchantAccount, recurringDetailsRequest.merchantAccount) &&
- Objects.equals(this.shopperReference, recurringDetailsRequest.shopperReference) &&
- Objects.equals(this.recurring, recurringDetailsRequest.recurring);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(merchantAccount, shopperReference, recurring);
- }
-
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("class RecurringDetailsRequest {\n");
-
- sb.append(" merchantAccount: ").append(toIndentedString(merchantAccount)).append("\n");
- sb.append(" shopperReference: ").append(toIndentedString(shopperReference)).append("\n");
- sb.append(" recurring: ").append(toIndentedString(recurring)).append("\n");
- sb.append("}");
- return sb.toString();
- }
-
- /**
- * Convert the given object to string with each line indented by 4 spaces
- * (except the first line).
- */
- private String toIndentedString(Object o) {
- if (o == null) {
- return "null";
- }
- return o.toString().replace("\n", "\n ");
- }
-
-}
-
diff --git a/src/main/java/com/adyen/model/RecurringDetailsResult.java b/src/main/java/com/adyen/model/RecurringDetailsResult.java
deleted file mode 100644
index 3c12f0a29..000000000
--- a/src/main/java/com/adyen/model/RecurringDetailsResult.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Adyen Wherever People Pay
- * This is the Adyen API Playground where you can test our API's.
You can find out more about Adyen at http://www.adyen.com.
- *
- * OpenAPI spec version: 1.0.0
- *
- *
- * NOTE: This class is auto generated by the swagger code generator program.
- * https://github.com/swagger-api/swagger-codegen.git
- * Do not edit the class manually.
- */
-
-
-package com.adyen.model;
-
-import com.google.gson.annotations.SerializedName;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Date;
-
-/**
- * RecurringDetailsResult
- */
-@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2016-12-14T08:41:23.938Z")
-public class RecurringDetailsResult {
- @SerializedName("creationDate")
- private Date creationDate = null;
-
- @SerializedName("shopperReference")
- private String shopperReference = null;
-
- @SerializedName("details")
- private List details = new ArrayList();
-
- @SerializedName("lastKnownShopperEmail")
- private String lastKnownShopperEmail = null;
-
- public RecurringDetailsResult creationDate(Date creationDate) {
- this.creationDate = creationDate;
- return this;
- }
-
- /**
- * the creation date when the shopper record was created
- * @return creationDate
- **/
- public Date getCreationDate() {
- return creationDate;
- }
-
- public void setCreationDate(Date creationDate) {
- this.creationDate = creationDate;
- }
-
- public RecurringDetailsResult shopperReference(String shopperReference) {
- this.shopperReference = shopperReference;
- return this;
- }
-
- /**
- * the reference you use to uniquely identify the shopper (e.g. user ID or account ID)
- * @return shopperReference
- **/
- public String getShopperReference() {
- return shopperReference;
- }
-
- public void setShopperReference(String shopperReference) {
- this.shopperReference = shopperReference;
- }
-
- public RecurringDetailsResult details(List details) {
- this.details = details;
- return this;
- }
-
- public RecurringDetailsResult addDetailsItem(RecurringDetail detailsItem) {
- this.details.add(detailsItem);
- return this;
- }
-
- /**
- * a list of one or more recurring payment details
- * @return details
- **/
- public List getDetails() {
- return details;
- }
-
- public void setDetails(List details) {
- this.details = details;
- }
-
- public RecurringDetailsResult lastKnownShopperEmail(String lastKnownShopperEmail) {
- this.lastKnownShopperEmail = lastKnownShopperEmail;
- return this;
- }
-
- /**
- * the most recent email for this shopper (if available)
- * @return lastKnownShopperEmail
- **/
- public String getLastKnownShopperEmail() {
- return lastKnownShopperEmail;
- }
-
- public void setLastKnownShopperEmail(String lastKnownShopperEmail) {
- this.lastKnownShopperEmail = lastKnownShopperEmail;
- }
-
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- RecurringDetailsResult recurringDetailsResult = (RecurringDetailsResult) o;
- return Objects.equals(this.creationDate, recurringDetailsResult.creationDate) &&
- Objects.equals(this.shopperReference, recurringDetailsResult.shopperReference) &&
- Objects.equals(this.details, recurringDetailsResult.details) &&
- Objects.equals(this.lastKnownShopperEmail, recurringDetailsResult.lastKnownShopperEmail);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(creationDate, shopperReference, details, lastKnownShopperEmail);
- }
-
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("class RecurringDetailsResult {\n");
-
- sb.append(" creationDate: ").append(toIndentedString(creationDate)).append("\n");
- sb.append(" shopperReference: ").append(toIndentedString(shopperReference)).append("\n");
- sb.append(" details: ").append(toIndentedString(details)).append("\n");
- sb.append(" lastKnownShopperEmail: ").append(toIndentedString(lastKnownShopperEmail)).append("\n");
- sb.append("}");
- return sb.toString();
- }
-
- /**
- * Convert the given object to string with each line indented by 4 spaces
- * (except the first line).
- */
- private String toIndentedString(Object o) {
- if (o == null) {
- return "null";
- }
- return o.toString().replace("\n", "\n ");
- }
-
-}
-
diff --git a/src/main/java/com/adyen/model/DisableRequest.java b/src/main/java/com/adyen/model/recurring/DisableRequest.java
similarity index 99%
rename from src/main/java/com/adyen/model/DisableRequest.java
rename to src/main/java/com/adyen/model/recurring/DisableRequest.java
index 3dd50d639..d06e35b1d 100644
--- a/src/main/java/com/adyen/model/DisableRequest.java
+++ b/src/main/java/com/adyen/model/recurring/DisableRequest.java
@@ -11,7 +11,7 @@
*/
-package com.adyen.model;
+package com.adyen.model.recurring;
import com.google.gson.annotations.SerializedName;
diff --git a/src/main/java/com/adyen/model/DisableResult.java b/src/main/java/com/adyen/model/recurring/DisableResult.java
similarity index 98%
rename from src/main/java/com/adyen/model/DisableResult.java
rename to src/main/java/com/adyen/model/recurring/DisableResult.java
index cd27b175c..65406d481 100644
--- a/src/main/java/com/adyen/model/DisableResult.java
+++ b/src/main/java/com/adyen/model/recurring/DisableResult.java
@@ -11,7 +11,7 @@
*/
-package com.adyen.model;
+package com.adyen.model.recurring;
import com.google.gson.annotations.SerializedName;
diff --git a/src/main/java/com/adyen/model/Recurring.java b/src/main/java/com/adyen/model/recurring/Recurring.java
similarity index 98%
rename from src/main/java/com/adyen/model/Recurring.java
rename to src/main/java/com/adyen/model/recurring/Recurring.java
index 34c107272..e1afc12e7 100644
--- a/src/main/java/com/adyen/model/Recurring.java
+++ b/src/main/java/com/adyen/model/recurring/Recurring.java
@@ -11,7 +11,7 @@
*/
-package com.adyen.model;
+package com.adyen.model.recurring;
import com.google.gson.annotations.SerializedName;
diff --git a/src/main/java/com/adyen/model/recurring/RecurringDetail.java b/src/main/java/com/adyen/model/recurring/RecurringDetail.java
new file mode 100644
index 000000000..f58d4885a
--- /dev/null
+++ b/src/main/java/com/adyen/model/recurring/RecurringDetail.java
@@ -0,0 +1,449 @@
+package com.adyen.model.recurring;
+
+import com.adyen.model.*;
+import com.google.gson.annotations.SerializedName;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * RecurringDetail
+ */
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2016-12-14T08:41:23.938Z")
+public class RecurringDetail {
+ @SerializedName("name")
+ private String name = null;
+
+ @SerializedName("creationDate")
+ private Date creationDate = null;
+
+ @SerializedName("card")
+ private Card card = null;
+
+ @SerializedName("elv")
+ private ELV elv = null;
+
+ @SerializedName("billingAddress")
+ private Address billingAddress = null;
+
+ @SerializedName("additionalData")
+ private Map additionalData = null;
+
+ @SerializedName("shopperName")
+ private Name shopperName = null;
+
+ @SerializedName("socialSecurityNumber")
+ private String socialSecurityNumber = null;
+
+ @SerializedName("recurringDetailReference")
+ private String recurringDetailReference = null;
+
+ @SerializedName("bank")
+ private BankAccount bank = null;
+
+ @SerializedName("alias")
+ private String alias = null;
+
+ @SerializedName("aliasType")
+ private String aliasType = null;
+
+ @SerializedName("tokenDetails")
+ private TokenDetails tokenDetails = null;
+
+ @SerializedName("variant")
+ private String variant = null;
+
+ @SerializedName("paymentMethodVariant")
+ private String paymentMethodVariant = null;
+
+ @SerializedName("firstPspReference")
+ private String firstPspReference = null;
+
+ @SerializedName("contractTypes")
+ private List contractTypes = new ArrayList();
+
+ @SerializedName("acquirer")
+ private String acquirer = null;
+
+ @SerializedName("acquirerAccount")
+ private String acquirerAccount = null;
+
+ public RecurringDetail name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * An optional descriptive name for this recurring detail
+ *
+ * @return name
+ **/
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public RecurringDetail creationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ return this;
+ }
+
+ /**
+ * Get creationDate
+ *
+ * @return creationDate
+ **/
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public RecurringDetail card(Card card) {
+ this.card = card;
+ return this;
+ }
+
+ /**
+ * Get card
+ *
+ * @return card
+ **/
+ public Card getCard() {
+ return card;
+ }
+
+ public void setCard(Card card) {
+ this.card = card;
+ }
+
+ public RecurringDetail elv(ELV elv) {
+ this.elv = elv;
+ return this;
+ }
+
+ /**
+ * Get elv
+ *
+ * @return elv
+ **/
+ public ELV getElv() {
+ return elv;
+ }
+
+ public void setElv(ELV elv) {
+ this.elv = elv;
+ }
+
+ public RecurringDetail billingAddress(Address billingAddress) {
+ this.billingAddress = billingAddress;
+ return this;
+ }
+
+ /**
+ * Get billingAddress
+ *
+ * @return billingAddress
+ **/
+ public Address getBillingAddress() {
+ return billingAddress;
+ }
+
+ public void setBillingAddress(Address billingAddress) {
+ this.billingAddress = billingAddress;
+ }
+
+ public Map getAdditionalData() {
+ return additionalData;
+ }
+
+ public void setAdditionalData(Map additionalData) {
+ this.additionalData = additionalData;
+ }
+
+ public RecurringDetail shopperName(Name shopperName) {
+ this.shopperName = shopperName;
+ return this;
+ }
+
+ /**
+ * Get shopperName
+ *
+ * @return shopperName
+ **/
+ public Name getShopperName() {
+ return shopperName;
+ }
+
+ public void setShopperName(Name shopperName) {
+ this.shopperName = shopperName;
+ }
+
+ public RecurringDetail socialSecurityNumber(String socialSecurityNumber) {
+ this.socialSecurityNumber = socialSecurityNumber;
+ return this;
+ }
+
+ /**
+ * Get socialSecurityNumber
+ *
+ * @return socialSecurityNumber
+ **/
+ public String getSocialSecurityNumber() {
+ return socialSecurityNumber;
+ }
+
+ public void setSocialSecurityNumber(String socialSecurityNumber) {
+ this.socialSecurityNumber = socialSecurityNumber;
+ }
+
+ public RecurringDetail recurringDetailReference(String recurringDetailReference) {
+ this.recurringDetailReference = recurringDetailReference;
+ return this;
+ }
+
+ /**
+ * The reference that uniquely identifies the recurring detail
+ *
+ * @return recurringDetailReference
+ **/
+ public String getRecurringDetailReference() {
+ return recurringDetailReference;
+ }
+
+ public void setRecurringDetailReference(String recurringDetailReference) {
+ this.recurringDetailReference = recurringDetailReference;
+ }
+
+ public RecurringDetail bank(BankAccount bank) {
+ this.bank = bank;
+ return this;
+ }
+
+ /**
+ * Get bank
+ *
+ * @return bank
+ **/
+ public BankAccount getBank() {
+ return bank;
+ }
+
+ public void setBank(BankAccount bank) {
+ this.bank = bank;
+ }
+
+ public RecurringDetail alias(String alias) {
+ this.alias = alias;
+ return this;
+ }
+
+ /**
+ * Get alias
+ *
+ * @return alias
+ **/
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ public RecurringDetail aliasType(String aliasType) {
+ this.aliasType = aliasType;
+ return this;
+ }
+
+ /**
+ * Get aliasType
+ *
+ * @return aliasType
+ **/
+ public String getAliasType() {
+ return aliasType;
+ }
+
+ public void setAliasType(String aliasType) {
+ this.aliasType = aliasType;
+ }
+
+ public RecurringDetail tokenDetails(TokenDetails tokenDetails) {
+ this.tokenDetails = tokenDetails;
+ return this;
+ }
+
+ /**
+ * Get tokenDetails
+ *
+ * @return tokenDetails
+ **/
+ public TokenDetails getTokenDetails() {
+ return tokenDetails;
+ }
+
+ public void setTokenDetails(TokenDetails tokenDetails) {
+ this.tokenDetails = tokenDetails;
+ }
+
+ public RecurringDetail variant(String variant) {
+ this.variant = variant;
+ return this;
+ }
+
+ /**
+ * Get variant
+ *
+ * @return variant
+ **/
+ public String getVariant() {
+ return variant;
+ }
+
+ public void setVariant(String variant) {
+ this.variant = variant;
+ }
+
+ public RecurringDetail paymentMethodVariant(String paymentMethodVariant) {
+ this.paymentMethodVariant = paymentMethodVariant;
+ return this;
+ }
+
+ /**
+ * Get paymentMethodVariant
+ *
+ * @return paymentMethodVariant
+ **/
+ public String getPaymentMethodVariant() {
+ return paymentMethodVariant;
+ }
+
+ public void setPaymentMethodVariant(String paymentMethodVariant) {
+ this.paymentMethodVariant = paymentMethodVariant;
+ }
+
+ public RecurringDetail firstPspReference(String firstPspReference) {
+ this.firstPspReference = firstPspReference;
+ return this;
+ }
+
+ /**
+ * Get firstPspReference
+ *
+ * @return firstPspReference
+ **/
+ public String getFirstPspReference() {
+ return firstPspReference;
+ }
+
+ public void setFirstPspReference(String firstPspReference) {
+ this.firstPspReference = firstPspReference;
+ }
+
+ public RecurringDetail contractTypes(List contractTypes) {
+ this.contractTypes = contractTypes;
+ return this;
+ }
+
+ public RecurringDetail addContractTypesItem(String contractTypesItem) {
+ this.contractTypes.add(contractTypesItem);
+ return this;
+ }
+
+ /**
+ * Get contractTypes
+ *
+ * @return contractTypes
+ **/
+ public List getContractTypes() {
+ return contractTypes;
+ }
+
+ public void setContractTypes(List contractTypes) {
+ this.contractTypes = contractTypes;
+ }
+
+ public RecurringDetail acquirer(String acquirer) {
+ this.acquirer = acquirer;
+ return this;
+ }
+
+ /**
+ * Get acquirer
+ *
+ * @return acquirer
+ **/
+ public String getAcquirer() {
+ return acquirer;
+ }
+
+ public void setAcquirer(String acquirer) {
+ this.acquirer = acquirer;
+ }
+
+ public RecurringDetail acquirerAccount(String acquirerAccount) {
+ this.acquirerAccount = acquirerAccount;
+ return this;
+ }
+
+ /**
+ * Get acquirerAccount
+ *
+ * @return acquirerAccount
+ **/
+ public String getAcquirerAccount() {
+ return acquirerAccount;
+ }
+
+ public void setAcquirerAccount(String acquirerAccount) {
+ this.acquirerAccount = acquirerAccount;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class RecurringDetail {\n");
+
+ sb.append(" name: ").append(toIndentedString(name)).append("\n");
+ sb.append(" creationDate: ").append(toIndentedString(creationDate)).append("\n");
+ sb.append(" card: ").append(toIndentedString(card)).append("\n");
+ sb.append(" elv: ").append(toIndentedString(elv)).append("\n");
+ sb.append(" billingAddress: ").append(toIndentedString(billingAddress)).append("\n");
+ sb.append(" additionalData: ").append(toIndentedString(additionalData)).append("\n");
+ sb.append(" shopperName: ").append(toIndentedString(shopperName)).append("\n");
+ sb.append(" socialSecurityNumber: ").append(toIndentedString(socialSecurityNumber)).append("\n");
+ sb.append(" recurringDetailReference: ").append(toIndentedString(recurringDetailReference)).append("\n");
+ sb.append(" bank: ").append(toIndentedString(bank)).append("\n");
+ sb.append(" alias: ").append(toIndentedString(alias)).append("\n");
+ sb.append(" aliasType: ").append(toIndentedString(aliasType)).append("\n");
+ sb.append(" tokenDetails: ").append(toIndentedString(tokenDetails)).append("\n");
+ sb.append(" variant: ").append(toIndentedString(variant)).append("\n");
+ sb.append(" paymentMethodVariant: ").append(toIndentedString(paymentMethodVariant)).append("\n");
+ sb.append(" firstPspReference: ").append(toIndentedString(firstPspReference)).append("\n");
+ sb.append(" contractTypes: ").append(toIndentedString(contractTypes)).append("\n");
+ sb.append(" acquirer: ").append(toIndentedString(acquirer)).append("\n");
+ sb.append(" acquirerAccount: ").append(toIndentedString(acquirerAccount)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/main/java/com/adyen/model/recurring/RecurringDetailContainer.java b/src/main/java/com/adyen/model/recurring/RecurringDetailContainer.java
new file mode 100644
index 000000000..b93799241
--- /dev/null
+++ b/src/main/java/com/adyen/model/recurring/RecurringDetailContainer.java
@@ -0,0 +1,40 @@
+package com.adyen.model.recurring;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Container for RecurringDetail
+ */
+public class RecurringDetailContainer {
+ @SerializedName("RecurringDetail")
+ private RecurringDetail recurringDetail = null;
+
+ public RecurringDetail getRecurringDetail() {
+ return recurringDetail;
+ }
+
+ public void setRecurringDetail(RecurringDetail recurringDetail) {
+ this.recurringDetail = recurringDetail;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class RecurringDetailContainer {\n");
+
+ sb.append(" recurringDetail: ").append(toIndentedString(recurringDetail)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
diff --git a/src/main/java/com/adyen/model/recurring/RecurringDetailsRequest.java b/src/main/java/com/adyen/model/recurring/RecurringDetailsRequest.java
new file mode 100644
index 000000000..8fc867d2b
--- /dev/null
+++ b/src/main/java/com/adyen/model/recurring/RecurringDetailsRequest.java
@@ -0,0 +1,125 @@
+/*
+ * Adyen Wherever People Pay
+ * This is the Adyen API Playground where you can test our API's.
You can find out more about Adyen at http://www.adyen.com.
+ *
+ * OpenAPI spec version: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by the swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen.git
+ * Do not edit the class manually.
+ */
+
+
+package com.adyen.model.recurring;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * RecurringDetailsRequest
+ */
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2016-12-14T08:41:23.938Z")
+public class RecurringDetailsRequest {
+ @SerializedName("merchantAccount")
+ private String merchantAccount = null;
+
+ @SerializedName("shopperReference")
+ private String shopperReference = null;
+
+ @SerializedName("recurring")
+ private Recurring recurring = null;
+
+ public RecurringDetailsRequest merchantAccount(String merchantAccount) {
+ this.merchantAccount = merchantAccount;
+ return this;
+ }
+
+ /**
+ * the merchant account which will be used for processing this request
+ *
+ * @return merchantAccount
+ **/
+ public String getMerchantAccount() {
+ return merchantAccount;
+ }
+
+ public void setMerchantAccount(String merchantAccount) {
+ this.merchantAccount = merchantAccount;
+ }
+
+ public RecurringDetailsRequest shopperReference(String shopperReference) {
+ this.shopperReference = shopperReference;
+ return this;
+ }
+
+ /**
+ * a reference you use to uniquely identify the shopper (e.g. user ID or account ID)
+ *
+ * @return shopperReference
+ **/
+ public String getShopperReference() {
+ return shopperReference;
+ }
+
+ public void setShopperReference(String shopperReference) {
+ this.shopperReference = shopperReference;
+ }
+
+ public RecurringDetailsRequest recurring(Recurring recurring) {
+ this.recurring = recurring;
+ return this;
+ }
+
+ /**
+ * the type of recurring contract to be used.
+ *
+ * @return recurring
+ **/
+ public Recurring getRecurring() {
+ return recurring;
+ }
+
+ public void setRecurring(Recurring recurring) {
+ this.recurring = recurring;
+ }
+
+ public RecurringDetailsRequest selectRecurringContract() {
+ Recurring recurring = new Recurring();
+ recurring.contract(Recurring.ContractEnum.RECURRING);
+ setRecurring(recurring);
+
+ return this;
+ }
+
+ public RecurringDetailsRequest selectOneClickContract() {
+ Recurring recurring = new Recurring();
+ recurring.contract(Recurring.ContractEnum.ONECLICK);
+ setRecurring(recurring);
+
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class RecurringDetailsRequest {\n");
+
+ sb.append(" merchantAccount: ").append(toIndentedString(merchantAccount)).append("\n");
+ sb.append(" shopperReference: ").append(toIndentedString(shopperReference)).append("\n");
+ sb.append(" recurring: ").append(toIndentedString(recurring)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/main/java/com/adyen/model/recurring/RecurringDetailsResult.java b/src/main/java/com/adyen/model/recurring/RecurringDetailsResult.java
new file mode 100644
index 000000000..898cadde3
--- /dev/null
+++ b/src/main/java/com/adyen/model/recurring/RecurringDetailsResult.java
@@ -0,0 +1,176 @@
+/*
+ * Adyen Wherever People Pay
+ * This is the Adyen API Playground where you can test our API's.
You can find out more about Adyen at http://www.adyen.com.
+ *
+ * OpenAPI spec version: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by the swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen.git
+ * Do not edit the class manually.
+ */
+
+
+package com.adyen.model.recurring;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * RecurringDetailsResult
+ */
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2016-12-14T08:41:23.938Z")
+public class RecurringDetailsResult {
+ @SerializedName("creationDate")
+ private Date creationDate = null;
+
+ @SerializedName("shopperReference")
+ private String shopperReference = null;
+
+ @SerializedName("details")
+ private List details = new ArrayList();
+
+ @SerializedName("lastKnownShopperEmail")
+ private String lastKnownShopperEmail = null;
+
+ public RecurringDetailsResult creationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ return this;
+ }
+
+ /**
+ * the creation date when the shopper record was created
+ *
+ * @return creationDate
+ **/
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ public RecurringDetailsResult shopperReference(String shopperReference) {
+ this.shopperReference = shopperReference;
+ return this;
+ }
+
+ /**
+ * the reference you use to uniquely identify the shopper (e.g. user ID or account ID)
+ *
+ * @return shopperReference
+ **/
+ public String getShopperReference() {
+ return shopperReference;
+ }
+
+ public void setShopperReference(String shopperReference) {
+ this.shopperReference = shopperReference;
+ }
+
+ public RecurringDetailsResult details(List details) {
+ this.details = details;
+ return this;
+ }
+
+ public RecurringDetailsResult addDetailsItem(RecurringDetailContainer detailsItem) {
+ this.details.add(detailsItem);
+ return this;
+ }
+
+ /**
+ * a list of one or more recurring payment details
+ *
+ * @return details
+ **/
+ public List getDetails() {
+ return details;
+ }
+
+ public void setDetails(List details) {
+ this.details = details;
+ }
+
+ public RecurringDetailsResult lastKnownShopperEmail(String lastKnownShopperEmail) {
+ this.lastKnownShopperEmail = lastKnownShopperEmail;
+ return this;
+ }
+
+ /**
+ * the most recent email for this shopper (if available)
+ *
+ * @return lastKnownShopperEmail
+ **/
+ public String getLastKnownShopperEmail() {
+ return lastKnownShopperEmail;
+ }
+
+ public void setLastKnownShopperEmail(String lastKnownShopperEmail) {
+ this.lastKnownShopperEmail = lastKnownShopperEmail;
+ }
+
+ /**
+ * Return RecurringDetails
+ *
+ * @return
+ */
+ public List getRecurringDetails() {
+ List recurringDetails = new ArrayList<>();
+ for (RecurringDetailContainer recurringDetailContainer : details) {
+ recurringDetails.add(recurringDetailContainer.getRecurringDetail());
+ }
+ return recurringDetails;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ RecurringDetailsResult recurringDetailsResult = (RecurringDetailsResult) o;
+ return Objects.equals(this.creationDate, recurringDetailsResult.creationDate) &&
+ Objects.equals(this.shopperReference, recurringDetailsResult.shopperReference) &&
+ Objects.equals(this.details, recurringDetailsResult.details) &&
+ Objects.equals(this.lastKnownShopperEmail, recurringDetailsResult.lastKnownShopperEmail);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(creationDate, shopperReference, details, lastKnownShopperEmail);
+ }
+
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class RecurringDetailsResult {\n");
+
+ sb.append(" creationDate: ").append(toIndentedString(creationDate)).append("\n");
+ sb.append(" shopperReference: ").append(toIndentedString(shopperReference)).append("\n");
+ sb.append(" details: ").append(toIndentedString(details)).append("\n");
+ sb.append(" lastKnownShopperEmail: ").append(toIndentedString(lastKnownShopperEmail)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+
+}
+
diff --git a/src/main/java/com/adyen/notification/NotificationHandler.java b/src/main/java/com/adyen/notification/NotificationHandler.java
index 1310c0dd2..b7638cdfa 100644
--- a/src/main/java/com/adyen/notification/NotificationHandler.java
+++ b/src/main/java/com/adyen/notification/NotificationHandler.java
@@ -2,7 +2,6 @@
import com.adyen.model.notification.NotificationRequest;
import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
/**
@@ -10,9 +9,7 @@
*/
public class NotificationHandler {
public NotificationRequest handleNotificationJson(String json) {
- GsonBuilder gsonBuilder = new GsonBuilder();
- gsonBuilder.setDateFormat("yyyy-MM-dd'T'HH:mm:ss");
- Gson gson = gsonBuilder.create();
+ Gson gson = new Gson();
NotificationRequest notificationRequest = gson.fromJson(json, new TypeToken() {
}.getType());
diff --git a/src/main/java/com/adyen/service/Recurring.java b/src/main/java/com/adyen/service/Recurring.java
index 5f90b6489..e7a3c6eec 100644
--- a/src/main/java/com/adyen/service/Recurring.java
+++ b/src/main/java/com/adyen/service/Recurring.java
@@ -2,12 +2,41 @@
import com.adyen.Client;
import com.adyen.Service;
+import com.adyen.model.recurring.RecurringDetailsRequest;
+import com.adyen.model.recurring.RecurringDetailsResult;
+import com.adyen.service.exception.ApiException;
+import com.adyen.service.resource.recurring.ListRecurringDetails;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
-public class Recurring extends Service{
+import java.io.IOException;
- Recurring(Client client) {
- super(client);
- // TODO Auto-generated constructor stub
- }
+public class Recurring extends Service {
+ private ListRecurringDetails listRecurringDetails;
+ public Recurring(Client client) {
+ super(client);
+
+ listRecurringDetails = new ListRecurringDetails(this);
+ }
+
+ /**
+ * Issues a listRecurringDetails API call
+ *
+ * @param request
+ * @return
+ * @throws IOException
+ * @throws ApiException
+ */
+ public RecurringDetailsResult listRecurringDetails(RecurringDetailsRequest request) throws IOException, ApiException {
+ Gson gson = new Gson();
+
+ String jsonRequest = gson.toJson(request);
+
+ String jsonResult = listRecurringDetails.request(jsonRequest);
+
+ RecurringDetailsResult result = gson.fromJson(jsonResult, new TypeToken() {
+ }.getType());
+ return result;
+ }
}
diff --git a/src/main/java/com/adyen/service/Resource.java b/src/main/java/com/adyen/service/Resource.java
index e2010a07f..240800628 100644
--- a/src/main/java/com/adyen/service/Resource.java
+++ b/src/main/java/com/adyen/service/Resource.java
@@ -1,13 +1,11 @@
package com.adyen.service;
import com.adyen.Config;
-import com.adyen.Request;
import com.adyen.Service;
import com.adyen.Util.Util;
import com.adyen.httpclient.ClientInterface;
import com.adyen.httpclient.HTTPClientException;
import com.adyen.model.ApiError;
-import com.adyen.model.PaymentResult;
import com.adyen.service.exception.ApiException;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@@ -16,11 +14,11 @@
import java.util.*;
public class Resource {
-
- private Service service;
+
+ private Service service;
protected String endpoint;
protected List requiredFields;
-
+
public Resource(Service service, String endpoint, List requiredFields) {
this.service = service;
@@ -28,14 +26,13 @@ public Resource(Service service, String endpoint, List requiredFields) {
this.requiredFields = requiredFields;
}
- public Map request(Map params) throws Exception
- {
- // validate parameters
+ public Map request(Map params) throws Exception {
+ // validate parameters
// TODO: build valdiation for dots (reflection used for Gson)
// this.validate(params);
- ClientInterface clientInterface = (ClientInterface) this.service.getClient().getHttpClient();
- Map result = clientInterface.requestJson(this.service, this.endpoint, params);
- return result;
+ ClientInterface clientInterface = (ClientInterface) this.service.getClient().getHttpClient();
+ Map result = clientInterface.requestJson(this.service, this.endpoint, params);
+ return result;
}
/**
@@ -56,7 +53,8 @@ public String request(String json) throws ApiException, IOException {
String responseBody = e.getResponseBody();
Gson gson = new Gson();
- ApiError apiError = gson.fromJson(responseBody, new TypeToken() {}.getType());
+ ApiError apiError = gson.fromJson(responseBody, new TypeToken() {
+ }.getType());
ApiException apiException = new ApiException(e.getMessage(), e.getCode());
apiException.setError(apiError);
@@ -66,21 +64,20 @@ public String request(String json) throws ApiException, IOException {
}
// Validate needs to be done by gson the json to an object. Object only contains valdiate fields to validate and use the json to put to the server to adyen
- protected void validate(Map params) throws Exception
- {
+ protected void validate(Map params) throws Exception {
List missingFields = new ArrayList();
List missingValues = new ArrayList();
- if(!this.requiredFields.isEmpty()) {
- for(String requiredField : this.requiredFields) {
+ if (!this.requiredFields.isEmpty()) {
+ for (String requiredField : this.requiredFields) {
// if validation is two levels validate if parent and child is in the request
- if(requiredField.contains(".")) {
+ if (requiredField.contains(".")) {
List items = Arrays.asList(requiredField.split("\\."));
String parent = items.get(0);
String child = items.get(1);
- if(!params.containsKey(parent)) {
+ if (!params.containsKey(parent)) {
missingFields.add(requiredField);
continue;
}
@@ -88,25 +85,25 @@ protected void validate(Map params) throws Exception
// cast to hashmap
HashMap result = (HashMap) params.get(parent);
- if(!result.containsKey(child)) {
+ if (!result.containsKey(child)) {
missingFields.add(requiredField);
continue;
}
// check if param has value toString() could lead to exception if there is no value set
try {
- if(result.get(child).toString().isEmpty()) {
+ if (result.get(child).toString().isEmpty()) {
missingValues.add(requiredField);
}
- } catch(Exception e) {
+ } catch (Exception e) {
missingValues.add(requiredField);
}
} else {
- if(!params.containsKey(requiredField)) {
+ if (!params.containsKey(requiredField)) {
missingFields.add(requiredField);
} else {
// check if field has value
- if(params.get(requiredField).toString().isEmpty()) {
+ if (params.get(requiredField).toString().isEmpty()) {
missingValues.add(requiredField);
}
}
@@ -114,12 +111,12 @@ protected void validate(Map params) throws Exception
}
}
- if(!missingFields.isEmpty()) {
+ if (!missingFields.isEmpty()) {
String msg = "Missing the following fields: " + Util.implode(",", missingFields);
throw new Exception(msg);
}
- if(!missingValues.isEmpty()) {
+ if (!missingValues.isEmpty()) {
String msg = "Missing the following values: " + Util.implode(",", missingValues);
throw new Exception(msg);
}
diff --git a/src/main/java/com/adyen/service/resource/recurring/ListRecurringDetails.java b/src/main/java/com/adyen/service/resource/recurring/ListRecurringDetails.java
new file mode 100644
index 000000000..602e1d66f
--- /dev/null
+++ b/src/main/java/com/adyen/service/resource/recurring/ListRecurringDetails.java
@@ -0,0 +1,18 @@
+package com.adyen.service.resource.recurring;
+
+import com.adyen.Service;
+import com.adyen.service.Resource;
+
+import java.util.Arrays;
+
+public class ListRecurringDetails extends Resource {
+ public ListRecurringDetails(Service service) {
+ super(service,
+ service.getClient().getConfig().getEndpoint() + "/pal/servlet/Recurring/" + service.getClient().getApiVersion() + "/listRecurringDetails",
+ Arrays.asList(
+ "merchantAccount",
+ "recurring.contract",
+ "shopperReference"
+ ));
+ }
+}
diff --git a/src/test/java/com/adyen/BaseTest.java b/src/test/java/com/adyen/BaseTest.java
index 50eb61a69..8a3a90982 100644
--- a/src/test/java/com/adyen/BaseTest.java
+++ b/src/test/java/com/adyen/BaseTest.java
@@ -13,6 +13,7 @@
import java.text.SimpleDateFormat;
import java.util.*;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.*;
public class BaseTest {
@@ -247,7 +248,7 @@ protected Client createMockClientForErrors(int status, String fileName) {
request(any(String.class), any(String.class), any(Config.class))).
thenThrow(httpClientException);
} catch (IOException | HTTPClientException e) {
- e.printStackTrace();
+ fail("Unexpected exception: " + e.getMessage());
}
Client client = new Client();
client.setHttpClient(httpURLConnectionClient);
diff --git a/src/test/java/com/adyen/RecurringTest.java b/src/test/java/com/adyen/RecurringTest.java
new file mode 100644
index 000000000..185fb104d
--- /dev/null
+++ b/src/test/java/com/adyen/RecurringTest.java
@@ -0,0 +1,37 @@
+package com.adyen;
+
+import com.adyen.model.recurring.RecurringDetail;
+import com.adyen.model.recurring.RecurringDetailsRequest;
+import com.adyen.model.recurring.RecurringDetailsResult;
+import com.adyen.service.Recurring;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class RecurringTest extends BaseTest {
+ private RecurringDetailsRequest createRecurringDetailsRequest() {
+ RecurringDetailsRequest request = new RecurringDetailsRequest()
+ .shopperReference("test-123")
+ .merchantAccount("MerchantAccount")
+ .selectOneClickContract();
+
+ return request;
+ }
+
+ @Test
+ public void testListRecurringDetails() throws Exception {
+ Client client = createMockClientFromFile("mocks/recurring/listRecurringDetails-success.json");
+ Recurring recurring = new Recurring(client);
+
+ RecurringDetailsRequest request = createRecurringDetailsRequest();
+
+ RecurringDetailsResult result = recurring.listRecurringDetails(request);
+ assertEquals(1, result.getDetails().size());
+ assertEquals(1, result.getRecurringDetails().size());
+
+ RecurringDetail recurringDetail = result.getRecurringDetails().get(0);
+ assertEquals("recurringReference", recurringDetail.getRecurringDetailReference());
+ assertEquals("cardAlias", recurringDetail.getAlias());
+ assertEquals("1111", recurringDetail.getCard().getNumber());
+ }
+}
diff --git a/src/test/java/com/adyen/service/ResourceTest.java b/src/test/java/com/adyen/service/ResourceTest.java
new file mode 100644
index 000000000..b108ea5f2
--- /dev/null
+++ b/src/test/java/com/adyen/service/ResourceTest.java
@@ -0,0 +1,81 @@
+package com.adyen.service;
+
+import com.adyen.BaseTest;
+import com.adyen.Client;
+import com.adyen.Service;
+import com.adyen.httpclient.ClientInterface;
+import com.adyen.httpclient.HTTPClientException;
+import com.adyen.service.exception.ApiException;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ResourceTest extends BaseTest {
+ @Mock
+ Service serviceMock;
+
+ @Mock
+ Client clientMock;
+
+ @Mock
+ ClientInterface clientInterfaceMock;
+
+ @Before
+ public void setUp() {
+ when(clientMock.getHttpClient()).thenReturn(clientInterfaceMock);
+ when(clientMock.getConfig()).thenReturn(null);
+ when(serviceMock.getClient()).thenReturn(clientMock);
+ }
+
+ @Test
+ public void testRequest() throws Exception {
+ when(clientInterfaceMock.request("", "request", null)).thenReturn("response");
+
+ Resource resource = new Resource(serviceMock, "", null);
+ String response = resource.request("request");
+
+ assertEquals("response", response);
+ }
+
+ @Test
+ public void testRequestExceptionEmpty() throws IOException, HTTPClientException {
+ try {
+ when(clientInterfaceMock.request("", "request", null))
+ .thenThrow(new HTTPClientException("message", 403, new HashMap>(), null));
+
+ Resource resource = new Resource(serviceMock, "", null);
+ String response = resource.request("request");
+
+ assertTrue("Expected exception", false);
+ } catch (ApiException e) {
+ assertEquals(403, e.getStatusCode());
+ assertNull(e.getError());
+ }
+ }
+
+ @Test
+ public void testRequestException() throws IOException, HTTPClientException {
+ Client client = createMockClientForErrors(403, "mocks/authorise-error-010.json");
+
+ when(serviceMock.getClient()).thenReturn(client);
+ try {
+ Resource resource = new Resource(serviceMock, "", null);
+ String response = resource.request("request");
+
+ assertTrue("Expected exception", false);
+ } catch (ApiException e) {
+ assertEquals(403, e.getStatusCode());
+ assertEquals("010", e.getError().getErrorCode());
+ }
+ }
+}
diff --git a/src/test/resources/mocks/recurring/listRecurringDetails-success.json b/src/test/resources/mocks/recurring/listRecurringDetails-success.json
new file mode 100644
index 000000000..ef12a54ba
--- /dev/null
+++ b/src/test/resources/mocks/recurring/listRecurringDetails-success.json
@@ -0,0 +1,32 @@
+{
+ "creationDate": "2017-03-01T11:53:11+01:00",
+ "details": [
+ {
+ "RecurringDetail": {
+ "acquirer": "TestPmmAcquirer",
+ "acquirerAccount": "TestPmmAcquirerAccount",
+ "additionalData": {
+ "cardBin": "411111"
+ },
+ "alias": "cardAlias",
+ "aliasType": "Default",
+ "card": {
+ "expiryMonth": "8",
+ "expiryYear": "2018",
+ "holderName": "Holder",
+ "number": "1111"
+ },
+ "contractTypes": [
+ "ONECLICK"
+ ],
+ "creationDate": "2017-03-07T09:43:33+01:00",
+ "firstPspReference": "8524888762135795",
+ "paymentMethodVariant": "visa",
+ "recurringDetailReference": "recurringReference",
+ "variant": "visa"
+ }
+ }
+ ],
+ "shopperReference": "test-123",
+ "invalidOneclickContracts": "false"
+}
\ No newline at end of file