diff --git a/README.md b/README.md index b016c2f..c3a9f6e 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Add this dependency to your project's POM: ch.postfinance postfinancecheckout-java-sdk - 4.0.3 + 4.0.5 compile ``` @@ -33,7 +33,7 @@ Add this dependency to your project's POM: Add this dependency to your project's build file: ```groovy -compile "ch.postfinance:postfinancecheckout-java-sdk:4.0.3" +compile "ch.postfinance:postfinancecheckout-java-sdk:4.0.5" ``` ### Others @@ -46,7 +46,7 @@ mvn clean package Then manually install the following JARs: -* `target/postfinancecheckout-java-sdk-4.0.3.jar` +* `target/postfinancecheckout-java-sdk-4.0.5.jar` * `target/lib/*.jar` ## Usage diff --git a/build.gradle b/build.gradle index aa52548..0d6acd6 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'idea' apply plugin: 'eclipse' group = 'ch.postfinance' -version = '4.0.3' +version = '4.0.5' buildscript { repositories { diff --git a/build.sbt b/build.sbt index fe18ada..486667c 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "ch.postfinance", name := "postfinancecheckout-java-sdk", - version := "4.0.3", + version := "4.0.5", scalaVersion := "2.11.4", scalacOptions ++= Seq("-feature"), javacOptions in compile ++= Seq("-Xlint:deprecation"), diff --git a/pom.xml b/pom.xml index 5898aa6..0192fd7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ postfinancecheckout-java-sdk jar postfinancecheckout-java-sdk - 4.0.3 + 4.0.5 https://www.postfinance.ch/checkout The SDK for simplifying the integration with PostFinance Checkout API. diff --git a/src/test/java/ch/postfinance/sdk/test/RefundServiceTest.java b/src/test/java/ch/postfinance/sdk/test/RefundServiceTest.java index 60ce787..46d6d1a 100644 --- a/src/test/java/ch/postfinance/sdk/test/RefundServiceTest.java +++ b/src/test/java/ch/postfinance/sdk/test/RefundServiceTest.java @@ -169,23 +169,27 @@ public void refundTest() throws Exception { } transaction = this.apiClient.getTransactionService().read(this.spaceId, transaction.getId()); } - Assert.assertEquals(TransactionState.FULFILL, transaction.getState()); - - TransactionCompletion transactionCompletion = this.apiClient.getTransactionCompletionService().completeOffline(this.spaceId, transaction.getId()); - Assert.assertEquals( - "Transaction completion successful", - transactionCompletion.getState(), - TransactionCompletionState.SUCCESSFUL - ); - - transaction = this.apiClient.getTransactionService().read(transaction.getLinkedSpaceId(), transactionCompletion.getLinkedTransaction()); - Refund refund = this.apiClient.getRefundService().refund(this.spaceId, getRefundPayload(transaction)); - - Assert.assertEquals( - "Refund successful", - refund.getState(), - RefundState.SUCCESSFUL - ); + + if (transaction.getState() == TransactionState.FULFILL) { + TransactionCompletion transactionCompletion = this.apiClient.getTransactionCompletionService().completeOffline(this.spaceId, transaction.getId()); + + Assert.assertEquals( + "Transaction completion successful", + transactionCompletion.getState(), + TransactionCompletionState.SUCCESSFUL + ); + + transaction = this.apiClient.getTransactionService().read(transaction.getLinkedSpaceId(), transactionCompletion.getLinkedTransaction()); + Refund refund = this.apiClient.getRefundService().refund(this.spaceId, getRefundPayload(transaction)); + + Assert.assertEquals( + "Refund successful", + refund.getState(), + RefundState.SUCCESSFUL + ); + } else { + System.err.println("API response timeout"); + } } /** diff --git a/src/test/java/ch/postfinance/sdk/test/TransactionCompletionServiceTest.java b/src/test/java/ch/postfinance/sdk/test/TransactionCompletionServiceTest.java index 40f9978..aa73605 100644 --- a/src/test/java/ch/postfinance/sdk/test/TransactionCompletionServiceTest.java +++ b/src/test/java/ch/postfinance/sdk/test/TransactionCompletionServiceTest.java @@ -99,15 +99,19 @@ public void completeOfflineTest() throws Exception{ } transaction = this.apiClient.getTransactionService().read(this.spaceId, transaction.getId()); } - Assert.assertEquals(TransactionState.AUTHORIZED, transaction.getState()); - - transaction = this.apiClient.getTransactionService().processWithoutUserInteraction(this.spaceId, transaction.getId()); - TransactionCompletion transactionCompletion = this.apiClient.getTransactionCompletionService().completeOffline(this.spaceId, transaction.getId()); - TransactionCompletionState[] TransactionCompletionStates = { - TransactionCompletionState.SUCCESSFUL, - TransactionCompletionState.PENDING - }; - Assert.assertTrue("Transaction Completions " + transactionCompletion.getState(), Arrays.asList(TransactionCompletionStates).contains(transactionCompletion.getState())); + if (transaction.getState() == TransactionState.FULFILL) { + Assert.assertEquals(TransactionState.AUTHORIZED, transaction.getState()); + + transaction = this.apiClient.getTransactionService().processWithoutUserInteraction(this.spaceId, transaction.getId()); + TransactionCompletion transactionCompletion = this.apiClient.getTransactionCompletionService().completeOffline(this.spaceId, transaction.getId()); + TransactionCompletionState[] TransactionCompletionStates = { + TransactionCompletionState.SUCCESSFUL, + TransactionCompletionState.PENDING + }; + Assert.assertTrue("Transaction Completions " + transactionCompletion.getState(), Arrays.asList(TransactionCompletionStates).contains(transactionCompletion.getState())); + } else { + System.err.println("API response timeout"); + } } /** @@ -135,14 +139,18 @@ public void completeOnlineTest() throws Exception { } transaction = this.apiClient.getTransactionService().read(this.spaceId, transaction.getId()); } - Assert.assertEquals(TransactionState.AUTHORIZED, transaction.getState()); - transaction = this.apiClient.getTransactionService().processWithoutUserInteraction(this.spaceId, transaction.getId()); - TransactionCompletion transactionCompletion = this.apiClient.getTransactionCompletionService().completeOnline(this.spaceId, transaction.getId()); - TransactionCompletionState[] TransactionCompletionStates = { - TransactionCompletionState.SUCCESSFUL, - TransactionCompletionState.PENDING - }; - Assert.assertTrue("Transaction Completions " + transactionCompletion.getState(), Arrays.asList(TransactionCompletionStates).contains(transactionCompletion.getState())); + if (transaction.getState() == TransactionState.FULFILL) { + Assert.assertEquals(TransactionState.AUTHORIZED, transaction.getState()); + transaction = this.apiClient.getTransactionService().processWithoutUserInteraction(this.spaceId, transaction.getId()); + TransactionCompletion transactionCompletion = this.apiClient.getTransactionCompletionService().completeOnline(this.spaceId, transaction.getId()); + TransactionCompletionState[] TransactionCompletionStates = { + TransactionCompletionState.SUCCESSFUL, + TransactionCompletionState.PENDING + }; + Assert.assertTrue("Transaction Completions " + transactionCompletion.getState(), Arrays.asList(TransactionCompletionStates).contains(transactionCompletion.getState())); + } else { + System.err.println("API response timeout"); + } } /** diff --git a/src/test/java/ch/postfinance/sdk/test/TransactionServiceTest.java b/src/test/java/ch/postfinance/sdk/test/TransactionServiceTest.java index 2d51818..e36cb39 100644 --- a/src/test/java/ch/postfinance/sdk/test/TransactionServiceTest.java +++ b/src/test/java/ch/postfinance/sdk/test/TransactionServiceTest.java @@ -254,13 +254,16 @@ public void processWithoutUserInteractionTest() throws Exception{ TransactionState[] TransactionStates = { TransactionState.FULFILL }; - Assert.assertTrue(Arrays.asList(TransactionStates).contains(transaction.getState())); - - - RenderedDocument renderedDocument = this.apiClient.getTransactionService().getInvoiceDocument(this.spaceId, transaction.getId()); - Assert.assertEquals(true, renderedDocument.getData() != null); - Assert.assertEquals(true, renderedDocument.getData().length > 0); - + if (transaction.getState() == TransactionState.FULFILL) { + Assert.assertTrue(Arrays.asList(TransactionStates).contains(transaction.getState())); + + + RenderedDocument renderedDocument = this.apiClient.getTransactionService().getInvoiceDocument(this.spaceId, transaction.getId()); + Assert.assertEquals(true, renderedDocument.getData() != null); + Assert.assertEquals(true, renderedDocument.getData().length > 0); + } else { + System.err.println("API response timeout"); + } } /**