diff --git a/pom.xml b/pom.xml index be40bac..949ad62 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ adapter-flow-lib - 0.1.19 + 0.1.20 jar adapter-flow-lib diff --git a/src/main/java/dev/vality/adapter/flow/lib/converter/entry/CtxToEntryModelConverter.java b/src/main/java/dev/vality/adapter/flow/lib/converter/entry/CtxToEntryModelConverter.java index 549c178..19cccd7 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/converter/entry/CtxToEntryModelConverter.java +++ b/src/main/java/dev/vality/adapter/flow/lib/converter/entry/CtxToEntryModelConverter.java @@ -11,7 +11,7 @@ import dev.vality.adapter.flow.lib.service.CardDataService; import dev.vality.adapter.flow.lib.service.IdGenerator; import dev.vality.adapter.flow.lib.service.TemporaryContextService; import dev.vality.adapter.flow.lib.utils.AdapterProperties; -import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor; +import dev.vality.adapter.flow.lib.service.CallbackUrlExtractor; import dev.vality.adapter.flow.lib.utils.CardDataUtils; import dev.vality.adapter.flow.lib.utils.TargetStatusResolver; import dev.vality.cds.storage.Auth3DS; diff --git a/src/main/java/dev/vality/adapter/flow/lib/service/CallbackUrlExtractor.java b/src/main/java/dev/vality/adapter/flow/lib/service/CallbackUrlExtractor.java new file mode 100644 index 0000000..b33a421 --- /dev/null +++ b/src/main/java/dev/vality/adapter/flow/lib/service/CallbackUrlExtractor.java @@ -0,0 +1,13 @@ +package dev.vality.adapter.flow.lib.service; + +import java.util.Map; + +public interface CallbackUrlExtractor { + + String TERMINATION_URI = "termination_uri"; + + String extractCallbackUrl(String redirectUrl); + + String getSuccessRedirectUrl(Map adapterConfigurations, String redirectUrl); + +} diff --git a/src/main/java/dev/vality/adapter/flow/lib/service/IntentResultFactory.java b/src/main/java/dev/vality/adapter/flow/lib/service/IntentResultFactory.java index 0aaae3c..53102f9 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/service/IntentResultFactory.java +++ b/src/main/java/dev/vality/adapter/flow/lib/service/IntentResultFactory.java @@ -8,7 +8,6 @@ import dev.vality.adapter.flow.lib.model.ExitStateModel; import dev.vality.adapter.flow.lib.model.PollingInfo; import dev.vality.adapter.flow.lib.model.ThreeDsData; import dev.vality.adapter.flow.lib.serde.ParametersSerializer; -import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor; import dev.vality.adapter.flow.lib.utils.ThreeDsDataInitializer; import dev.vality.adapter.flow.lib.utils.TimeoutUtils; import dev.vality.adapter.flow.lib.utils.TimerProperties; diff --git a/src/main/java/dev/vality/adapter/flow/lib/service/RecurrentIntentResultFactory.java b/src/main/java/dev/vality/adapter/flow/lib/service/RecurrentIntentResultFactory.java index 59fcbcd..3c70234 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/service/RecurrentIntentResultFactory.java +++ b/src/main/java/dev/vality/adapter/flow/lib/service/RecurrentIntentResultFactory.java @@ -6,7 +6,6 @@ import dev.vality.adapter.flow.lib.model.EntryStateModel; import dev.vality.adapter.flow.lib.model.ExitStateModel; import dev.vality.adapter.flow.lib.model.PollingInfo; import dev.vality.adapter.flow.lib.model.ThreeDsData; -import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor; import dev.vality.adapter.flow.lib.utils.ThreeDsDataInitializer; import dev.vality.adapter.flow.lib.utils.TimeoutUtils; import dev.vality.adapter.flow.lib.utils.TimerProperties; diff --git a/src/main/java/dev/vality/adapter/flow/lib/service/ThreeDsAdapterService.java b/src/main/java/dev/vality/adapter/flow/lib/service/ThreeDsAdapterService.java index d1c561c..f3ec46f 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/service/ThreeDsAdapterService.java +++ b/src/main/java/dev/vality/adapter/flow/lib/service/ThreeDsAdapterService.java @@ -4,7 +4,6 @@ import dev.vality.adapter.common.exception.HellgateException; import dev.vality.adapter.common.hellgate.HellgateClient; import dev.vality.adapter.flow.lib.serde.ParametersDeserializer; import dev.vality.adapter.flow.lib.serde.ParametersSerializer; -import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; diff --git a/src/main/java/dev/vality/adapter/flow/lib/utils/CallbackUrlExtractor.java b/src/main/java/dev/vality/adapter/flow/lib/service/impl/CallbackUrlExtractorImpl.java similarity index 77% rename from src/main/java/dev/vality/adapter/flow/lib/utils/CallbackUrlExtractor.java rename to src/main/java/dev/vality/adapter/flow/lib/service/impl/CallbackUrlExtractorImpl.java index 7e402e7..4f7d5fa 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/utils/CallbackUrlExtractor.java +++ b/src/main/java/dev/vality/adapter/flow/lib/service/impl/CallbackUrlExtractorImpl.java @@ -1,6 +1,8 @@ -package dev.vality.adapter.flow.lib.utils; +package dev.vality.adapter.flow.lib.service.impl; import dev.vality.adapter.flow.lib.constant.RedirectFields; +import dev.vality.adapter.flow.lib.service.CallbackUrlExtractor; +import dev.vality.adapter.flow.lib.utils.AdapterProperties; import lombok.RequiredArgsConstructor; import org.springframework.util.StringUtils; import org.springframework.web.util.UriComponentsBuilder; @@ -8,18 +10,18 @@ import org.springframework.web.util.UriComponentsBuilder; import java.util.Map; @RequiredArgsConstructor -public class CallbackUrlExtractor { - - public static final String TERMINATION_URI = "termination_uri"; +public class CallbackUrlExtractorImpl implements CallbackUrlExtractor { private final AdapterProperties adapterProperties; + @Override public String extractCallbackUrl(String redirectUrl) { return UriComponentsBuilder.fromUriString(adapterProperties.getCallbackUrl()) .path(adapterProperties.getPathCallbackUrl()) .queryParam(TERMINATION_URI, redirectUrl).build().toUriString(); } + @Override public String getSuccessRedirectUrl(Map adapterConfigurations, String redirectUrl) { if (StringUtils.hasText(redirectUrl)) { return redirectUrl; diff --git a/src/test/java/dev/vality/adapter/flow/lib/flow/AbstractGenerateTokenTest.java b/src/test/java/dev/vality/adapter/flow/lib/flow/AbstractGenerateTokenTest.java index 79ae2da..64c6763 100644 --- a/src/test/java/dev/vality/adapter/flow/lib/flow/AbstractGenerateTokenTest.java +++ b/src/test/java/dev/vality/adapter/flow/lib/flow/AbstractGenerateTokenTest.java @@ -11,7 +11,7 @@ import dev.vality.adapter.flow.lib.flow.full.FullThreeDsAllVersionsStepResolverI import dev.vality.adapter.flow.lib.flow.full.GenerateTokenFullThreeDsAllVersionsStepResolverImpl; import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer; import dev.vality.adapter.flow.lib.service.TagManagementService; -import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor; +import dev.vality.adapter.flow.lib.service.impl.CallbackUrlExtractorImpl; import dev.vality.adapter.flow.lib.validator.AdapterConfigurationValidator; import dev.vality.bender.BenderSrv; import dev.vality.damsel.proxy_provider.*; @@ -25,11 +25,10 @@ import static dev.vality.adapter.common.damsel.DomainPackageCreators.createTarge import static dev.vality.adapter.flow.lib.flow.full.three.ds.ForwardRecurrentPaymentNon3dsTest.RECURRENT_TOKEN; import static org.junit.jupiter.api.Assertions.*; - @PropertySource("classpath:application.yaml") @ContextConfiguration(classes = {HandlerConfig.class, AppConfig.class, ProcessorConfig.class, SerdeConfig.class, ThreeDsCallbackController.class, TomcatEmbeddedConfiguration.class, TagManagementService.class, - CallbackUrlExtractor.class, FullThreeDsAllVersionsStepResolverImpl.class, + CallbackUrlExtractorImpl.class, FullThreeDsAllVersionsStepResolverImpl.class, GenerateTokenFullThreeDsAllVersionsStepResolverImpl.class}) public class AbstractGenerateTokenTest { diff --git a/src/test/java/dev/vality/adapter/flow/lib/flow/AbstractPaymentTest.java b/src/test/java/dev/vality/adapter/flow/lib/flow/AbstractPaymentTest.java index 80e4638..00b0f25 100644 --- a/src/test/java/dev/vality/adapter/flow/lib/flow/AbstractPaymentTest.java +++ b/src/test/java/dev/vality/adapter/flow/lib/flow/AbstractPaymentTest.java @@ -11,7 +11,7 @@ import dev.vality.adapter.flow.lib.flow.full.FullThreeDsAllVersionsStepResolverI import dev.vality.adapter.flow.lib.flow.full.GenerateTokenFullThreeDsAllVersionsStepResolverImpl; import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer; import dev.vality.adapter.flow.lib.service.TagManagementService; -import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor; +import dev.vality.adapter.flow.lib.service.impl.CallbackUrlExtractorImpl; import dev.vality.adapter.flow.lib.validator.AdapterConfigurationValidator; import dev.vality.bender.BenderSrv; import dev.vality.damsel.domain.InvoicePaymentCaptured; @@ -27,11 +27,10 @@ import org.springframework.test.context.ContextConfiguration; import static dev.vality.adapter.common.damsel.DomainPackageCreators.createTargetProcessed; import static org.junit.jupiter.api.Assertions.*; - @PropertySource("classpath:application.yaml") @ContextConfiguration(classes = {HandlerConfig.class, AppConfig.class, ProcessorConfig.class, SerdeConfig.class, ThreeDsCallbackController.class, TomcatEmbeddedConfiguration.class, TagManagementService.class, - CallbackUrlExtractor.class, FullThreeDsAllVersionsStepResolverImpl.class, + CallbackUrlExtractorImpl.class, FullThreeDsAllVersionsStepResolverImpl.class, GenerateTokenFullThreeDsAllVersionsStepResolverImpl.class}) public class AbstractPaymentTest { diff --git a/src/test/java/dev/vality/adapter/flow/lib/flow/config/HandlerConfig.java b/src/test/java/dev/vality/adapter/flow/lib/flow/config/HandlerConfig.java index cf003ab..4ce97c2 100644 --- a/src/test/java/dev/vality/adapter/flow/lib/flow/config/HandlerConfig.java +++ b/src/test/java/dev/vality/adapter/flow/lib/flow/config/HandlerConfig.java @@ -23,7 +23,7 @@ import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer; import dev.vality.adapter.flow.lib.serde.TemporaryContextSerializer; import dev.vality.adapter.flow.lib.service.*; import dev.vality.adapter.flow.lib.utils.AdapterProperties; -import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor; +import dev.vality.adapter.flow.lib.service.CallbackUrlExtractor; import dev.vality.adapter.flow.lib.utils.TimerProperties; import dev.vality.adapter.flow.lib.validator.AdapterConfigurationValidator; import dev.vality.bender.BenderSrv;