@@ -8,15 +8,17 @@ $ mvn clean compile
88```
99
1010### Deploy to your own artifacts sever
11+
1112Currently, the Datatrans Java SDK is not yet available on Maven Central (or something similar).
12- Thats why you manually need to deploy it to your own artifacts hosting solution.
13+ That's why you manually need to deploy it to your own artifacts hosting solution.
1314
1415```
1516# You might have to adjust your ~/.m2/settings.xml or add a <distributionManagement> section to the pom.xml
1617$ mvn deploy
1718```
1819
1920## Using the Java SDK
21+
2022Once deployed, add the following dependency:
2123
2224### Maven users
@@ -41,6 +43,7 @@ compile "ch.datatrans:datatrans-java-sdk:2.0.15"
4143```
4244
4345### Invoking the SDK
46+
4447``` java
4548ApiClient defaultClient = Configuration . getDefaultApiClient();
4649defaultClient. setBasePath(" https://api.sandbox.datatrans.com" );
@@ -52,28 +55,26 @@ Basic.setPassword("password"); // your Datatrans server to server password
5255
5356V1TransactionsApi transactionsApiInstance = new V1TransactionsApi (defaultClient);
5457
55- AuthorizeRequest authorizeRequest = new AuthorizeRequest ();
56- authorizeRequest. currency(" CHF" )
58+ RedirectRequest redirectRequest = new RedirectRequest ();
59+ redirectRequest. successUrl(" https://pay.sandbox.datatrans.com/upp/merchant/successPage.jsp" )
60+ .cancelUrl(" https://pay.sandbox.datatrans.com/upp/merchant/cancelPage.jsp" )
61+ .errorUrl(" https://pay.sandbox.datatrans.com/upp/merchant/errorPage.jsp" );
62+
63+ InitRequest initRequest = new InitRequest ();
64+ initRequest. currency(" CHF" )
65+ .paymentMethods(List . of(InitRequest . PaymentMethodsEnum . VIS ))
66+ .redirect(redirectRequest)
5767 .amount(100L )
5868 .refno(String . valueOf(System . currentTimeMillis()));
5969
60- CardAuthorizeRequest cardAuthorizeRequest = new CardAuthorizeRequest ();
61-
62- cardAuthorizeRequest. alias(" AAABcH0Bq92s3kgAESIAAbGj5NIsAHWC" )
63- .expiryMonth(" 12" )
64- .expiryYear(" 21" );
65-
66- authorizeRequest. setCard(cardAuthorizeRequest);
67-
6870try {
69- AuthorizeResponse result = transactionsApiInstance. authorize(authorizeRequest );
71+ InitResponse result = transactionsApiInstance. init(initRequest );
7072 System . out. println(result);
7173} catch (ApiException e) {
72- System . err. println(" Exception when calling V1AliasesApi#aliasesConvert " );
74+ System . err. println(" Exception when calling V1TransactionsApi#init " );
7375 System . err. println(" Status code: " + e. getCode());
7476 System . err. println(" Reason: " + e. getResponseBody());
7577 System . err. println(" Response headers: " + e. getResponseHeaders());
7678 e. printStackTrace();
7779}
7880```
79-
0 commit comments