Skip to content

Commit 95b02e9

Browse files
committed
Release 2.1.0
1 parent 9a666fa commit 95b02e9

File tree

275 files changed

+25745
-31382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+25745
-31382
lines changed

README.md

Lines changed: 77 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Add this dependency to your project's POM:
2323
<dependency>
2424
<groupId>com.postfinancecheckout</groupId>
2525
<artifactId>postfinancecheckout-java-sdk</artifactId>
26-
<version>2.0.11</version>
26+
<version>2.1.0</version>
2727
<scope>compile</scope>
2828
</dependency>
2929
```
@@ -33,7 +33,7 @@ Add this dependency to your project's POM:
3333
Add this dependency to your project's build file:
3434

3535
```groovy
36-
compile "com.postfinancecheckout:postfinancecheckout-java-sdk:2.0.11"
36+
compile "com.postfinancecheckout:postfinancecheckout-java-sdk:2.1.0"
3737
```
3838

3939
### Others
@@ -46,7 +46,7 @@ mvn clean package
4646

4747
Then manually install the following JARs:
4848

49-
* `target/postfinancecheckout-java-sdk-2.0.11.jar`
49+
* `target/postfinancecheckout-java-sdk-2.1.0.jar`
5050
* `target/lib/*.jar`
5151

5252
## Usage
@@ -81,132 +81,104 @@ public class Example {
8181
To get started with sending transactions, please review the example below:
8282

8383
```java
84-
package com.postfinancecheckout.sdk.example;
84+
package com.postfinancecheckout.sdk.test;
8585

8686
import com.postfinancecheckout.sdk.ApiClient;
87-
import com.postfinancecheckout.sdk.ApiException;
88-
import com.postfinancecheckout.sdk.ApiResponse;
89-
import com.postfinancecheckout.sdk.service.TransactionPaymentPageService;
90-
import com.postfinancecheckout.sdk.service.TransactionService;
9187
import com.postfinancecheckout.sdk.model.*;
88+
import com.postfinancecheckout.sdk.service.*;
89+
9290
import org.junit.Assert;
9391
import org.junit.Before;
9492
import org.junit.Test;
9593

9694
import java.math.BigDecimal;
97-
import java.time.LocalDate;
98-
import java.util.Arrays;
99-
import java.util.UUID;
10095

96+
/**
97+
* API tests for TransactionPaymentPageService
98+
*/
10199
public class TransactionPaymentPageServiceTest {
102-
private TransactionService transactionService;
103-
private TransactionCreate transactionCreate;
104-
private Long spaceId;
105-
private Long applicationUserId;
106-
private String authenticationKey;
100+
101+
// Credentials
102+
private Long spaceId = (long) 405;
103+
private Long applicationUserId = (long) 512;
104+
private String authenticationKey = "FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=";
105+
106+
// Services
107107
private ApiClient apiClient;
108-
private ApiResponse<Transaction> transaction;
108+
private TransactionPaymentPageService transactionPaymentPageService;
109+
private TransactionService transactionService;
110+
111+
// Models
112+
private TransactionCreate transactionPayload;
109113

110114
@Before
111115
public void setup() {
112-
this.applicationUserId = (long) 512;
113-
this.spaceId = (long) 405;
114-
this.authenticationKey = "FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=";
115-
this.apiClient = new ApiClient(applicationUserId, authenticationKey);
116-
this.transactionService = new TransactionService(this.apiClient);
117-
this.createTransaction();
116+
if (this.apiClient == null) {
117+
this.apiClient = new ApiClient(applicationUserId, authenticationKey);
118+
}
119+
if (this.transactionPaymentPageService == null) {
120+
this.transactionPaymentPageService = new TransactionPaymentPageService(this.apiClient);
121+
}
122+
if (this.transactionService == null) {
123+
this.transactionService = new TransactionService(this.apiClient);
124+
}
118125
}
119126

120-
private void createTransaction() {
121-
122-
AddressCreate billingAddress = new AddressCreate()
123-
.salutation("Ms")
124-
.givenName("Good")
125-
.familyName("Customer")
126-
.gender(Gender.FEMALE)
127-
.country("CH")
128-
.city("Winterthur")
129-
.postcode("8400")
130-
.dateOfBirth(LocalDate.of(1991, 1, 11))
131-
.organizationName("Test GmbH")
132-
.mobilePhoneNumber("+41791234567")
133-
.emailAddress("[email protected]");
134-
135-
AddressCreate shippingAddress = new AddressCreate()
136-
.salutation("Ms")
137-
.givenName("Good")
138-
.familyName("Customer")
139-
.gender(Gender.FEMALE)
140-
.country("CH")
141-
.city("Winterthur")
142-
.postcode("8400")
143-
.dateOfBirth(LocalDate.of(1991, 1, 11))
144-
.organizationName("Test GmbH")
145-
.mobilePhoneNumber("+41791234567")
146-
.emailAddress("[email protected]");
147-
148-
LineItemCreate lineItem1 = new LineItemCreate()
149-
.sku("item-1")
150-
.name("Item 1")
151-
.uniqueId("unique-id-item-1")
152-
.type(LineItemType.PRODUCT)
153-
.quantity(BigDecimal.ONE)
154-
.shippingRequired(true)
155-
.amountIncludingTax(new BigDecimal("67.47"))
156-
.addTaxesItem(
157-
new TaxCreate().title("VAT").rate(new BigDecimal(8))
158-
);
159-
160-
LineItemCreate lineItem2 = new LineItemCreate()
161-
.sku("test-shipping")
162-
.name("Shipping")
163-
.uniqueId("unique-id-test-shipping")
164-
.type(LineItemType.SHIPPING)
165-
.quantity(BigDecimal.ONE)
166-
.amountIncludingTax(new BigDecimal("3.12"))
167-
.addTaxesItem(
168-
new TaxCreate().title("VAT").rate(new BigDecimal(8))
169-
);
170-
171-
this.transactionCreate = new TransactionCreate();
172-
this.transactionCreate.customerEmailAddress("[email protected]");
173-
this.transactionCreate.customerId("cutomer-x");
174-
this.transactionCreate.merchantReference(UUID.randomUUID().toString());
175-
this.transactionCreate.invoiceMerchantReference("order-1");
176-
this.transactionCreate.successUrl("http://localhost/success?orderId=1");
177-
this.transactionCreate.failedUrl("http://localhost/failed?orderId=1");
178-
this.transactionCreate.shippingMethod("Test Shipping");
179-
this.transactionCreate.chargeRetryEnabled(false);
180-
this.transactionCreate.allowedPaymentMethodConfigurations(Arrays.asList(8656l));
181-
this.transactionCreate.language("en-US");
182-
this.transactionCreate.currency("CHF");
183-
this.transactionCreate.billingAddress(billingAddress);
184-
this.transactionCreate.shippingAddress(shippingAddress);
185-
this.transactionCreate.addLineItemsItem(lineItem1);
186-
this.transactionCreate.addLineItemsItem(lineItem2);
187-
try {
188-
this.transaction = this.transactionService.createWithHttpInfo(
189-
this.spaceId,
190-
this.transactionCreate
191-
);
192-
} catch (ApiException e) {
193-
Assert.fail("Failed to create transaction. Reason: " + e.getMessage() + " Details: " + e.getResponseBody());
127+
/**
128+
* Get transaction payload
129+
*
130+
* @return TransactionCreate
131+
*/
132+
private TransactionCreate getTransactionPayload() {
133+
if (this.transactionPayload == null) {
134+
// Line item
135+
LineItemCreate lineItem = new LineItemCreate();
136+
lineItem.name("Red T-Shirt")
137+
.uniqueId("5412")
138+
.type(LineItemType.PRODUCT)
139+
.quantity(BigDecimal.valueOf(1))
140+
.amountIncludingTax(BigDecimal.valueOf(29.95))
141+
.sku("red-t-shirt-123");
142+
143+
// Customer Billind Address
144+
AddressCreate billingAddress = new AddressCreate();
145+
billingAddress.city("Winterthur")
146+
.country("CH")
147+
.emailAddress("[email protected]")
148+
.familyName("Customer")
149+
.givenName("Good")
150+
.postcode("8400")
151+
.postalState("ZH")
152+
.organizationName("Test GmbH")
153+
.mobilePhoneNumber("+41791234567")
154+
.salutation("Ms");
155+
156+
this.transactionPayload = new TransactionCreate();
157+
this.transactionPayload.autoConfirmationEnabled(true).currency("CHF").language("en-US");
158+
this.transactionPayload.setBillingAddress(billingAddress);
159+
this.transactionPayload.setShippingAddress(billingAddress);
160+
this.transactionPayload.addLineItemsItem(lineItem);
194161
}
162+
return this.transactionPayload;
195163
}
196164

165+
/**
166+
* Build Payment Page URL
167+
*
168+
* This operation creates the URL to which the user should be redirected to when the payment page should be used.
169+
*
170+
*/
197171
@Test
198-
public void testPaymentPageUrl() {
199-
200-
TransactionPaymentPageService transactionPaymentPageService = new TransactionPaymentPageService(this.apiClient);
201-
String paymentPageUrl = null;
172+
public void paymentPageUrlTest() {
202173
try {
203-
paymentPageUrl = transactionPaymentPageService.paymentPageUrl(this.spaceId, this.transaction.getData().getId());
204-
} catch (ApiException e) {
174+
Transaction transaction = this.transactionService.create(this.spaceId, this.getTransactionPayload());
175+
String paymentPageUrl = this.transactionPaymentPageService.paymentPageUrl(spaceId, transaction.getId());
176+
Assert.assertTrue(paymentPageUrl.contains("https://"));
177+
} catch (Exception e) {
205178
e.printStackTrace();
206179
}
207-
System.out.println(paymentPageUrl);
208-
Assert.assertTrue(paymentPageUrl.contains("http"));
209180
}
181+
210182
}
211183

212184
```

build.gradle

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
apply plugin: 'java'
21
apply plugin: 'idea'
32
apply plugin: 'eclipse'
43

54
group = 'com.postfinancecheckout'
6-
version = '2.0.11'
5+
version = '2.1.0'
76

87
buildscript {
98
repositories {
109
jcenter()
1110
}
1211
dependencies {
13-
classpath 'com.android.tools.build:gradle:2.3.+'
14-
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
12+
classpath 'com.android.tools.build:gradle:1.5.+'
13+
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
1514
}
1615
}
1716

@@ -24,19 +23,19 @@ if(hasProperty('target') && target == 'android') {
2423

2524
apply plugin: 'com.android.library'
2625
apply plugin: 'com.github.dcendents.android-maven'
27-
26+
2827
android {
29-
compileSdkVersion 25
30-
buildToolsVersion '25.0.2'
28+
compileSdkVersion 23
29+
buildToolsVersion '23.0.2'
3130
defaultConfig {
3231
minSdkVersion 14
33-
targetSdkVersion 25
32+
targetSdkVersion 22
3433
}
3534
compileOptions {
3635
sourceCompatibility JavaVersion.VERSION_1_8
3736
targetCompatibility JavaVersion.VERSION_1_8
3837
}
39-
38+
4039
// Rename the aar correctly
4140
libraryVariants.all { variant ->
4241
variant.outputs.each { output ->
@@ -52,7 +51,7 @@ if(hasProperty('target') && target == 'android') {
5251
provided 'javax.annotation:jsr250-api:1.0'
5352
}
5453
}
55-
54+
5655
afterEvaluate {
5756
android.libraryVariants.all { variant ->
5857
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
@@ -64,12 +63,12 @@ if(hasProperty('target') && target == 'android') {
6463
artifacts.add('archives', task);
6564
}
6665
}
67-
66+
6867
task sourcesJar(type: Jar) {
6968
from android.sourceSets.main.java.srcDirs
7069
classifier = 'sources'
7170
}
72-
71+
7372
artifacts {
7473
archives sourcesJar
7574
}
@@ -87,19 +86,30 @@ if(hasProperty('target') && target == 'android') {
8786
pom.artifactId = 'postfinancecheckout-java-sdk'
8887
}
8988
}
90-
89+
9190
task execute(type:JavaExec) {
9291
main = System.getProperty('mainClass')
9392
classpath = sourceSets.main.runtimeClasspath
9493
}
9594
}
9695

96+
ext {
97+
swagger_annotations_version = "1.5.17"
98+
jackson_version = "2.10.1"
99+
google_api_client_version = "1.23.0"
100+
jersey_common_version = "2.29.1"
101+
jodatime_version = "2.9.9"
102+
junit_version = "4.12"
103+
}
104+
97105
dependencies {
98-
compile 'io.swagger:swagger-annotations:1.5.17'
99-
compile 'com.squareup.okhttp:okhttp:2.7.5'
100-
compile 'com.squareup.okhttp:logging-interceptor:2.7.5'
101-
compile 'com.google.code.gson:gson:2.8.1'
102-
compile 'io.gsonfire:gson-fire:1.8.0'
103-
compile 'junit:junit:4.12'
104-
testCompile 'junit:junit:4.12'
106+
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
107+
compile "com.google.api-client:google-api-client:${google_api_client_version}"
108+
compile "org.glassfish.jersey.core:jersey-common:${jersey_common_version}"
109+
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
110+
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
111+
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
112+
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
113+
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
114+
testCompile "junit:junit:$junit_version"
105115
}

build.sbt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ lazy val root = (project in file(".")).
22
settings(
33
organization := "com.postfinancecheckout",
44
name := "postfinancecheckout-java-sdk",
5-
version := "2.0.11",
5+
version := "2.1.0",
66
scalaVersion := "2.11.4",
77
scalacOptions ++= Seq("-feature"),
88
javacOptions in compile ++= Seq("-Xlint:deprecation"),
99
publishArtifact in (Compile, packageDoc) := false,
1010
resolvers += Resolver.mavenLocal,
1111
libraryDependencies ++= Seq(
1212
"io.swagger" % "swagger-annotations" % "1.5.17",
13-
"com.squareup.okhttp" % "okhttp" % "2.7.5",
14-
"com.squareup.okhttp" % "logging-interceptor" % "2.7.5",
15-
"com.google.code.gson" % "gson" % "2.8.1",
16-
"io.gsonfire" % "gson-fire" % "1.8.0" % "compile",
13+
"com.google.api-client" % "google-api-client" % "1.23.0",
14+
"org.glassfish.jersey.core" % "jersey-common" % "2.29.1",
15+
"com.fasterxml.jackson.core" % "jackson-core" % "2.10.1" % "compile",
16+
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.10.1" % "compile",
17+
"com.fasterxml.jackson.core" % "jackson-databind" % "2.10.1" % "compile",
18+
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.10.1" % "compile",
1719
"junit" % "junit" % "4.12" % "test",
1820
"com.novocode" % "junit-interface" % "0.10" % "test"
1921
)

0 commit comments

Comments
 (0)