From 6cd73e98f90a4462d84a0618ec4ea4e3aa6583a0 Mon Sep 17 00:00:00 2001 From: struga Date: Sat, 5 Mar 2022 14:29:04 +0300 Subject: [PATCH] Fix trx (#12) --- pom.xml | 2 +- .../exit/ExitModelToProxyResultConverter.java | 16 ++++++++++------ ...ExitModelToRecTokenProxyResultConverter.java | 17 ++++++++++------- .../flow/lib/model/AdditionalTrxInfo.java | 17 +++++++++++++++++ .../flow/lib/model/BaseResponseModel.java | 4 ++++ .../adapter/flow/lib/model/ExitStateModel.java | 1 + .../flow/lib/processor/ErrorProcessor.java | 1 + .../flow/lib/processor/RedirectProcessor.java | 1 + .../flow/lib/processor/RetryProcessor.java | 1 + .../lib/processor/SuccessFinishProcessor.java | 1 + .../flow/lib/service/PollingInfoService.java | 1 - .../flow/lib/service/ThreeDsAdapterService.java | 2 +- .../flow/lib/utils/AdditionalInfoUtils.java | 17 +++++++++++++++++ .../flow/lib/flow/AbstractPaymentTest.java | 2 +- .../three/ds/PaymentSuccess3ds2SimpleTest.java | 4 ---- .../simple/redirect/PaymentSuccess3dsTest.java | 7 ------- 16 files changed, 66 insertions(+), 28 deletions(-) create mode 100644 src/main/java/dev/vality/adapter/flow/lib/model/AdditionalTrxInfo.java create mode 100644 src/main/java/dev/vality/adapter/flow/lib/utils/AdditionalInfoUtils.java diff --git a/pom.xml b/pom.xml index 294f20b..863bad7 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ adapter-flow-lib - 0.0.8 + 0.0.9 jar adapter-flow-lib diff --git a/src/main/java/dev/vality/adapter/flow/lib/converter/exit/ExitModelToProxyResultConverter.java b/src/main/java/dev/vality/adapter/flow/lib/converter/exit/ExitModelToProxyResultConverter.java index dbe6fbe..f0cfa8d 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/converter/exit/ExitModelToProxyResultConverter.java +++ b/src/main/java/dev/vality/adapter/flow/lib/converter/exit/ExitModelToProxyResultConverter.java @@ -5,9 +5,10 @@ import dev.vality.adapter.flow.lib.flow.ResultIntentResolver; import dev.vality.adapter.flow.lib.model.ExitStateModel; import dev.vality.adapter.flow.lib.serde.TemporaryContextSerializer; import dev.vality.adapter.flow.lib.service.IntentResultFactory; +import dev.vality.adapter.flow.lib.utils.AdditionalInfoUtils; +import dev.vality.damsel.domain.TransactionInfo; import dev.vality.damsel.proxy_provider.Intent; import dev.vality.damsel.proxy_provider.PaymentProxyResult; -import dev.vality.java.damsel.utils.creators.DomainPackageCreators; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.core.convert.converter.Converter; @@ -34,11 +35,14 @@ public class ExitModelToProxyResultConverter implements Converter()) + .setTrx( + new TransactionInfo() + .setId(String.valueOf( + exitStateModel.getEntryStateModel().getBaseRequestModel().getPaymentId())) + .setExtra(exitStateModel.getTrxExtra() != null + ? exitStateModel.getTrxExtra() + : new HashMap<>()) + .setAdditionalInfo(AdditionalInfoUtils.initAdditionalTrxInfo(exitStateModel)) ); } diff --git a/src/main/java/dev/vality/adapter/flow/lib/converter/exit/ExitModelToRecTokenProxyResultConverter.java b/src/main/java/dev/vality/adapter/flow/lib/converter/exit/ExitModelToRecTokenProxyResultConverter.java index 3ddb19d..4c38d41 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/converter/exit/ExitModelToRecTokenProxyResultConverter.java +++ b/src/main/java/dev/vality/adapter/flow/lib/converter/exit/ExitModelToRecTokenProxyResultConverter.java @@ -5,6 +5,8 @@ import dev.vality.adapter.flow.lib.flow.RecurrentResultIntentResolver; import dev.vality.adapter.flow.lib.model.ExitStateModel; import dev.vality.adapter.flow.lib.serde.TemporaryContextSerializer; import dev.vality.adapter.flow.lib.service.RecurrentIntentResultFactory; +import dev.vality.adapter.flow.lib.utils.AdditionalInfoUtils; +import dev.vality.damsel.domain.TransactionInfo; import dev.vality.damsel.proxy_provider.RecurrentTokenIntent; import dev.vality.damsel.proxy_provider.RecurrentTokenProxyResult; import lombok.RequiredArgsConstructor; @@ -12,8 +14,6 @@ import org.springframework.core.convert.converter.Converter; import java.util.HashMap; -import static dev.vality.java.damsel.utils.creators.DomainPackageCreators.createTransactionInfo; - @RequiredArgsConstructor public class ExitModelToRecTokenProxyResultConverter implements Converter { @@ -36,11 +36,14 @@ public class ExitModelToRecTokenProxyResultConverter implements Converter()) + .setTrx( + new TransactionInfo() + .setId(String.valueOf( + exitStateModel.getEntryStateModel().getBaseRequestModel().getPaymentId())) + .setExtra(exitStateModel.getTrxExtra() != null + ? exitStateModel.getTrxExtra() + : new HashMap<>()) + .setAdditionalInfo(AdditionalInfoUtils.initAdditionalTrxInfo(exitStateModel)) ); } diff --git a/src/main/java/dev/vality/adapter/flow/lib/model/AdditionalTrxInfo.java b/src/main/java/dev/vality/adapter/flow/lib/model/AdditionalTrxInfo.java new file mode 100644 index 0000000..d7cc407 --- /dev/null +++ b/src/main/java/dev/vality/adapter/flow/lib/model/AdditionalTrxInfo.java @@ -0,0 +1,17 @@ +package dev.vality.adapter.flow.lib.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class AdditionalTrxInfo { + + private String rrn; + private String approvalCode; + +} diff --git a/src/main/java/dev/vality/adapter/flow/lib/model/BaseResponseModel.java b/src/main/java/dev/vality/adapter/flow/lib/model/BaseResponseModel.java index 14ff6c9..fa4b969 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/model/BaseResponseModel.java +++ b/src/main/java/dev/vality/adapter/flow/lib/model/BaseResponseModel.java @@ -38,5 +38,9 @@ public class BaseResponseModel { * Data for choose 3ds flow and parameters for redirects. */ private ThreeDsData threeDsData; + /** + * Data for support about transactions. + */ + private AdditionalTrxInfo additionalTrxInfo; } \ No newline at end of file diff --git a/src/main/java/dev/vality/adapter/flow/lib/model/ExitStateModel.java b/src/main/java/dev/vality/adapter/flow/lib/model/ExitStateModel.java index d0990d9..50cfdd6 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/model/ExitStateModel.java +++ b/src/main/java/dev/vality/adapter/flow/lib/model/ExitStateModel.java @@ -26,6 +26,7 @@ public class ExitStateModel { private Map trxExtra; private PollingInfo pollingInfo; private ThreeDsData threeDsData; + private AdditionalTrxInfo additionalTrxInfo; private String recToken; diff --git a/src/main/java/dev/vality/adapter/flow/lib/processor/ErrorProcessor.java b/src/main/java/dev/vality/adapter/flow/lib/processor/ErrorProcessor.java index 7788c9a..4fd7411 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/processor/ErrorProcessor.java +++ b/src/main/java/dev/vality/adapter/flow/lib/processor/ErrorProcessor.java @@ -19,6 +19,7 @@ public class ErrorProcessor implements Processor saveData = response.getSaveData(); if (entryStateModel.getBaseRequestModel().getRecurrentPaymentData() != null && entryStateModel.getBaseRequestModel().getRecurrentPaymentData().isMakeRecurrent()) { diff --git a/src/main/java/dev/vality/adapter/flow/lib/service/PollingInfoService.java b/src/main/java/dev/vality/adapter/flow/lib/service/PollingInfoService.java index 6696df1..4babe56 100644 --- a/src/main/java/dev/vality/adapter/flow/lib/service/PollingInfoService.java +++ b/src/main/java/dev/vality/adapter/flow/lib/service/PollingInfoService.java @@ -6,7 +6,6 @@ import dev.vality.adapter.flow.lib.utils.TimerProperties; import dev.vality.java.damsel.utils.extractors.OptionsExtractors; import lombok.NonNull; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; import java.time.Instant; import java.time.temporal.ChronoUnit; 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 61fa44c..764d2d6 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 @@ -1,7 +1,7 @@ package dev.vality.adapter.flow.lib.service; -import dev.vality.adapter.flow.lib.serde.ParametersSerializer; 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 dev.vality.adapter.helpers.hellgate.HellgateAdapterClient; import dev.vality.adapter.helpers.hellgate.exception.HellgateException; diff --git a/src/main/java/dev/vality/adapter/flow/lib/utils/AdditionalInfoUtils.java b/src/main/java/dev/vality/adapter/flow/lib/utils/AdditionalInfoUtils.java new file mode 100644 index 0000000..b1f89db --- /dev/null +++ b/src/main/java/dev/vality/adapter/flow/lib/utils/AdditionalInfoUtils.java @@ -0,0 +1,17 @@ +package dev.vality.adapter.flow.lib.utils; + +import dev.vality.adapter.flow.lib.model.ExitStateModel; +import dev.vality.damsel.domain.AdditionalTransactionInfo; + +public class AdditionalInfoUtils { + + public static AdditionalTransactionInfo initAdditionalTrxInfo(ExitStateModel exitStateModel) { + if (exitStateModel.getAdditionalTrxInfo() != null) { + return new AdditionalTransactionInfo() + .setRrn(exitStateModel.getAdditionalTrxInfo().getRrn()) + .setApprovalCode(exitStateModel.getAdditionalTrxInfo().getApprovalCode()); + } + return null; + } + +} 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 d5a7d32..0f96c0c 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 @@ -6,9 +6,9 @@ import dev.vality.adapter.flow.lib.controller.ThreeDsCallbackController; import dev.vality.adapter.flow.lib.flow.config.*; import dev.vality.adapter.flow.lib.flow.full.FullThreeDsAllVersionsStepResolverImpl; 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.serde.TemporaryContextDeserializer; import dev.vality.adapter.flow.lib.validator.AdapterConfigurationValidator; import dev.vality.adapter.helpers.hellgate.HellgateAdapterClient; import dev.vality.bender.BenderSrv; diff --git a/src/test/java/dev/vality/adapter/flow/lib/flow/full/three/ds/PaymentSuccess3ds2SimpleTest.java b/src/test/java/dev/vality/adapter/flow/lib/flow/full/three/ds/PaymentSuccess3ds2SimpleTest.java index f356d05..4f988ff 100644 --- a/src/test/java/dev/vality/adapter/flow/lib/flow/full/three/ds/PaymentSuccess3ds2SimpleTest.java +++ b/src/test/java/dev/vality/adapter/flow/lib/flow/full/three/ds/PaymentSuccess3ds2SimpleTest.java @@ -18,10 +18,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit.jupiter.SpringExtension; diff --git a/src/test/java/dev/vality/adapter/flow/lib/flow/simple/redirect/PaymentSuccess3dsTest.java b/src/test/java/dev/vality/adapter/flow/lib/flow/simple/redirect/PaymentSuccess3dsTest.java index e2df724..cec18bb 100644 --- a/src/test/java/dev/vality/adapter/flow/lib/flow/simple/redirect/PaymentSuccess3dsTest.java +++ b/src/test/java/dev/vality/adapter/flow/lib/flow/simple/redirect/PaymentSuccess3dsTest.java @@ -10,7 +10,6 @@ import dev.vality.adapter.flow.lib.flow.simple.redirect.config.SimpleRedirectWit import dev.vality.adapter.flow.lib.flow.utils.BeanUtils; import dev.vality.adapter.flow.lib.flow.utils.MockUtil; import dev.vality.adapter.flow.lib.model.BaseResponseModel; -import dev.vality.damsel.proxy_provider.PaymentCallbackResult; import dev.vality.damsel.proxy_provider.PaymentContext; import dev.vality.damsel.proxy_provider.PaymentProxyResult; import lombok.extern.slf4j.Slf4j; @@ -20,19 +19,13 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.io.IOException; -import java.nio.ByteBuffer; import java.util.Map; -import static dev.vality.adapter.flow.lib.flow.utils.BeanUtils.createParesBuffer; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any;