From 40cab571c555e53a9f6cec40fed1cced3ca928f5 Mon Sep 17 00:00:00 2001 From: struga Date: Tue, 1 Mar 2022 18:14:26 +0300 Subject: [PATCH] Fix get card data (#9) --- pom.xml | 2 +- .../lib/converter/entry/CtxToEntryModelConverter.java | 2 ++ .../converter/entry/RecCtxToEntryModelConverter.java | 4 ++++ .../adapter/flow/lib/service/IntentResultFactory.java | 11 +++++------ .../lib/service/RecurrentIntentResultFactory.java | 9 +++++---- .../vality/adapter/flow/lib/utils/TimeoutUtils.java | 9 +++++++++ 6 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 src/main/java/dev/vality/adapter/flow/lib/utils/TimeoutUtils.java diff --git a/pom.xml b/pom.xml index 199aaa5..c3d41bd 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ adapter-flow-lib - 0.0.5 + 0.0.6 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 61f524d..6e4a2b1 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 @@ -76,9 +76,11 @@ public class CtxToEntryModelConverter implements Converter()) .successRedirectUrl(getSuccessRedirectUrl(payment, adapterConfigurations)) + .threeDsDataFromMpiCallback(temporaryContext.getThreeDsData()) .build()) .targetStatus(targetStatus) .currentStep(currentStep) + .startedPollingInfo(temporaryContext.getPollingInfo()) .build(); } diff --git a/src/main/java/dev/vality/adapter/flow/lib/converter/entry/RecCtxToEntryModelConverter.java b/src/main/java/dev/vality/adapter/flow/lib/converter/entry/RecCtxToEntryModelConverter.java index a0616c0..b23b118 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/converter/entry/RecCtxToEntryModelConverter.java +++ b/src/main/java/dev/vality/adapter/flow/lib/converter/entry/RecCtxToEntryModelConverter.java @@ -50,6 +50,8 @@ public class RecCtxToEntryModelConverter implements Converter() : transactionInfo.getExtra()) + .threeDsDataFromMpiCallback(temporaryContext.getThreeDsData()) .build()) .currentStep(generalExitStateModel.getNextStep()) + .startedPollingInfo(temporaryContext.getPollingInfo()) .build(); } 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 efb80ee..6f87014 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,6 +8,7 @@ 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; import dev.vality.damsel.base.Timer; import dev.vality.damsel.proxy_provider.*; @@ -72,13 +73,13 @@ public class IntentResultFactory { String redirectUrl = entryStateModel.getBaseRequestModel().getSuccessRedirectUrl(); params.put(RedirectFields.TERM_URL.getValue(), callbackUrlExtractor.extractCallbackUrl(redirectUrl)); ThreeDsData threeDsData = exitStateModel.getThreeDsData(); - int timerRedirectTimeout = extractRedirectTimeout( + int timerRedirectTimeoutMin = extractRedirectTimeout( entryStateModel.getBaseRequestModel().getAdapterConfigurations(), timerProperties.getRedirectTimeoutMin()); return Intent.suspend( new SuspendIntent( tagManagementService.findTag(params), - Timer.timeout(timerRedirectTimeout)) + Timer.timeout(TimeoutUtils.toSeconds(timerRedirectTimeoutMin))) .setTimeoutBehaviour(TimeoutBehaviour.callback( ByteBuffer.wrap(parametersSerializer.writeByte(params))) ).setUserInteraction(createPostUserInteraction(threeDsData.getAcsUrl(), params)) @@ -102,11 +103,9 @@ public class IntentResultFactory { exitStateModel.setPollingInfo(pollingInfo); Map adapterConfigurations = entryStateModel.getBaseRequestModel().getAdapterConfigurations(); - int nextTimeout = + int nextTimeoutSec = exponentialBackOffPollingService.prepareNextPollingInterval(pollingInfo, adapterConfigurations); - return Intent.sleep( - new SleepIntent(Timer.timeout(nextTimeout)) - ); + return Intent.sleep(new SleepIntent(Timer.timeout(nextTimeoutSec))); } public Intent createFinishIntentFailed(ExitStateModel exitStateModel) { 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 ab4ccfc..063f627 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 @@ -7,6 +7,7 @@ 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; import dev.vality.damsel.base.Timer; import dev.vality.damsel.proxy_provider.*; @@ -35,13 +36,13 @@ public class RecurrentIntentResultFactory { Map params = ThreeDsDataInitializer.initThreeDsParameters(exitStateModel); String redirectUrl = entryStateModel.getBaseRequestModel().getSuccessRedirectUrl(); params.put(RedirectFields.TERM_URL.getValue(), callbackUrlExtractor.extractCallbackUrl(redirectUrl)); - int timerRedirectTimeout = extractRedirectTimeout( + int timerRedirectTimeoutMin = extractRedirectTimeout( entryStateModel.getBaseRequestModel().getAdapterConfigurations(), timerProperties.getRedirectTimeoutMin()); return RecurrentTokenIntent.suspend( new SuspendIntent( tagManagementService.findTag(params), - Timer.timeout(timerRedirectTimeout) + Timer.timeout(TimeoutUtils.toSeconds(timerRedirectTimeoutMin)) ).setUserInteraction(createPostUserInteraction(threeDsData.getAcsUrl(), params)) ); } @@ -59,10 +60,10 @@ public class RecurrentIntentResultFactory { exitStateModel.setPollingInfo(pollingInfo); Map adapterConfigurations = entryStateModel.getBaseRequestModel().getAdapterConfigurations(); - int nextTimeout = + int nextTimeoutSec = exponentialBackOffPollingService.prepareNextPollingInterval(pollingInfo, adapterConfigurations); return RecurrentTokenIntent.sleep( - new SleepIntent(Timer.timeout(nextTimeout)) + new SleepIntent(Timer.timeout(nextTimeoutSec)) ); } diff --git a/src/main/java/dev/vality/adapter/flow/lib/utils/TimeoutUtils.java b/src/main/java/dev/vality/adapter/flow/lib/utils/TimeoutUtils.java new file mode 100644 index 0000000..0a9b777 --- /dev/null +++ b/src/main/java/dev/vality/adapter/flow/lib/utils/TimeoutUtils.java @@ -0,0 +1,9 @@ +package dev.vality.adapter.flow.lib.utils; + +public class TimeoutUtils { + + public static int toSeconds(int timerRedirectTimeoutMin) { + return timerRedirectTimeoutMin * 60; + } + +}