diff --git a/pom.xml b/pom.xml index 1d623d0..32a42d6 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ adapter-flow-lib - 0.1.5 + 0.1.6 jar adapter-flow-lib diff --git a/src/main/java/dev/vality/adapter/flow/lib/client/RemoteClient.java b/src/main/java/dev/vality/adapter/flow/lib/client/RemoteClient.java index 6f49a61..be92a2e 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/client/RemoteClient.java +++ b/src/main/java/dev/vality/adapter/flow/lib/client/RemoteClient.java @@ -10,6 +10,10 @@ import dev.vality.adapter.flow.lib.model.BaseResponseModel; */ public interface RemoteClient { + default BaseResponseModel preAuth(BaseRequestModel request) { + throw new UnsupportedOperationException(); + } + default BaseResponseModel auth(BaseRequestModel request) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/dev/vality/adapter/flow/lib/constant/Step.java b/src/main/java/dev/vality/adapter/flow/lib/constant/Step.java index 4b68b01..17864d4 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/constant/Step.java +++ b/src/main/java/dev/vality/adapter/flow/lib/constant/Step.java @@ -2,6 +2,7 @@ package dev.vality.adapter.flow.lib.constant; public enum Step { + PRE_AUTH, AUTH, PAY, GENERATE_TOKEN, diff --git a/src/main/java/dev/vality/adapter/flow/lib/handler/payment/PreAuthHandler.java b/src/main/java/dev/vality/adapter/flow/lib/handler/payment/PreAuthHandler.java new file mode 100644 index 0000000..eff6b53 --- /dev/null +++ b/src/main/java/dev/vality/adapter/flow/lib/handler/payment/PreAuthHandler.java @@ -0,0 +1,29 @@ +package dev.vality.adapter.flow.lib.handler.payment; + +import dev.vality.adapter.flow.lib.client.RemoteClient; +import dev.vality.adapter.flow.lib.constant.Step; +import dev.vality.adapter.flow.lib.handler.CommonHandlerImpl; +import dev.vality.adapter.flow.lib.model.BaseRequestModel; +import dev.vality.adapter.flow.lib.model.BaseResponseModel; +import dev.vality.adapter.flow.lib.model.EntryStateModel; +import dev.vality.adapter.flow.lib.model.ExitStateModel; +import dev.vality.adapter.flow.lib.processor.Processor; +import org.springframework.core.convert.converter.Converter; + + +public class PreAuthHandler + extends CommonHandlerImpl { + + public PreAuthHandler( + RemoteClient client, + Converter converter, + Processor responseProcessorChain + ) { + super(client::preAuth, converter, responseProcessorChain); + } + + @Override + public boolean isHandle(EntryStateModel entryStateModel) { + return Step.PRE_AUTH == entryStateModel.getCurrentStep(); + } +}