mirror of
https://github.com/valitydev/adapter-flow-lib.git
synced 2024-11-06 00:05:22 +00:00
Add changedCost field mapping (#76)
This commit is contained in:
parent
8beec311ad
commit
f5a59d2032
2
pom.xml
2
pom.xml
@ -12,7 +12,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>adapter-flow-lib</artifactId>
|
<artifactId>adapter-flow-lib</artifactId>
|
||||||
<version>0.2.3</version>
|
<version>0.2.4</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>adapter-flow-lib</name>
|
<name>adapter-flow-lib</name>
|
||||||
|
@ -22,7 +22,7 @@ public class SimpleRedirectWithPollingResultIntentResolver implements ResultInte
|
|||||||
? intentResultFactory.createSuspendIntentWithCallbackAfterTimeout(exitStateModel)
|
? intentResultFactory.createSuspendIntentWithCallbackAfterTimeout(exitStateModel)
|
||||||
: intentResultFactory.createSleepIntentWithExponentialPolling(exitStateModel);
|
: intentResultFactory.createSleepIntentWithExponentialPolling(exitStateModel);
|
||||||
case DO_NOTHING -> createIntentByTargetStatus(exitStateModel);
|
case DO_NOTHING -> createIntentByTargetStatus(exitStateModel);
|
||||||
case REFUND, CANCEL -> intentResultFactory.createFinishIntentSuccess();
|
case REFUND, CANCEL -> intentResultFactory.createFinishIntentSuccess(exitStateModel);
|
||||||
default -> throw new IllegalStateException("Wrong nextStep: " + nextStep);
|
default -> throw new IllegalStateException("Wrong nextStep: " + nextStep);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ public class SimpleRedirectWithPollingResultIntentResolver implements ResultInte
|
|||||||
private Intent createIntentByTargetStatus(ExitStateModel exitStateModel) {
|
private Intent createIntentByTargetStatus(ExitStateModel exitStateModel) {
|
||||||
if (exitStateModel.getEntryStateModel().getTargetStatus() == TargetStatus.CANCELLED
|
if (exitStateModel.getEntryStateModel().getTargetStatus() == TargetStatus.CANCELLED
|
||||||
|| exitStateModel.getEntryStateModel().getTargetStatus() == TargetStatus.REFUNDED) {
|
|| exitStateModel.getEntryStateModel().getTargetStatus() == TargetStatus.REFUNDED) {
|
||||||
return intentResultFactory.createFinishIntentSuccess();
|
return intentResultFactory.createFinishIntentSuccess(exitStateModel);
|
||||||
}
|
}
|
||||||
return intentResultFactory.createFinishIntentSuccessWithCheckToken(exitStateModel);
|
return intentResultFactory.createFinishIntentSuccessWithCheckToken(exitStateModel);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dev.vality.adapter.flow.lib.model;
|
package dev.vality.adapter.flow.lib.model;
|
||||||
|
|
||||||
import dev.vality.adapter.flow.lib.constant.Status;
|
import dev.vality.adapter.flow.lib.constant.Status;
|
||||||
|
import dev.vality.damsel.proxy_provider.Cash;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
@ -50,5 +51,10 @@ public class BaseResponseModel {
|
|||||||
* Custom data for more flexibility
|
* Custom data for more flexibility
|
||||||
*/
|
*/
|
||||||
private byte[] customContext;
|
private byte[] customContext;
|
||||||
|
/**
|
||||||
|
* Cash that was actually received by provider.
|
||||||
|
* Is used when payer transferred wrong amount of money.
|
||||||
|
*/
|
||||||
|
private Cash changedCost;
|
||||||
|
|
||||||
}
|
}
|
@ -2,6 +2,7 @@ package dev.vality.adapter.flow.lib.model;
|
|||||||
|
|
||||||
import dev.vality.adapter.flow.lib.constant.Status;
|
import dev.vality.adapter.flow.lib.constant.Status;
|
||||||
import dev.vality.adapter.flow.lib.constant.Step;
|
import dev.vality.adapter.flow.lib.constant.Step;
|
||||||
|
import dev.vality.damsel.proxy_provider.Cash;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@ -31,6 +32,6 @@ public class ExitStateModel {
|
|||||||
|
|
||||||
private String recToken;
|
private String recToken;
|
||||||
private byte[] customContext;
|
private byte[] customContext;
|
||||||
|
private Cash changedCost;
|
||||||
|
|
||||||
}
|
}
|
@ -32,6 +32,7 @@ public class SuccessFinishProcessor
|
|||||||
exitStateModel.setLastOperationStatus(response.getStatus());
|
exitStateModel.setLastOperationStatus(response.getStatus());
|
||||||
exitStateModel.setAdditionalTrxInfo(response.getAdditionalTrxInfo());
|
exitStateModel.setAdditionalTrxInfo(response.getAdditionalTrxInfo());
|
||||||
exitStateModel.setCustomContext(response.getCustomContext());
|
exitStateModel.setCustomContext(response.getCustomContext());
|
||||||
|
exitStateModel.setChangedCost(response.getChangedCost());
|
||||||
Map<String, String> saveData = response.getSaveData();
|
Map<String, String> saveData = response.getSaveData();
|
||||||
if (entryStateModel.getBaseRequestModel().getRecurrentPaymentData() != null
|
if (entryStateModel.getBaseRequestModel().getRecurrentPaymentData() != null
|
||||||
&& entryStateModel.getBaseRequestModel().getRecurrentPaymentData().isMakeRecurrent()) {
|
&& entryStateModel.getBaseRequestModel().getRecurrentPaymentData().isMakeRecurrent()) {
|
||||||
|
@ -11,7 +11,7 @@ public interface IntentResultFactory {
|
|||||||
|
|
||||||
Intent createSuspendIntentWithCallbackAfterTimeout(ExitStateModel exitStateModel);
|
Intent createSuspendIntentWithCallbackAfterTimeout(ExitStateModel exitStateModel);
|
||||||
|
|
||||||
Intent createFinishIntentSuccess();
|
Intent createFinishIntentSuccess(ExitStateModel exitStateModel);
|
||||||
|
|
||||||
Intent createSleepIntentWithExponentialPolling(ExitStateModel exitStateModel);
|
Intent createSleepIntentWithExponentialPolling(ExitStateModel exitStateModel);
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import dev.vality.damsel.proxy_provider.*;
|
|||||||
import dev.vality.damsel.timeout_behaviour.TimeoutBehaviour;
|
import dev.vality.damsel.timeout_behaviour.TimeoutBehaviour;
|
||||||
import dev.vality.damsel.user_interaction.UserInteraction;
|
import dev.vality.damsel.user_interaction.UserInteraction;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -42,7 +43,7 @@ public class IntentResultForwardThreeDsParamsFactory implements IntentResultFact
|
|||||||
&& entryStateModel.getBaseRequestModel().getRecurrentPaymentData().isMakeRecurrent()) {
|
&& entryStateModel.getBaseRequestModel().getRecurrentPaymentData().isMakeRecurrent()) {
|
||||||
return createFinishIntentSuccessWithToken(exitStateModel.getRecToken());
|
return createFinishIntentSuccessWithToken(exitStateModel.getRecToken());
|
||||||
}
|
}
|
||||||
return createFinishIntentSuccess();
|
return createFinishIntentSuccess(exitStateModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -95,7 +96,11 @@ public class IntentResultForwardThreeDsParamsFactory implements IntentResultFact
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Intent createFinishIntentSuccess() {
|
public Intent createFinishIntentSuccess(ExitStateModel exitStateModel) {
|
||||||
|
var success = new Success();
|
||||||
|
if (!ObjectUtils.isEmpty(exitStateModel.getChangedCost())) {
|
||||||
|
success.setChangedCost(exitStateModel.getChangedCost());
|
||||||
|
}
|
||||||
return Intent.finish(new FinishIntent(FinishStatus.success(new Success())));
|
return Intent.finish(new FinishIntent(FinishStatus.success(new Success())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package dev.vality.adapter.flow.lib.service.factory;
|
package dev.vality.adapter.flow.lib.service.factory;
|
||||||
|
|
||||||
import dev.vality.adapter.common.mapper.ErrorMapping;
|
import dev.vality.adapter.common.mapper.ErrorMapping;
|
||||||
import dev.vality.adapter.flow.lib.constant.HttpMethod;
|
|
||||||
import dev.vality.adapter.flow.lib.model.*;
|
import dev.vality.adapter.flow.lib.model.*;
|
||||||
import dev.vality.adapter.flow.lib.serde.ParametersSerializer;
|
import dev.vality.adapter.flow.lib.serde.ParametersSerializer;
|
||||||
import dev.vality.adapter.flow.lib.service.ExponentialBackOffPollingService;
|
import dev.vality.adapter.flow.lib.service.ExponentialBackOffPollingService;
|
||||||
@ -16,6 +15,7 @@ import dev.vality.damsel.user_interaction.QrCode;
|
|||||||
import dev.vality.damsel.user_interaction.QrCodeDisplayRequest;
|
import dev.vality.damsel.user_interaction.QrCodeDisplayRequest;
|
||||||
import dev.vality.damsel.user_interaction.UserInteraction;
|
import dev.vality.damsel.user_interaction.UserInteraction;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -41,7 +41,7 @@ public class IntentResultQrPaymentFactory implements IntentResultFactory {
|
|||||||
&& entryStateModel.getBaseRequestModel().getRecurrentPaymentData().isMakeRecurrent()) {
|
&& entryStateModel.getBaseRequestModel().getRecurrentPaymentData().isMakeRecurrent()) {
|
||||||
return createFinishIntentSuccessWithToken(exitStateModel.getRecToken());
|
return createFinishIntentSuccessWithToken(exitStateModel.getRecToken());
|
||||||
}
|
}
|
||||||
return createFinishIntentSuccess();
|
return createFinishIntentSuccess(exitStateModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -96,7 +96,11 @@ public class IntentResultQrPaymentFactory implements IntentResultFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Intent createFinishIntentSuccess() {
|
public Intent createFinishIntentSuccess(ExitStateModel exitStateModel) {
|
||||||
|
var success = new Success();
|
||||||
|
if (!ObjectUtils.isEmpty(exitStateModel.getChangedCost())) {
|
||||||
|
success.setChangedCost(exitStateModel.getChangedCost());
|
||||||
|
}
|
||||||
return Intent.finish(new FinishIntent(FinishStatus.success(new Success())));
|
return Intent.finish(new FinishIntent(FinishStatus.success(new Success())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import dev.vality.damsel.proxy_provider.*;
|
|||||||
import dev.vality.damsel.timeout_behaviour.TimeoutBehaviour;
|
import dev.vality.damsel.timeout_behaviour.TimeoutBehaviour;
|
||||||
import dev.vality.damsel.user_interaction.UserInteraction;
|
import dev.vality.damsel.user_interaction.UserInteraction;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -45,7 +46,7 @@ public class SimpleIntentResultFactory implements IntentResultFactory {
|
|||||||
&& entryStateModel.getBaseRequestModel().getRecurrentPaymentData().isMakeRecurrent()) {
|
&& entryStateModel.getBaseRequestModel().getRecurrentPaymentData().isMakeRecurrent()) {
|
||||||
return createFinishIntentSuccessWithToken(exitStateModel.getRecToken());
|
return createFinishIntentSuccessWithToken(exitStateModel.getRecToken());
|
||||||
}
|
}
|
||||||
return createFinishIntentSuccess();
|
return createFinishIntentSuccess(exitStateModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -106,7 +107,11 @@ public class SimpleIntentResultFactory implements IntentResultFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Intent createFinishIntentSuccess() {
|
public Intent createFinishIntentSuccess(ExitStateModel exitStateModel) {
|
||||||
|
var success = new Success();
|
||||||
|
if (!ObjectUtils.isEmpty(exitStateModel.getChangedCost())) {
|
||||||
|
success.setChangedCost(exitStateModel.getChangedCost());
|
||||||
|
}
|
||||||
return Intent.finish(new FinishIntent(FinishStatus.success(new Success())));
|
return Intent.finish(new FinishIntent(FinishStatus.success(new Success())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user