@@ -23,7 +23,7 @@ Add this dependency to your project's POM:
23
23
<dependency >
24
24
<groupId >ch.postfinance</groupId >
25
25
<artifactId >postfinancecheckout-java-sdk</artifactId >
26
- <version >4.0.9 </version >
26
+ <version >4.0.10 </version >
27
27
<scope >compile</scope >
28
28
</dependency >
29
29
```
@@ -33,7 +33,7 @@ Add this dependency to your project's POM:
33
33
Add this dependency to your project's build file:
34
34
35
35
``` groovy
36
- compile "ch.postfinance:postfinancecheckout-java-sdk:4.0.9 "
36
+ compile "ch.postfinance:postfinancecheckout-java-sdk:4.0.10 "
37
37
```
38
38
39
39
### Others
@@ -46,7 +46,7 @@ mvn clean package
46
46
47
47
Then manually install the following JARs:
48
48
49
- * ` target/postfinancecheckout-java-sdk-4.0.9 .jar `
49
+ * ` target/postfinancecheckout-java-sdk-4.0.10 .jar `
50
50
* ` target/lib/*.jar `
51
51
52
52
## Usage
@@ -65,15 +65,18 @@ public class Example {
65
65
66
66
public static void main (String [] args ) {
67
67
68
- // API Configuration.
69
- long spaceId = (Long ) 405 ;
70
- long userId = (Long ) 512 ;
68
+ // Credentials
69
+ Long userId = 512L ;
71
70
String secret = " FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=" ;
71
+
72
+ // API Client
72
73
ApiClient apiClient = new ApiClient (userId, secret);
73
74
74
- // Create API service instance.
75
+ // Create an API service instance:
75
76
TransactionService transactionService = apiClient. getTransactionService();
76
77
78
+ // ... use the transactionService to make API calls ...
79
+
77
80
}
78
81
}
79
82
```
@@ -83,93 +86,68 @@ To get started with sending transactions, please review the example below:
83
86
``` java
84
87
package ch.postfinance.sdk.test ;
85
88
89
+ import java.io.IOException ;
90
+ import java.math.BigDecimal ;
91
+
86
92
import ch.postfinance.sdk.ApiClient ;
87
93
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 ;
95
94
96
95
/**
97
- * API tests for TransactionPaymentPageService
96
+ *
98
97
*/
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
+ }
173
151
174
152
}
175
153
0 commit comments