Add preAuth (#34)

This commit is contained in:
struga 2022-05-20 15:12:42 +03:00 committed by GitHub
parent 35685ba833
commit ba825592ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 1 deletions

View File

@ -12,7 +12,7 @@
</parent>
<artifactId>adapter-flow-lib</artifactId>
<version>0.1.5</version>
<version>0.1.6</version>
<packaging>jar</packaging>
<name>adapter-flow-lib</name>

View File

@ -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();
}

View File

@ -2,6 +2,7 @@ package dev.vality.adapter.flow.lib.constant;
public enum Step {
PRE_AUTH,
AUTH,
PAY,
GENERATE_TOKEN,

View File

@ -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<BaseRequestModel, BaseResponseModel, EntryStateModel, ExitStateModel> {
public PreAuthHandler(
RemoteClient client,
Converter<EntryStateModel, BaseRequestModel> converter,
Processor<ExitStateModel, BaseResponseModel, EntryStateModel> responseProcessorChain
) {
super(client::preAuth, converter, responseProcessorChain);
}
@Override
public boolean isHandle(EntryStateModel entryStateModel) {
return Step.PRE_AUTH == entryStateModel.getCurrentStep();
}
}