This commit is contained in:
struga 2022-03-09 14:59:41 +03:00 committed by GitHub
parent 9660ae04a6
commit 063586c512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -13,7 +13,7 @@
</parent> </parent>
<artifactId>adapter-flow-lib</artifactId> <artifactId>adapter-flow-lib</artifactId>
<version>0.0.10</version> <version>0.0.11</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>adapter-flow-lib</name> <name>adapter-flow-lib</name>

View File

@ -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.Status;
import dev.vality.adapter.flow.lib.constant.Step; 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.flow.ResultIntentResolver;
import dev.vality.adapter.flow.lib.model.EntryStateModel; import dev.vality.adapter.flow.lib.model.EntryStateModel;
import dev.vality.adapter.flow.lib.model.ExitStateModel; 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 case CHECK_STATUS -> exitStateModel.getLastOperationStatus() == Status.NEED_REDIRECT
? intentResultFactory.createSuspendIntentWithCallbackAfterTimeout(exitStateModel) ? intentResultFactory.createSuspendIntentWithCallbackAfterTimeout(exitStateModel)
: intentResultFactory.createSleepIntentWithExponentialPolling(exitStateModel); : intentResultFactory.createSleepIntentWithExponentialPolling(exitStateModel);
case DO_NOTHING -> createIntentByCurrentStep(exitStateModel, currentStep); case DO_NOTHING -> createIntentByTargetStatus(exitStateModel);
case REFUND, CANCEL -> intentResultFactory.createFinishIntentSuccess(); case REFUND, CANCEL -> intentResultFactory.createFinishIntentSuccess();
default -> throw new IllegalStateException("Wrong nextStep: " + nextStep); default -> throw new IllegalStateException("Wrong nextStep: " + nextStep);
}; };
} }
private Intent createIntentByCurrentStep(ExitStateModel exitStateModel, Step currentStep) { private Intent createIntentByTargetStatus(ExitStateModel exitStateModel) {
return switch (currentStep) { if (exitStateModel.getEntryStateModel().getTargetStatus() == TargetStatus.CANCELLED
case CHECK_STATUS, CHECK_NEED_3DS_V2, FINISH_THREE_DS_V1, FINISH_THREE_DS_V2, DO_NOTHING, || exitStateModel.getEntryStateModel().getTargetStatus() == TargetStatus.REFUNDED) {
PAY, AUTH -> intentResultFactory.createFinishIntentSuccessWithCheckToken(exitStateModel); return intentResultFactory.createFinishIntentSuccess();
case REFUND, CANCEL -> intentResultFactory.createFinishIntentSuccess(); }
default -> throw new IllegalStateException("Wrong currentStep: " + currentStep); return intentResultFactory.createFinishIntentSuccessWithCheckToken(exitStateModel);
};
} }
} }