Fix get card data (#9)

This commit is contained in:
struga 2022-03-01 18:14:26 +03:00 committed by GitHub
parent a99037996a
commit 40cab571c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 11 deletions

View File

@ -13,7 +13,7 @@
</parent>
<artifactId>adapter-flow-lib</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>
<packaging>jar</packaging>
<name>adapter-flow-lib</name>

View File

@ -76,9 +76,11 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
.providerTrxId(trx != null ? trx.getId() : temporaryContext.getProviderTrxId())
.savedData(trx != null ? trx.getExtra() : new HashMap<>())
.successRedirectUrl(getSuccessRedirectUrl(payment, adapterConfigurations))
.threeDsDataFromMpiCallback(temporaryContext.getThreeDsData())
.build())
.targetStatus(targetStatus)
.currentStep(currentStep)
.startedPollingInfo(temporaryContext.getPollingInfo())
.build();
}

View File

@ -50,6 +50,8 @@ public class RecCtxToEntryModelConverter implements Converter<RecurrentTokenCont
TransactionInfo transactionInfo = tokenInfo.getTrx();
Long orderId = idGenerator.get(tokenInfo.getPaymentTool().getId());
var temporaryContext = temporaryContextService.getTemporaryContext(context, temporaryContextDeserializer);
return entryStateModelBuilder
.baseRequestModel(BaseRequestModel.builder()
.recurrentPaymentData(RecurrentPaymentData
@ -74,8 +76,10 @@ public class RecCtxToEntryModelConverter implements Converter<RecurrentTokenCont
.savedData(transactionInfo == null || transactionInfo.getExtra() == null
? new HashMap<>()
: transactionInfo.getExtra())
.threeDsDataFromMpiCallback(temporaryContext.getThreeDsData())
.build())
.currentStep(generalExitStateModel.getNextStep())
.startedPollingInfo(temporaryContext.getPollingInfo())
.build();
}

View File

@ -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<String, String> 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) {

View File

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

View File

@ -0,0 +1,9 @@
package dev.vality.adapter.flow.lib.utils;
public class TimeoutUtils {
public static int toSeconds(int timerRedirectTimeoutMin) {
return timerRedirectTimeoutMin * 60;
}
}