From ddea6b66c77bd0828ec0af3257b6f1fc6c6e89ae Mon Sep 17 00:00:00 2001
From: Baikov Dmitrii <44803026+D-Baykov@users.noreply.github.com>
Date: Thu, 28 Jul 2022 04:46:42 -0700
Subject: [PATCH] INT-193: Add FailedUrl filling (#43)
---
pom.xml | 2 +-
.../flow/lib/constant/OptionFields.java | 1 +
.../entry/CtxToEntryModelConverter.java | 18 +++++++++++++++---
.../flow/lib/flow/config/HandlerConfig.java | 6 ++++--
4 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/pom.xml b/pom.xml
index 535acc3..3fec1e7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
adapter-flow-lib
- 0.1.13
+ 0.1.14
jar
adapter-flow-lib
diff --git a/src/main/java/dev/vality/adapter/flow/lib/constant/OptionFields.java b/src/main/java/dev/vality/adapter/flow/lib/constant/OptionFields.java
index 89b00f5..6610cd8 100644
--- a/src/main/java/dev/vality/adapter/flow/lib/constant/OptionFields.java
+++ b/src/main/java/dev/vality/adapter/flow/lib/constant/OptionFields.java
@@ -4,5 +4,6 @@ public enum OptionFields {
STAGE,
CARD_HOLDER_FROM_FILE,
+ FAILED_URL
}
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 1afc9bd..90cf421 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
@@ -4,14 +4,13 @@ import dev.vality.adapter.common.cds.CdsStorageClient;
import dev.vality.adapter.common.cds.model.CardDataProxyModel;
import dev.vality.adapter.common.damsel.ProxyProviderPackageCreators;
import dev.vality.adapter.common.damsel.ProxyProviderPackageExtractors;
-import dev.vality.adapter.flow.lib.constant.MetaData;
-import dev.vality.adapter.flow.lib.constant.Step;
-import dev.vality.adapter.flow.lib.constant.TargetStatus;
+import dev.vality.adapter.flow.lib.constant.*;
import dev.vality.adapter.flow.lib.model.*;
import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer;
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.utils.CardDataUtils;
import dev.vality.adapter.flow.lib.utils.TargetStatusResolver;
@@ -24,6 +23,7 @@ import dev.vality.damsel.domain.TransactionInfo;
import dev.vality.damsel.proxy_provider.*;
import lombok.RequiredArgsConstructor;
import org.springframework.core.convert.converter.Converter;
+import org.springframework.util.StringUtils;
import java.util.HashMap;
import java.util.Map;
@@ -38,6 +38,7 @@ public class CtxToEntryModelConverter implements Converter())
.successRedirectUrl(getSuccessRedirectUrl(payment, adapterConfigurations))
+ .failedRedirectUrl(getFailureRedirectUrl(payment, adapterConfigurations))
.threeDsDataFromMpiCallback(temporaryContext.getThreeDsData())
.build())
.targetStatus(targetStatus)
@@ -106,6 +108,16 @@ public class CtxToEntryModelConverter implements Converter adapterConfigurations) {
+ String redirectUrl = payment.isSetPayerSessionInfo()
+ ? payment.getPayerSessionInfo().getRedirectUrl()
+ : null;
+ return StringUtils.hasText(redirectUrl)
+ ? redirectUrl
+ : adapterConfigurations.getOrDefault(
+ OptionFields.FAILED_URL.name(), adapterProperties.getFailedRedirectUrl());
+ }
+
private dev.vality.adapter.flow.lib.model.CardData initCardData(PaymentContext context,
PaymentResource paymentResource,
SessionData sessionData) {
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 f5e8998..e70949e 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
@@ -101,13 +101,15 @@ public class HandlerConfig {
IdGenerator idGenerator,
TemporaryContextService temporaryContextService,
CallbackUrlExtractor callbackUrlExtractor,
- CardDataServiceWithHolderNamesImpl cardDataService) {
+ CardDataServiceWithHolderNamesImpl cardDataService,
+ AdapterProperties adapterProperties) {
return new CtxToEntryModelConverter(cdsStorageClient,
adapterDeserializer,
idGenerator,
temporaryContextService,
callbackUrlExtractor,
- cardDataService);
+ cardDataService,
+ adapterProperties);
}
@Bean