mirror of
https://github.com/valitydev/adapter-flow-lib.git
synced 2024-11-06 00:05:22 +00:00
INT-193: Add FailedUrl filling (#43)
This commit is contained in:
parent
d72bb3eccd
commit
ddea6b66c7
2
pom.xml
2
pom.xml
@ -12,7 +12,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>adapter-flow-lib</artifactId>
|
<artifactId>adapter-flow-lib</artifactId>
|
||||||
<version>0.1.13</version>
|
<version>0.1.14</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>adapter-flow-lib</name>
|
<name>adapter-flow-lib</name>
|
||||||
|
@ -4,5 +4,6 @@ public enum OptionFields {
|
|||||||
|
|
||||||
STAGE,
|
STAGE,
|
||||||
CARD_HOLDER_FROM_FILE,
|
CARD_HOLDER_FROM_FILE,
|
||||||
|
FAILED_URL
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,13 @@ import dev.vality.adapter.common.cds.CdsStorageClient;
|
|||||||
import dev.vality.adapter.common.cds.model.CardDataProxyModel;
|
import dev.vality.adapter.common.cds.model.CardDataProxyModel;
|
||||||
import dev.vality.adapter.common.damsel.ProxyProviderPackageCreators;
|
import dev.vality.adapter.common.damsel.ProxyProviderPackageCreators;
|
||||||
import dev.vality.adapter.common.damsel.ProxyProviderPackageExtractors;
|
import dev.vality.adapter.common.damsel.ProxyProviderPackageExtractors;
|
||||||
import dev.vality.adapter.flow.lib.constant.MetaData;
|
import dev.vality.adapter.flow.lib.constant.*;
|
||||||
import dev.vality.adapter.flow.lib.constant.Step;
|
|
||||||
import dev.vality.adapter.flow.lib.constant.TargetStatus;
|
|
||||||
import dev.vality.adapter.flow.lib.model.*;
|
import dev.vality.adapter.flow.lib.model.*;
|
||||||
import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer;
|
import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer;
|
||||||
import dev.vality.adapter.flow.lib.service.CardDataService;
|
import dev.vality.adapter.flow.lib.service.CardDataService;
|
||||||
import dev.vality.adapter.flow.lib.service.IdGenerator;
|
import dev.vality.adapter.flow.lib.service.IdGenerator;
|
||||||
import dev.vality.adapter.flow.lib.service.TemporaryContextService;
|
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.CallbackUrlExtractor;
|
||||||
import dev.vality.adapter.flow.lib.utils.CardDataUtils;
|
import dev.vality.adapter.flow.lib.utils.CardDataUtils;
|
||||||
import dev.vality.adapter.flow.lib.utils.TargetStatusResolver;
|
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 dev.vality.damsel.proxy_provider.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -38,6 +38,7 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
|
|||||||
private final TemporaryContextService temporaryContextService;
|
private final TemporaryContextService temporaryContextService;
|
||||||
private final CallbackUrlExtractor callbackUrlExtractor;
|
private final CallbackUrlExtractor callbackUrlExtractor;
|
||||||
private final CardDataService cardDataService;
|
private final CardDataService cardDataService;
|
||||||
|
private final AdapterProperties adapterProperties;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntryStateModel convert(PaymentContext context) {
|
public EntryStateModel convert(PaymentContext context) {
|
||||||
@ -86,6 +87,7 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
|
|||||||
.providerTrxId(trx != null ? trx.getId() : temporaryContext.getProviderTrxId())
|
.providerTrxId(trx != null ? trx.getId() : temporaryContext.getProviderTrxId())
|
||||||
.savedData(trx != null ? trx.getExtra() : new HashMap<>())
|
.savedData(trx != null ? trx.getExtra() : new HashMap<>())
|
||||||
.successRedirectUrl(getSuccessRedirectUrl(payment, adapterConfigurations))
|
.successRedirectUrl(getSuccessRedirectUrl(payment, adapterConfigurations))
|
||||||
|
.failedRedirectUrl(getFailureRedirectUrl(payment, adapterConfigurations))
|
||||||
.threeDsDataFromMpiCallback(temporaryContext.getThreeDsData())
|
.threeDsDataFromMpiCallback(temporaryContext.getThreeDsData())
|
||||||
.build())
|
.build())
|
||||||
.targetStatus(targetStatus)
|
.targetStatus(targetStatus)
|
||||||
@ -106,6 +108,16 @@ public class CtxToEntryModelConverter implements Converter<PaymentContext, Entry
|
|||||||
: null);
|
: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getFailureRedirectUrl(InvoicePayment payment, Map<String, String> 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,
|
private dev.vality.adapter.flow.lib.model.CardData initCardData(PaymentContext context,
|
||||||
PaymentResource paymentResource,
|
PaymentResource paymentResource,
|
||||||
SessionData sessionData) {
|
SessionData sessionData) {
|
||||||
|
@ -101,13 +101,15 @@ public class HandlerConfig {
|
|||||||
IdGenerator idGenerator,
|
IdGenerator idGenerator,
|
||||||
TemporaryContextService temporaryContextService,
|
TemporaryContextService temporaryContextService,
|
||||||
CallbackUrlExtractor callbackUrlExtractor,
|
CallbackUrlExtractor callbackUrlExtractor,
|
||||||
CardDataServiceWithHolderNamesImpl cardDataService) {
|
CardDataServiceWithHolderNamesImpl cardDataService,
|
||||||
|
AdapterProperties adapterProperties) {
|
||||||
return new CtxToEntryModelConverter(cdsStorageClient,
|
return new CtxToEntryModelConverter(cdsStorageClient,
|
||||||
adapterDeserializer,
|
adapterDeserializer,
|
||||||
idGenerator,
|
idGenerator,
|
||||||
temporaryContextService,
|
temporaryContextService,
|
||||||
callbackUrlExtractor,
|
callbackUrlExtractor,
|
||||||
cardDataService);
|
cardDataService,
|
||||||
|
adapterProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
Loading…
Reference in New Issue
Block a user