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>
<artifactId>adapter-flow-lib</artifactId>
<version>0.0.10</version>
<version>0.0.11</version>
<packaging>jar</packaging>
<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.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);
}
}