From 063586c5127790cf09a8c7aaeade58ce592051e6 Mon Sep 17 00:00:00 2001 From: struga Date: Wed, 9 Mar 2022 14:59:41 +0300 Subject: [PATCH] Fix trx (#15) --- pom.xml | 2 +- ...eRedirectWithPollingResultIntentResolver.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 8248b63..986cbdc 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ adapter-flow-lib - 0.0.10 + 0.0.11 jar adapter-flow-lib diff --git a/src/main/java/dev/vality/adapter/flow/lib/flow/simple/SimpleRedirectWithPollingResultIntentResolver.java b/src/main/java/dev/vality/adapter/flow/lib/flow/simple/SimpleRedirectWithPollingResultIntentResolver.java index eb33635..9280470 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/flow/simple/SimpleRedirectWithPollingResultIntentResolver.java +++ b/src/main/java/dev/vality/adapter/flow/lib/flow/simple/SimpleRedirectWithPollingResultIntentResolver.java @@ -2,6 +2,7 @@ package dev.vality.adapter.flow.lib.flow.simple; import dev.vality.adapter.flow.lib.constant.Status; import dev.vality.adapter.flow.lib.constant.Step; +import dev.vality.adapter.flow.lib.constant.TargetStatus; import dev.vality.adapter.flow.lib.flow.ResultIntentResolver; import dev.vality.adapter.flow.lib.model.EntryStateModel; import dev.vality.adapter.flow.lib.model.ExitStateModel; @@ -23,19 +24,18 @@ public class SimpleRedirectWithPollingResultIntentResolver implements ResultInte case CHECK_STATUS -> exitStateModel.getLastOperationStatus() == Status.NEED_REDIRECT ? intentResultFactory.createSuspendIntentWithCallbackAfterTimeout(exitStateModel) : intentResultFactory.createSleepIntentWithExponentialPolling(exitStateModel); - case DO_NOTHING -> createIntentByCurrentStep(exitStateModel, currentStep); + case DO_NOTHING -> createIntentByTargetStatus(exitStateModel); case REFUND, CANCEL -> intentResultFactory.createFinishIntentSuccess(); default -> throw new IllegalStateException("Wrong nextStep: " + nextStep); }; } - private Intent createIntentByCurrentStep(ExitStateModel exitStateModel, Step currentStep) { - return switch (currentStep) { - case CHECK_STATUS, CHECK_NEED_3DS_V2, FINISH_THREE_DS_V1, FINISH_THREE_DS_V2, DO_NOTHING, - PAY, AUTH -> intentResultFactory.createFinishIntentSuccessWithCheckToken(exitStateModel); - case REFUND, CANCEL -> intentResultFactory.createFinishIntentSuccess(); - default -> throw new IllegalStateException("Wrong currentStep: " + currentStep); - }; + private Intent createIntentByTargetStatus(ExitStateModel exitStateModel) { + if (exitStateModel.getEntryStateModel().getTargetStatus() == TargetStatus.CANCELLED + || exitStateModel.getEntryStateModel().getTargetStatus() == TargetStatus.REFUNDED) { + return intentResultFactory.createFinishIntentSuccess(); + } + return intentResultFactory.createFinishIntentSuccessWithCheckToken(exitStateModel); } }