This commit is contained in:
struga 2022-03-05 14:29:04 +03:00 committed by GitHub
parent 4b137530e1
commit 6cd73e98f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 66 additions and 28 deletions

View File

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

View File

@ -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<ExitStateModel
return new PaymentProxyResult(intent)
.setNextState(serializer.writeByte(contextConverter.convert(exitStateModel)))
.setTrx(DomainPackageCreators.createTransactionInfo(
exitStateModel.getProviderTrxId(),
exitStateModel.getTrxExtra() != null
? exitStateModel.getTrxExtra()
: new HashMap<>())
.setTrx(
new TransactionInfo()
.setId(String.valueOf(
exitStateModel.getEntryStateModel().getBaseRequestModel().getPaymentId()))
.setExtra(exitStateModel.getTrxExtra() != null
? exitStateModel.getTrxExtra()
: new HashMap<>())
.setAdditionalInfo(AdditionalInfoUtils.initAdditionalTrxInfo(exitStateModel))
);
}

View File

@ -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<ExitStateModel, RecurrentTokenProxyResult> {
@ -36,11 +36,14 @@ public class ExitModelToRecTokenProxyResultConverter implements Converter<ExitSt
return new RecurrentTokenProxyResult(intent)
.setNextState(serializer.writeByte(contextConverter.convert(exitStateModel)))
.setTrx(createTransactionInfo(
exitStateModel.getProviderTrxId(),
exitStateModel.getTrxExtra() != null
? exitStateModel.getTrxExtra()
: new HashMap<>())
.setTrx(
new TransactionInfo()
.setId(String.valueOf(
exitStateModel.getEntryStateModel().getBaseRequestModel().getPaymentId()))
.setExtra(exitStateModel.getTrxExtra() != null
? exitStateModel.getTrxExtra()
: new HashMap<>())
.setAdditionalInfo(AdditionalInfoUtils.initAdditionalTrxInfo(exitStateModel))
);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -26,6 +26,7 @@ public class ExitStateModel {
private Map<String, String> trxExtra;
private PollingInfo pollingInfo;
private ThreeDsData threeDsData;
private AdditionalTrxInfo additionalTrxInfo;
private String recToken;

View File

@ -19,6 +19,7 @@ public class ErrorProcessor implements Processor<ExitStateModel, BaseResponseMod
ExitStateModel exitStateModel = new ExitStateModel();
exitStateModel.setErrorCode(String.valueOf(response.getErrorCode()));
exitStateModel.setErrorMessage(response.getErrorMessage());
exitStateModel.setAdditionalTrxInfo(response.getAdditionalTrxInfo());
log.debug("Finish error process response: {} entryStateModel: {}", response, entryStateModel);
return exitStateModel;
}

View File

@ -25,6 +25,7 @@ public class RedirectProcessor implements Processor<ExitStateModel, BaseResponse
exitStateModel.setThreeDsData(response.getThreeDsData());
exitStateModel.setLastOperationStatus(response.getStatus());
exitStateModel.setProviderTrxId(response.getProviderTrxId());
exitStateModel.setAdditionalTrxInfo(response.getAdditionalTrxInfo());
log.debug("Finish redirect process response: {} entryStateModel: {}", response, entryStateModel);
return exitStateModel;
}

View File

@ -23,6 +23,7 @@ public class RetryProcessor implements Processor<ExitStateModel, BaseResponseMod
exitStateModel.setLastOperationStatus(response.getStatus());
exitStateModel.setProviderTrxId(entryStateModel.getBaseRequestModel().getProviderTrxId());
exitStateModel.setTrxExtra(response.getSaveData());
exitStateModel.setAdditionalTrxInfo(response.getAdditionalTrxInfo());
log.debug("Finish redirect process response: {} entryStateModel: {}", response, entryStateModel);
return exitStateModel;
}

View File

@ -30,6 +30,7 @@ public class SuccessFinishProcessor
? response.getProviderTrxId()
: entryStateModel.getBaseRequestModel().getProviderTrxId());
exitStateModel.setLastOperationStatus(response.getStatus());
exitStateModel.setAdditionalTrxInfo(response.getAdditionalTrxInfo());
Map<String, String> saveData = response.getSaveData();
if (entryStateModel.getBaseRequestModel().getRecurrentPaymentData() != null
&& entryStateModel.getBaseRequestModel().getRecurrentPaymentData().isMakeRecurrent()) {

View File

@ -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;

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;