Skip to content

Commit

Permalink
Merge pull request #182 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 2.0.2
  • Loading branch information
AlexandrosMor authored Apr 17, 2019
2 parents 8d1e776 + 81c3b93 commit db9e74a
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 106 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ The Library supports all APIs under the following services:
* Java 7 or higher

## Installation

You can use Maven or simply download the release.

### Maven

Add this dependency to your project's POM:
Expand All @@ -35,7 +35,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>com.adyen</groupId>
<artifactId>adyen-java-api-library</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
</dependency>
```

Expand All @@ -62,7 +62,7 @@ client.setHttpClient(httpURLConnectionClientWithProxy);
## Support

If you have any problems, questions or suggestions, create an issue here or send your inquiry to [email protected].

## Licence

MIT license. For more information, see the LICENSE file.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.adyen</groupId>
<artifactId>adyen-java-api-library</artifactId>
<packaging>jar</packaging>
<version>2.0.1</version>
<version>2.0.2</version>
<name>Adyen Java API Library</name>
<description>Adyen API Client Library for Java</description>
<url>https://github.com/adyen/adyen-java-api-library</url>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/adyen/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Client {
public static final String MARKETPAY_FUND_API_VERSION = "v3";
public static final String MARKETPAY_NOTIFICATION_API_VERSION = "v1";
public static final String LIB_NAME = "adyen-java-api-library";
public static final String LIB_VERSION = "2.0.1";
public static final String LIB_VERSION = "2.0.2";
public static final String CHECKOUT_ENDPOINT_TEST = "https://checkout-test.adyen.com/checkout";
public static final String CHECKOUT_ENDPOINT_LIVE_SUFFIX = "-checkout-live.adyenpayments.com/checkout";
public static final String CHECKOUT_API_VERSION = "v41";
Expand Down
9 changes: 1 addition & 8 deletions src/main/java/com/adyen/model/AbstractPaymentRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ public String toString() {
private ApplicationInfo applicationInfo;

public AbstractPaymentRequest() {
if (this.applicationInfo == null) {
applicationInfo = new ApplicationInfo();
}
applicationInfo = new ApplicationInfo();
}

/**
Expand Down Expand Up @@ -757,10 +755,6 @@ public ApplicationInfo getApplicationInfo() {
return applicationInfo;
}

public void setApplicationInfo(ApplicationInfo applicationInfo) {
this.applicationInfo = applicationInfo;
}

/**
* a map of key/value pairs of metadata sent by merchant
*
Expand Down Expand Up @@ -930,4 +924,3 @@ private String toIndentedString(Object o) {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,10 @@ public void setPaymentDetailsSource(CommonField paymentDetailsSource) {
this.paymentDetailsSource = paymentDetailsSource;
}


public CommonField getAdyenLibrary() {
return adyenLibrary;
}

public void setAdyenLibrary(CommonField adyenLibrary) {
this.adyenLibrary = adyenLibrary;
}

public CommonField getAdyenPaymentSource() {
return adyenPaymentSource;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,12 @@ private String toIndentedString(Object o) {
public enum ResultCodeEnum {

AUTHORISED("Authorised"),
PARTIALLYAUTHORISED("PartiallyAuthorised"),
REFUSED("Refused"),
ERROR("Error"),
CANCELLED("Cancelled"),
RECEIVED("Received"),
REDIRECTSHOPPER("RedirectShopper");
REDIRECTSHOPPER("RedirectShopper"),
PENDING("Pending");

private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@
*/
package com.adyen.model.modification;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import com.adyen.model.Split;
import com.adyen.model.additionalData.InvoiceLine;
import com.adyen.model.additionalData.SplitPayment;
import com.adyen.model.additionalData.SplitPaymentItem;
import com.adyen.model.applicationinfo.ApplicationInfo;
import com.google.gson.annotations.SerializedName;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
* Abstract class for modification requests
*/
Expand All @@ -56,6 +57,10 @@ public class AbstractModificationRequest<T extends AbstractModificationRequest<T
@SerializedName("splits")
private List<Split> splits = null;

public AbstractModificationRequest() {
applicationInfo = new ApplicationInfo();
}

public T reference(String reference) {
this.reference = reference;
return (T) this;
Expand Down Expand Up @@ -132,15 +137,6 @@ public ApplicationInfo getApplicationInfo() {
return applicationInfo;
}

public void setApplicationInfo(ApplicationInfo applicationInfo) {
this.applicationInfo = applicationInfo;
}

public T applicationInfo(ApplicationInfo applicationInfo) {
this.applicationInfo = applicationInfo;
return (T) this;
}

public Map<String, String> getAdditionalData() {
return additionalData;
}
Expand Down Expand Up @@ -268,7 +264,7 @@ public String toString() {
sb.append(" authorisationCode: ").append(toIndentedString(authorisationCode)).append("\n");
sb.append(" originalReference: ").append(toIndentedString(originalReference)).append("\n");
sb.append(" merchantAccount: ").append(toIndentedString(merchantAccount)).append("\n");
sb.append(" applicationInfo: ").append(toIndentedString(additionalData)).append("\n");
sb.append(" applicationInfo: ").append(toIndentedString(applicationInfo)).append("\n");
sb.append(" additionalData: ").append(toIndentedString(additionalData)).append("\n");

return sb.toString();
Expand All @@ -288,4 +284,3 @@ private String toIndentedString(Object o) {
}

}

26 changes: 15 additions & 11 deletions src/test/java/com/adyen/ApplicationInfoTest.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
package com.adyen;

import org.junit.Test;
import com.adyen.model.applicationinfo.ApplicationInfo;
import com.adyen.model.applicationinfo.CommonField;
import org.junit.Test;

import static com.adyen.Client.LIB_NAME;
import static com.adyen.Client.LIB_VERSION;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class ApplicationInfoTest {

@Test
public void TestApplicationInfoEquals() {
ApplicationInfo applicationInfo = new ApplicationInfo();
ApplicationInfo applicationInfo2 = new ApplicationInfo();

CommonField adyenLibrary = new CommonField();
adyenLibrary.setName(LIB_NAME);
adyenLibrary.setVersion(LIB_VERSION);
assertEquals(applicationInfo, applicationInfo2);
}

@Test
public void TestApplicationInfoPrefilledLibraryFields() {
ApplicationInfo applicationInfo = new ApplicationInfo();
applicationInfo.setAdyenLibrary(adyenLibrary);

ApplicationInfo applicationInfo2 = new ApplicationInfo();
applicationInfo2.setAdyenLibrary(adyenLibrary);

assertTrue(applicationInfo.equals(applicationInfo2));
assertNotNull(applicationInfo.getAdyenLibrary());
assertNotNull(applicationInfo.getAdyenLibrary().getName());
assertEquals(LIB_NAME, applicationInfo.getAdyenLibrary().getName());
assertNotNull(applicationInfo.getAdyenLibrary().getVersion());
assertEquals(LIB_VERSION, applicationInfo.getAdyenLibrary().getVersion());
}
}
108 changes: 68 additions & 40 deletions src/test/java/com/adyen/CheckoutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
*/
package com.adyen;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import org.junit.Test;
import com.adyen.model.Amount;
import com.adyen.model.checkout.DefaultPaymentMethodDetails;
import com.adyen.model.checkout.PaymentMethodDetails;
Expand All @@ -41,6 +34,17 @@
import com.adyen.model.checkout.PaymentsResponse;
import com.adyen.service.Checkout;
import com.google.gson.annotations.SerializedName;
import org.junit.Test;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

import static com.adyen.Client.LIB_NAME;
import static com.adyen.Client.LIB_VERSION;
import static com.adyen.enums.Environment.LIVE;
import static junit.framework.TestCase.assertNull;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -213,26 +217,31 @@ public void TestPaymentMethodsFailureMissingIdentifierOnLive() throws Exception
@Test
public void TestPaymentMethodDetails() {
PaymentsRequest paymentsRequest = createPaymentsCheckoutRequest();
paymentsRequest.setApplicationInfo(null);
String jsonRequest = PRETTY_PRINT_GSON.toJson(paymentsRequest);

assertEquals("{\n"
+ " \"amount\": {\n"
+ " \"value\": 1000,\n"
+ " \"currency\": \"USD\"\n"
+ " },\n"
+ " \"merchantAccount\": \"MagentoMerchantTest\",\n"
+ " \"paymentMethod\": {\n"
+ " \"type\": \"scheme\",\n"
+ " \"number\": \"4111111111111111\",\n"
+ " \"expiryMonth\": \"10\",\n"
+ " \"expiryYear\": \"2018\",\n"
+ " \"holderName\": \"John Smith\",\n"
+ " \"cvc\": \"737\"\n"
+ " },\n"
+ " \"reference\": \"Your order number\",\n"
+ " \"returnUrl\": \"https://your-company.com/...\"\n"
+ "}", jsonRequest);
+ " \"amount\": {\n"
+ " \"value\": 1000,\n"
+ " \"currency\": \"USD\"\n"
+ " },\n"
+ " \"merchantAccount\": \"MagentoMerchantTest\",\n"
+ " \"paymentMethod\": {\n"
+ " \"type\": \"scheme\",\n"
+ " \"number\": \"4111111111111111\",\n"
+ " \"expiryMonth\": \"10\",\n"
+ " \"expiryYear\": \"2018\",\n"
+ " \"holderName\": \"John Smith\",\n"
+ " \"cvc\": \"737\"\n"
+ " },\n"
+ " \"reference\": \"Your order number\",\n"
+ " \"returnUrl\": \"https://your-company.com/...\",\n"
+ " \"applicationInfo\": {\n"
+ " \"adyenLibrary\": {\n"
+ " \"name\": \"" + LIB_NAME + "\",\n"
+ " \"version\": \"" + LIB_VERSION + "\"\n"
+ " }\n"
+ " }\n"
+ "}", jsonRequest);

TestPaymentMethodDetails testPaymentMethodDetails = new TestPaymentMethodDetails();
testPaymentMethodDetails.setType("testType");
Expand All @@ -241,18 +250,24 @@ public void TestPaymentMethodDetails() {

jsonRequest = PRETTY_PRINT_GSON.toJson(paymentsRequest);
assertEquals("{\n"
+ " \"amount\": {\n"
+ " \"value\": 1000,\n"
+ " \"currency\": \"USD\"\n"
+ " },\n"
+ " \"merchantAccount\": \"MagentoMerchantTest\",\n"
+ " \"paymentMethod\": {\n"
+ " \"testKey\": \"testValue\",\n"
+ " \"type\": \"testType\"\n"
+ " },\n"
+ " \"reference\": \"Your order number\",\n"
+ " \"returnUrl\": \"https://your-company.com/...\"\n"
+ "}", jsonRequest);
+ " \"amount\": {\n"
+ " \"value\": 1000,\n"
+ " \"currency\": \"USD\"\n"
+ " },\n"
+ " \"merchantAccount\": \"MagentoMerchantTest\",\n"
+ " \"paymentMethod\": {\n"
+ " \"testKey\": \"testValue\",\n"
+ " \"type\": \"testType\"\n"
+ " },\n"
+ " \"reference\": \"Your order number\",\n"
+ " \"returnUrl\": \"https://your-company.com/...\",\n"
+ " \"applicationInfo\": {\n"
+ " \"adyenLibrary\": {\n"
+ " \"name\": \"" + LIB_NAME + "\",\n"
+ " \"version\": \"" + LIB_VERSION + "\"\n"
+ " }\n"
+ " }\n"
+ "}", jsonRequest);
}

/**
Expand All @@ -279,7 +294,6 @@ public void TestSepaPaymentMethodDetails() {
defaultPaymentMethodDetails.setSepaIbanNumber("DE87123456781234567890");

PaymentsRequest paymentsRequest = createPaymentsCheckoutRequest();
paymentsRequest.setApplicationInfo(null);
paymentsRequest.setPaymentMethod(defaultPaymentMethodDetails);

String jsonRequest = PRETTY_PRINT_GSON.toJson(paymentsRequest);
Expand All @@ -296,14 +310,19 @@ public void TestSepaPaymentMethodDetails() {
+ " \"sepa.ibanNumber\": \"DE87123456781234567890\"\n"
+ " },\n"
+ " \"reference\": \"Your order number\",\n"
+ " \"returnUrl\": \"https://your-company.com/...\"\n"
+ " \"returnUrl\": \"https://your-company.com/...\",\n"
+ " \"applicationInfo\": {\n"
+ " \"adyenLibrary\": {\n"
+ " \"name\": \"" + LIB_NAME + "\",\n"
+ " \"version\": \"" + LIB_VERSION + "\"\n"
+ " }\n"
+ " }\n"
+ "}",jsonRequest );
}

@Test
public void TestDateSerializers() throws ParseException {
PaymentsRequest paymentsRequest = new PaymentsRequest();
paymentsRequest.setApplicationInfo(null);

SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
fmt.setTimeZone(TimeZone.getTimeZone("GMT"));
Expand All @@ -312,7 +331,16 @@ public void TestDateSerializers() throws ParseException {
paymentsRequest.setDateOfBirth(d);
paymentsRequest.setDeliveryDate(d);
String jsonRequest = PRETTY_PRINT_GSON.toJson(paymentsRequest);
assertEquals("{\n" + " \"dateOfBirth\": \"2018-10-31\",\n" + " \"deliveryDate\": \"2018-10-31T00:00:00.000Z\"\n" + "}", jsonRequest);
assertEquals("{\n"
+ " \"dateOfBirth\": \"2018-10-31\",\n"
+ " \"deliveryDate\": \"2018-10-31T00:00:00.000Z\",\n"
+ " \"applicationInfo\": {\n"
+ " \"adyenLibrary\": {\n"
+ " \"name\": \"" + LIB_NAME + "\",\n"
+ " \"version\": \"" + LIB_VERSION + "\"\n"
+ " }\n"
+ " }\n"
+ "}",jsonRequest );
}

/**
Expand Down
Loading

0 comments on commit db9e74a

Please sign in to comment.