Skip to content

Commit 7a8dcdd

Browse files
committed
Release 4.0.10
1 parent 958596b commit 7a8dcdd

13 files changed

+1876
-93
lines changed

README.md

Lines changed: 67 additions & 89 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>ch.postfinance</groupId>
2525
<artifactId>postfinancecheckout-java-sdk</artifactId>
26-
<version>4.0.9</version>
26+
<version>4.0.10</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 "ch.postfinance:postfinancecheckout-java-sdk:4.0.9"
36+
compile "ch.postfinance:postfinancecheckout-java-sdk:4.0.10"
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-4.0.9.jar`
49+
* `target/postfinancecheckout-java-sdk-4.0.10.jar`
5050
* `target/lib/*.jar`
5151

5252
## Usage
@@ -65,15 +65,18 @@ public class Example {
6565

6666
public static void main(String[] args) {
6767

68-
// API Configuration.
69-
long spaceId = (Long) 405;
70-
long userId = (Long) 512;
68+
// Credentials
69+
Long userId = 512L;
7170
String secret = "FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=";
71+
72+
// API Client
7273
ApiClient apiClient = new ApiClient(userId, secret);
7374

74-
// Create API service instance.
75+
// Create an API service instance:
7576
TransactionService transactionService = apiClient.getTransactionService();
7677

78+
// ... use the transactionService to make API calls ...
79+
7780
}
7881
}
7982
```
@@ -83,93 +86,68 @@ To get started with sending transactions, please review the example below:
8386
```java
8487
package ch.postfinance.sdk.test;
8588

89+
import java.io.IOException;
90+
import java.math.BigDecimal;
91+
8692
import ch.postfinance.sdk.ApiClient;
8793
import ch.postfinance.sdk.model.*;
88-
import ch.postfinance.sdk.service.*;
89-
90-
import org.junit.Assert;
91-
import org.junit.Before;
92-
import org.junit.Test;
93-
94-
import java.math.BigDecimal;
9594

9695
/**
97-
* API tests for TransactionPaymentPageService
96+
*
9897
*/
99-
public class TransactionPaymentPageServiceTest {
100-
101-
// Credentials
102-
private Long spaceId = (long) 405;
103-
private Long applicationUserId = (long) 512;
104-
private String authenticationKey = "FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=";
105-
106-
// Services
107-
private ApiClient apiClient;
108-
109-
// Models
110-
private TransactionCreate transactionPayload;
111-
112-
@Before
113-
public void setup() {
114-
if (this.apiClient == null) {
115-
this.apiClient = new ApiClient(applicationUserId, authenticationKey);
116-
}
117-
}
118-
119-
/**
120-
* Get transaction payload
121-
*
122-
* @return TransactionCreate
123-
*/
124-
private TransactionCreate getTransactionPayload() {
125-
if (this.transactionPayload == null) {
126-
// Line item
127-
LineItemCreate lineItem = new LineItemCreate();
128-
lineItem.name("Red T-Shirt")
129-
.uniqueId("5412")
130-
.type(LineItemType.PRODUCT)
131-
.quantity(BigDecimal.valueOf(1))
132-
.amountIncludingTax(BigDecimal.valueOf(29.95))
133-
.sku("red-t-shirt-123");
134-
135-
// Customer Billind Address
136-
AddressCreate billingAddress = new AddressCreate();
137-
billingAddress.city("Winterthur")
138-
.country("CH")
139-
.emailAddress("test@example.com")
140-
.familyName("Customer")
141-
.givenName("Good")
142-
.postcode("8400")
143-
.postalState("ZH")
144-
.organizationName("Test GmbH")
145-
.mobilePhoneNumber("+41791234567")
146-
.salutation("Ms");
147-
148-
this.transactionPayload = new TransactionCreate();
149-
this.transactionPayload.autoConfirmationEnabled(true).currency("CHF").language("en-US");
150-
this.transactionPayload.setBillingAddress(billingAddress);
151-
this.transactionPayload.setShippingAddress(billingAddress);
152-
this.transactionPayload.addLineItemsItem(lineItem);
153-
}
154-
return this.transactionPayload;
155-
}
156-
157-
/**
158-
* Build Payment Page URL
159-
*
160-
* This operation creates the URL to which the user should be redirected to when the payment page should be used.
161-
*
162-
*/
163-
@Test
164-
public void paymentPageUrlTest() {
165-
try {
166-
Transaction transaction = this.apiClient.getTransactionService().create(this.spaceId, this.getTransactionPayload());
167-
String paymentPageUrl = this.apiClient.getTransactionPaymentPageService.paymentPageUrl(spaceId, transaction.getId());
168-
Assert.assertTrue(paymentPageUrl.contains("https://"));
169-
} catch (Exception e) {
170-
e.printStackTrace();
171-
}
172-
}
98+
public class TransactionPaymentPageExample {
99+
100+
public static void main(String[] args) throws IOException {
101+
102+
// Credentials
103+
Long spaceId = 405L;
104+
Long applicationUserId = 512L;
105+
String authenticationKey = "FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=";
106+
107+
// API Client
108+
ApiClient apiClient = new ApiClient(applicationUserId, authenticationKey);
109+
110+
// Line item
111+
LineItemCreate lineItem = new LineItemCreate();
112+
lineItem.name("Red T-Shirt")
113+
.uniqueId("5412")
114+
.type(LineItemType.PRODUCT)
115+
.quantity(BigDecimal.valueOf(1))
116+
.amountIncludingTax(BigDecimal.valueOf(29.95))
117+
.sku("red-t-shirt-123");
118+
119+
// Customer Billing Address
120+
AddressCreate billingAddress = new AddressCreate();
121+
billingAddress.city("Winterthur")
122+
.country("CH")
123+
.emailAddress("test@example.com")
124+
.familyName("Customer")
125+
.givenName("Good")
126+
.postcode("8400")
127+
.postalState("ZH")
128+
.organizationName("Test GmbH")
129+
.mobilePhoneNumber("+41791234567")
130+
.salutation("Ms");
131+
132+
// Transaction Create Request
133+
TransactionCreate request = new TransactionCreate();
134+
request.autoConfirmationEnabled(true).currency("CHF").language("en-US");
135+
request.setBillingAddress(billingAddress);
136+
request.setShippingAddress(billingAddress);
137+
request.addLineItemsItem(lineItem);
138+
139+
// Create Transaction
140+
Transaction transaction = apiClient.getTransactionService().create(spaceId, request);
141+
142+
// Build the payment page URL to which the user should be redirected when the payment page should be used:
143+
String paymentPageUrl = apiClient.getTransactionPaymentPageService().paymentPageUrl(spaceId, transaction.getId());
144+
System.out.println("Payment Page URL: " + paymentPageUrl);
145+
146+
// The above statement should print something like:
147+
//
148+
// Payment Page URL: https://app-wallee.com/s/405/payment/transaction/pay/[transaction ID]?securityToken=[some token]
149+
//
150+
}
173151

174152
}
175153

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'idea'
22
apply plugin: 'eclipse'
33

44
group = 'ch.postfinance'
5-
version = '4.0.9'
5+
version = '4.0.10'
66

77
buildscript {
88
repositories {

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ lazy val root = (project in file(".")).
22
settings(
33
organization := "ch.postfinance",
44
name := "postfinancecheckout-java-sdk",
5-
version := "4.0.9",
5+
version := "4.0.10",
66
scalaVersion := "2.11.4",
77
scalacOptions ++= Seq("-feature"),
88
javacOptions in compile ++= Seq("-Xlint:deprecation"),

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>postfinancecheckout-java-sdk</artifactId>
66
<packaging>jar</packaging>
77
<name>postfinancecheckout-java-sdk</name>
8-
<version>4.0.9</version>
8+
<version>4.0.10</version>
99
<url>https://postfinance.ch/en/business/products/e-commerce/postfinance-checkout-all-in-one.html</url>
1010
<description>The SDK for simplifying the integration with PostFinance Checkout API.</description>
1111
<scm>

src/main/java/ch/postfinance/sdk/ApiClient.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ public AccountService getAccountService() {
127127
return this.accountService;
128128
}
129129

130+
private AnalyticsQueryService analyticsQueryService;
131+
public AnalyticsQueryService getAnalyticsQueryService() {
132+
if (this.analyticsQueryService == null) {
133+
this.analyticsQueryService = new AnalyticsQueryService(this);
134+
}
135+
return this.analyticsQueryService;
136+
}
137+
130138
private ApplicationUserService applicationUserService;
131139
public ApplicationUserService getApplicationUserService() {
132140
if (this.applicationUserService == null) {

src/main/java/ch/postfinance/sdk/DefaultHeaders.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void intercept(HttpRequest request) throws IOException {
3434

3535
private HttpHeaders getDefaultHeaders() {
3636
HttpHeaders headers = new HttpHeaders();
37-
headers.put("x-meta-sdk-version", "4.0.9");
37+
headers.put("x-meta-sdk-version", "4.0.10");
3838
headers.put("x-meta-sdk-language", "java");
3939
headers.put("x-meta-sdk-provider", "PostFinance Checkout");
4040
headers.put("x-meta-sdk-language-version", System.getProperty("java.version"));

0 commit comments

Comments
 (0)