mirror of
https://github.com/valitydev/adapter-flow-lib.git
synced 2024-11-06 00:05:22 +00:00
add trxInfo for error flow (#67)
* add trxInfo for error flow * add trxInfo for error flow
This commit is contained in:
parent
540e49b59e
commit
4c10c52e06
2
pom.xml
2
pom.xml
@ -12,7 +12,7 @@
|
||||
</parent>
|
||||
|
||||
<artifactId>adapter-flow-lib</artifactId>
|
||||
<version>0.1.23</version>
|
||||
<version>0.1.24</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>adapter-flow-lib</name>
|
||||
|
@ -28,23 +28,26 @@ public class ExitModelToProxyResultConverter implements Converter<ExitStateModel
|
||||
@Override
|
||||
public PaymentProxyResult convert(ExitStateModel exitStateModel) {
|
||||
if (StringUtils.hasText(exitStateModel.getErrorCode())) {
|
||||
return new PaymentProxyResult(intentResultFactory.createFinishIntentFailed(exitStateModel));
|
||||
return new PaymentProxyResult(intentResultFactory.createFinishIntentFailed(exitStateModel))
|
||||
.setTrx(StringUtils.hasText(exitStateModel.getProviderTrxId())
|
||||
? getTransactionInfo(exitStateModel)
|
||||
: null);
|
||||
}
|
||||
|
||||
Intent intent = resultIntentResolver.initIntentByStep(exitStateModel);
|
||||
|
||||
return new PaymentProxyResult(intent)
|
||||
.setNextState(serializer.writeByte(contextConverter.convert(exitStateModel)))
|
||||
.setTrx(
|
||||
new TransactionInfo()
|
||||
.setTrx(getTransactionInfo(exitStateModel));
|
||||
}
|
||||
|
||||
private TransactionInfo getTransactionInfo(ExitStateModel exitStateModel) {
|
||||
return new TransactionInfo()
|
||||
.setId(exitStateModel.getProviderTrxId())
|
||||
.setExtra(exitStateModel.getTrxExtra() != null
|
||||
? exitStateModel.getTrxExtra()
|
||||
: new HashMap<>())
|
||||
.setAdditionalInfo(AdditionalInfoUtils.initAdditionalTrxInfo(exitStateModel))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
.setAdditionalInfo(AdditionalInfoUtils.initAdditionalTrxInfo(exitStateModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import dev.vality.damsel.proxy_provider.RecurrentTokenIntent;
|
||||
import dev.vality.damsel.proxy_provider.RecurrentTokenProxyResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@ -28,23 +29,26 @@ public class ExitModelToRecTokenProxyResultConverter implements Converter<ExitSt
|
||||
return new RecurrentTokenProxyResult(
|
||||
recurrentIntentResultFactory.createFinishIntentFailed(
|
||||
exitStateModel.getErrorCode(),
|
||||
exitStateModel.getErrorMessage())
|
||||
);
|
||||
exitStateModel.getErrorMessage()))
|
||||
.setTrx(StringUtils.hasText(exitStateModel.getProviderTrxId())
|
||||
? getTransactionInfo(exitStateModel)
|
||||
: null);
|
||||
}
|
||||
|
||||
RecurrentTokenIntent intent = recurrentResultIntentResolver.initIntentByStep(exitStateModel);
|
||||
|
||||
return new RecurrentTokenProxyResult(intent)
|
||||
.setNextState(serializer.writeByte(contextConverter.convert(exitStateModel)))
|
||||
.setTrx(
|
||||
new TransactionInfo()
|
||||
.setTrx(getTransactionInfo(exitStateModel));
|
||||
}
|
||||
|
||||
private TransactionInfo getTransactionInfo(ExitStateModel exitStateModel) {
|
||||
return new TransactionInfo()
|
||||
.setId(exitStateModel.getProviderTrxId())
|
||||
.setExtra(exitStateModel.getTrxExtra() != null
|
||||
? exitStateModel.getTrxExtra()
|
||||
: new HashMap<>())
|
||||
.setAdditionalInfo(AdditionalInfoUtils.initAdditionalTrxInfo(exitStateModel))
|
||||
);
|
||||
}
|
||||
|
||||
.setAdditionalInfo(AdditionalInfoUtils.initAdditionalTrxInfo(exitStateModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import dev.vality.adapter.flow.lib.model.ExitStateModel;
|
||||
import dev.vality.adapter.flow.lib.utils.ErrorUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@ -20,6 +21,10 @@ public class ErrorProcessor implements Processor<ExitStateModel, BaseResponseMod
|
||||
exitStateModel.setErrorCode(String.valueOf(response.getErrorCode()));
|
||||
exitStateModel.setErrorMessage(response.getErrorMessage());
|
||||
exitStateModel.setAdditionalTrxInfo(response.getAdditionalTrxInfo());
|
||||
exitStateModel.setProviderTrxId(
|
||||
StringUtils.hasText(response.getProviderTrxId())
|
||||
? response.getProviderTrxId()
|
||||
: entryStateModel.getBaseRequestModel().getProviderTrxId());
|
||||
log.debug("Finish error process response: {} entryStateModel: {}", response, entryStateModel);
|
||||
return exitStateModel;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user