diff --git a/README.md b/README.md index 6b0ed35..e79f20f 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,9 @@ $ mvn clean compile ``` ### Deploy to your own artifacts sever + Currently, the Datatrans Java SDK is not yet available on Maven Central (or something similar). -Thats why you manually need to deploy it to your own artifacts hosting solution. +That's why you manually need to deploy it to your own artifacts hosting solution. ``` # You might have to adjust your ~/.m2/settings.xml or add a section to the pom.xml @@ -17,6 +18,7 @@ $ mvn deploy ``` ## Using the Java SDK + Once deployed, add the following dependency: ### Maven users @@ -41,6 +43,7 @@ compile "ch.datatrans:datatrans-java-sdk:2.0.15" ``` ### Invoking the SDK + ```java ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("https://api.sandbox.datatrans.com"); @@ -52,28 +55,26 @@ Basic.setPassword("password"); // your Datatrans server to server password V1TransactionsApi transactionsApiInstance = new V1TransactionsApi(defaultClient); -AuthorizeRequest authorizeRequest = new AuthorizeRequest(); -authorizeRequest.currency("CHF") +RedirectRequest redirectRequest = new RedirectRequest(); +redirectRequest.successUrl("https://pay.sandbox.datatrans.com/upp/merchant/successPage.jsp") + .cancelUrl("https://pay.sandbox.datatrans.com/upp/merchant/cancelPage.jsp") + .errorUrl("https://pay.sandbox.datatrans.com/upp/merchant/errorPage.jsp"); + +InitRequest initRequest = new InitRequest(); +initRequest.currency("CHF") + .paymentMethods(List.of(InitRequest.PaymentMethodsEnum.VIS)) + .redirect(redirectRequest) .amount(100L) .refno(String.valueOf(System.currentTimeMillis())); -CardAuthorizeRequest cardAuthorizeRequest = new CardAuthorizeRequest(); - -cardAuthorizeRequest.alias("AAABcH0Bq92s3kgAESIAAbGj5NIsAHWC") - .expiryMonth("12") - .expiryYear("21"); - -authorizeRequest.setCard(cardAuthorizeRequest); - try { - AuthorizeResponse result = transactionsApiInstance.authorize(authorizeRequest); + InitResponse result = transactionsApiInstance.init(initRequest); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling V1AliasesApi#aliasesConvert"); + System.err.println("Exception when calling V1TransactionsApi#init"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } ``` - diff --git a/pom.xml b/pom.xml index 441ea63..4aefcd1 100644 --- a/pom.xml +++ b/pom.xml @@ -14,14 +14,14 @@ 3.8.1 1.8.5 1.6.2 - 4.9.1 - 2.8.6 + 4.12.0 + 2.8.9 3.11 1.3.2 - 4.13.1 + 5.10.3 3.0.2 - 2.0.15 - 5.1.0 + 2.0.45 + 7.7.0 ch.datatrans @@ -70,8 +70,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter-api ${junit-version} test @@ -133,4 +133,4 @@ - \ No newline at end of file + diff --git a/src/main/resources/datatrans-openapi-specification-2.0.15.json b/src/main/resources/datatrans-openapi-specification-2.0.15.json deleted file mode 100644 index 3b78ccc..0000000 --- a/src/main/resources/datatrans-openapi-specification-2.0.15.json +++ /dev/null @@ -1,5664 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Datatrans API Reference", - "description": "Welcome to the Datatrans API reference.\nThis document is meant to be used in combination with https://docs.datatrans.ch.\nAll the parameters used in the curl and web samples are described here.\nReach out to support@datatrans.ch if something is missing or unclear.\n\nLast updated: 24.03.21 - 13:17 UTC\n\n# Payment Process\nThe following steps describe how transactions are processed with Datatrans.\nWe separate payments in three categories: Customer-initiated payments, merchant-initiated payments and after the payment.\n\n## Customer Initiated Payments\nWe have three integrations available: [Redirect](https://docs.datatrans.ch/docs/redirect-lightbox),\n[Lightbox](https://docs.datatrans.ch/docs/redirect-lightbox) and [Secure Fields](https://docs.datatrans.ch/docs/secure-fields).\n\n### Redirect & Lightbox\n- Send the required parameters to initialize a `transactionId` to the [init](#operation/init) endpoint.\n- Let the customer proceed with the payment by redirecting them to the correct link - or showing them your payment form.\n - Redirect: Redirect the browser to the following URL structure\n ```\n https://pay.sandbox.datatrans.com/v1/start/transactionId\n ```\n - Lightbox: Load the JavaScript library and initialize the payment form:\n ```js\n