Skip to content

Commit a57c928

Browse files
authored
Release 1.2.2.0 (#90)
2 parents 8f60135 + efa8035 commit a57c928

26 files changed

+749
-762
lines changed

.github/workflows/maven.yml

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v3
14+
- name: Install Chrome driver # for integration tests with Selenium
15+
uses: nanasess/setup-chromedriver@v1
1416
- name: Set up JDK 11
1517
uses: actions/setup-java@v3
1618
with:

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres
77
to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
88

9+
## [1.2.2.0][1.2.2.0]
10+
11+
This release adds Klarna payment type to Java SDK.
12+
13+
### Added
14+
15+
* Added payment type `Klarna`.
16+
* Added `language` field to `Customer` resource.
17+
* Added `termsAndConditionsUrl` and `privacyPolicyUrl` fields to `AdditionalTransactionData` resource
18+
19+
### Fixed
20+
21+
* Fixed typo `ShippingAddress.Type:DIFFERENT_ADDRESSES` -> `ShippingAddress.Type:DIFFERENT_ADDRESS`. This typo caused errors on authorize/charge in some payment cases
22+
* Fixed (de-)serialization of `AbstractTransaction` cause infinite Webhook calls.
23+
924
## [1.2.1.0][1.2.1.0]
1025

1126
This release brings Unzer Paylater Invoice payment type support to Java SDK.
@@ -234,6 +249,8 @@ This release brings Unzer Paylater Invoice payment type support to Java SDK.
234249
* Remove deprecated classes
235250
* RestCommunication
236251

252+
[1.2.2.0]: http://github.com/unzerdev/java-sdk/compare/1.2.1.0..1.2.2.0
253+
237254
[1.2.1.0]: http://github.com/unzerdev/java-sdk/compare/1.2.0.0..1.2.1.0
238255

239256
[1.2.0.0]: http://github.com/unzerdev/java-sdk/compare/1.1.2.7..1.2.0.0

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Java 1.8 or later.
1414
<dependency>
1515
<groupId>com.unzer.payment</groupId>
1616
<artifactId>java-sdk</artifactId>
17-
<version>1.2.1.0</version>
17+
<version>1.2.2.0</version>
1818
</dependency>
1919
```
2020

pom.xml

+7-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.unzer.payment</groupId>
88
<artifactId>java-sdk</artifactId>
9-
<version>1.2.1.0</version>
9+
<version>1.2.2.0</version>
1010
<name>Unzer Java SDK</name>
1111
<description>Unzer Java SDK</description>
1212
<url>https://docs.unzer.com/</url>
@@ -135,8 +135,8 @@
135135
<artifactId>maven-compiler-plugin</artifactId>
136136
<version>3.10.1</version>
137137
<configuration>
138-
<source>1.8</source>
139-
<target>1.8</target>
138+
<source>8</source>
139+
<target>8</target>
140140
</configuration>
141141
</plugin>
142142
<plugin>
@@ -319,7 +319,7 @@
319319
<dependency>
320320
<groupId>org.jsoup</groupId>
321321
<artifactId>jsoup</artifactId>
322-
<version>1.14.2</version>
322+
<version>1.15.3</version>
323323
<scope>test</scope>
324324
</dependency>
325325

@@ -330,7 +330,6 @@
330330
<scope>test</scope>
331331
</dependency>
332332

333-
<!-- UI Test dependencies Selenium -->
334333
<dependency>
335334
<groupId>org.seleniumhq.selenium</groupId>
336335
<artifactId>selenium-java</artifactId>
@@ -339,16 +338,9 @@
339338
</dependency>
340339

341340
<dependency>
342-
<groupId>org.seleniumhq.selenium</groupId>
343-
<artifactId>selenium-server</artifactId>
344-
<version>3.141.59</version>
345-
<scope>test</scope>
346-
</dependency>
347-
348-
<dependency>
349-
<groupId>org.seleniumhq.selenium</groupId>
350-
<artifactId>htmlunit-driver</artifactId>
351-
<version>2.39.0</version>
341+
<groupId>io.github.bonigarcia</groupId>
342+
<artifactId>webdrivermanager</artifactId>
343+
<version>3.8.1</version>
352344
<scope>test</scope>
353345
</dependency>
354346
</dependencies>

selenium/chrome/chromedriver

-14.1 MB
Binary file not shown.

selenium/chrome/chromedriver.exe

-8.19 MB
Binary file not shown.

selenium/geckodriver/geckodriver

-5.81 MB
Binary file not shown.

selenium/geckodriver/geckodriver.exe

-10.3 MB
Binary file not shown.

src/main/java/com/unzer/payment/AbstractTransaction.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.Date;
2626

2727
public abstract class AbstractTransaction<T extends AbstractPayment> implements PaymentType {
28-
2928
private String id;
3029
private BigDecimal amount;
3130
private Currency currency;
@@ -48,9 +47,9 @@ public abstract class AbstractTransaction<T extends AbstractPayment> implements
4847
private String type;
4948
private AdditionalTransactionData additionalTransactionData;
5049
@JsonFieldIgnore
51-
private T payment;
50+
private transient T payment;
5251
@JsonFieldIgnore
53-
private Unzer unzer;
52+
private transient Unzer unzer;
5453
@JsonFieldIgnore
5554
private URL resourceUrl;
5655

src/main/java/com/unzer/payment/Customer.java

+26-6
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
import com.unzer.payment.paymenttypes.PaymentType;
2121

2222
import java.util.Date;
23+
import java.util.Locale;
2324

2425
/**
2526
* Business object for Customer together with billingAddress.
26-
*
27+
* <p>
2728
* firstname and lastname are mandatory to create a new Customer.
2829
*
2930
* @author Unzer E-Com GmbH
@@ -41,6 +42,15 @@ public class Customer implements PaymentType {
4142
private Address billingAddress;
4243
private ShippingAddress shippingAddress;
4344
private String company;
45+
46+
/**
47+
* Customer language.
48+
* <p>
49+
* Mandatory depending on payment type
50+
* Format: ISO 639 alpha-2 code
51+
*/
52+
private Locale language;
53+
4454
private CustomerCompanyData companyData;
4555

4656
public Customer(String firstname, String lastname) {
@@ -150,14 +160,14 @@ public ShippingAddress getShippingAddress() {
150160
}
151161

152162
public Customer setShippingAddress(ShippingAddress shippingAddress) {
153-
this.shippingAddress = shippingAddress;
154-
return this;
155-
}
163+
this.shippingAddress = shippingAddress;
164+
return this;
165+
}
156166

157167
/**
158168
* @deprecated use {@link #setShippingAddress(ShippingAddress)} instead
159169
*/
160-
@Deprecated
170+
@Deprecated
161171
public Customer setShippingAddress(Address shippingAddress) {
162172
this.shippingAddress = ShippingAddress.of(shippingAddress, null);
163173
return this;
@@ -175,8 +185,9 @@ public String getCompany() {
175185
return company;
176186
}
177187

178-
public void setCompany(String company) {
188+
public Customer setCompany(String company) {
179189
this.company = company;
190+
return this;
180191
}
181192

182193
@Override
@@ -188,6 +199,15 @@ public void setId(String id) {
188199
this.id = id;
189200
}
190201

202+
public Locale getLanguage() {
203+
return language;
204+
}
205+
206+
public Customer setLanguage(Locale language) {
207+
this.language = language;
208+
return this;
209+
}
210+
191211
public enum Salutation {
192212
@SerializedName("mr")
193213
MR,

src/main/java/com/unzer/payment/ShippingAddress.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public static ShippingAddress of(Address address, Type shippingType) {
4949
public enum Type {
5050
@SerializedName("equals-billing")
5151
EQUALS_BILLING,
52-
@SerializedName("different-addresses")
53-
DIFFERENT_ADDRESSES,
52+
@SerializedName("different-address")
53+
DIFFERENT_ADDRESS,
5454
@SerializedName("branch-pickup")
5555
BRANCH_PICKUP,
5656
@SerializedName("post-office-pickup")

src/main/java/com/unzer/payment/communication/json/JsonCustomer.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class JsonCustomer extends JsonIdObject implements JsonObject {
3737
private String mobile;
3838
private Address billingAddress;
3939
private ShippingAddress shippingAddress;
40-
40+
private String language;
4141
private JSonCompanyInfo companyInfo;
4242

4343
public String getFirstname() {
@@ -136,4 +136,11 @@ public void setCompany(String company) {
136136
this.company = company;
137137
}
138138

139+
public String getLanguage() {
140+
return language;
141+
}
142+
143+
public void setLanguage(String language) {
144+
this.language = language;
145+
}
139146
}

src/main/java/com/unzer/payment/communication/mapper/JsonToBusinessClassMapper.java

+12
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import com.unzer.payment.marketplace.MarketplaceCancel;
2121
import com.unzer.payment.paymenttypes.PaymentType;
2222

23+
import java.util.Locale;
24+
2325
public class JsonToBusinessClassMapper {
2426

2527
public JsonObject map(AbstractTransaction<? extends AbstractPayment> abstractInitPayment) {
@@ -321,6 +323,11 @@ public JsonCustomer map(Customer customer) {
321323
json.setFirstname(customer.getFirstname());
322324
json.setLastname(customer.getLastname());
323325
json.setCompany(customer.getCompany());
326+
327+
if (customer.getLanguage() != null) {
328+
json.setLanguage(customer.getLanguage().getLanguage());
329+
}
330+
324331
json.setCustomerId(customer.getCustomerId());
325332
json.setEmail(customer.getEmail());
326333
json.setMobile(customer.getMobile());
@@ -340,6 +347,11 @@ public Customer mapToBusinessObject(Customer customer, JsonCustomer json) {
340347
customer.setLastname(json.getLastname());
341348
customer.setCompany(json.getCompany());
342349
customer.setCustomerId(json.getCustomerId());
350+
351+
if(json.getLanguage() != null && !json.getLanguage().isEmpty()) {
352+
customer.setLanguage(new Locale(json.getLanguage()));
353+
}
354+
343355
customer.setEmail(json.getEmail());
344356
customer.setMobile(json.getMobile());
345357
customer.setPhone(json.getPhone());

src/main/java/com/unzer/payment/models/AdditionalTransactionData.java

+40
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ public class AdditionalTransactionData {
2525
private ShippingTransactionData shipping;
2626
private RiskData riskData;
2727

28+
/**
29+
* URL to the merchant's Terms and Conditions Page
30+
*/
31+
private String termsAndConditionUrl;
32+
33+
/**
34+
* URL to the merchant's Privacy Policy Page
35+
*/
36+
private String privacyPolicyUrl;
37+
2838
public CardTransactionData getCard() {
2939
return card;
3040
}
@@ -51,4 +61,34 @@ public AdditionalTransactionData setRiskData(RiskData riskData) {
5161
this.riskData = riskData;
5262
return this;
5363
}
64+
65+
/**
66+
* URL to the merchant's Terms and Conditions Page
67+
*/
68+
public String getTermsAndConditionsUrl() {
69+
return termsAndConditionUrl;
70+
}
71+
72+
/**
73+
* URL to the merchant's Terms and Conditions Page
74+
*/
75+
public AdditionalTransactionData setTermsAndConditionsUrl(String termsAndConditionsUrl) {
76+
this.termsAndConditionUrl = termsAndConditionsUrl;
77+
return this;
78+
}
79+
80+
/**
81+
* URL to the merchant's Privacy Policy Page
82+
*/
83+
public String getPrivacyPolicyUrl() {
84+
return privacyPolicyUrl;
85+
}
86+
87+
/**
88+
* URL to the merchant's Privacy Policy Page
89+
*/
90+
public AdditionalTransactionData setPrivacyPolicyUrl(String privacyPolicyUrl) {
91+
this.privacyPolicyUrl = privacyPolicyUrl;
92+
return this;
93+
}
5494
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2020-today Unzer E-Com GmbH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.unzer.payment.paymenttypes;
17+
18+
import com.unzer.payment.GeoLocation;
19+
import com.unzer.payment.communication.json.JsonIdObject;
20+
import com.unzer.payment.communication.json.JsonObject;
21+
22+
public class Klarna extends AbstractPaymentType {
23+
@Override
24+
public String getTypeUrl() {
25+
return "types/klarna";
26+
}
27+
28+
@Override
29+
public PaymentType map(PaymentType paymentType, JsonObject jsonObject) {
30+
((Klarna) paymentType).setId(jsonObject.getId());
31+
((Klarna) paymentType).setRecurring(((JsonIdObject) jsonObject).getRecurring());
32+
GeoLocation tempGeoLocation = new GeoLocation(((JsonIdObject) jsonObject).getGeoLocation().getClientIp(), ((JsonIdObject) jsonObject).getGeoLocation().getCountryIsoA2());
33+
((Klarna) paymentType).setGeoLocation(tempGeoLocation);
34+
35+
return paymentType;
36+
}
37+
}

src/main/java/com/unzer/payment/paymenttypes/PaymentTypeEnum.java

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public enum PaymentTypeEnum {
4444
PF_CARD("pfc"),
4545
PF_EFINANCE("pfe"),
4646
UNZER_PAYLATER_INVOICE("piv"),
47+
KLARNA("kla"),
4748
UNKNOWN("unknown");
4849

4950
private String shortName;

src/main/java/com/unzer/payment/service/PaymentService.java

+3
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ private JsonIdObject getJsonObjectFromTypeId(String typeId) {
565565
case PF_CARD:
566566
case PF_EFINANCE:
567567
case UNZER_PAYLATER_INVOICE:
568+
case KLARNA:
568569
return new JsonIdObject();
569570
case PAYPAL:
570571
return new JsonPaypal();
@@ -644,6 +645,8 @@ private AbstractPaymentType getPaymentTypeFromTypeId(String typeId) {
644645
return new PostFinanceEFinance();
645646
case UNZER_PAYLATER_INVOICE:
646647
return new PaylaterInvoice();
648+
case KLARNA:
649+
return new Klarna();
647650
default:
648651
throw new PaymentException("Type '" + typeId + "' is currently not supported by the SDK");
649652
}

0 commit comments

Comments
 (0)