mirror of
https://github.com/valitydev/adapter-bank-spring-boot-starter.git
synced 2024-11-06 01:05:20 +00:00
Some refactoring
This commit is contained in:
parent
27b95152e4
commit
a8cf70300b
2
pom.xml
2
pom.xml
@ -103,7 +103,7 @@
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>adapter-common-lib</artifactId>
|
||||
<version>0.0.7-SNAPSHOT</version>
|
||||
<version>0.0.8</version>
|
||||
</dependency>
|
||||
|
||||
<!-- test -->
|
||||
|
@ -3,10 +3,10 @@ package com.rbkmoney.adapter.bank.spring.boot.starter.flow;
|
||||
import com.rbkmoney.adapter.bank.spring.boot.starter.model.*;
|
||||
import com.rbkmoney.adapter.common.enums.Step;
|
||||
|
||||
public class DefaultStepResolverImpl implements StepResolver<StateModel> {
|
||||
public class DefaultStepResolverImpl implements StepResolver<GeneralEntryStateModel, GeneralExitStateModel> {
|
||||
|
||||
@Override
|
||||
public Step resolveEntry(StateModel stateModel) {
|
||||
public Step resolveEntry(GeneralEntryStateModel stateModel) {
|
||||
switch (stateModel.getTargetStatus()) {
|
||||
case PROCESSED:
|
||||
return resolveProcessedSteps(stateModel);
|
||||
@ -21,7 +21,7 @@ public class DefaultStepResolverImpl implements StepResolver<StateModel> {
|
||||
}
|
||||
}
|
||||
|
||||
private Step resolveProcessedSteps(StateModel stateModel) {
|
||||
private Step resolveProcessedSteps(GeneralEntryStateModel stateModel) {
|
||||
if (isNextThreeDs(stateModel)) {
|
||||
return Step.FINISH_THREE_DS;
|
||||
} else if (stateModel.isMakeRecurrent()) {
|
||||
@ -32,19 +32,19 @@ public class DefaultStepResolverImpl implements StepResolver<StateModel> {
|
||||
return Step.AUTH;
|
||||
}
|
||||
|
||||
private static boolean isNextThreeDs(StateModel stateModel) {
|
||||
return stateModel.getAdapterContext() != null && stateModel.getAdapterContext().getNextStep() != null
|
||||
&& (Step.FINISH_THREE_DS.equals(stateModel.getAdapterContext().getNextStep())
|
||||
|| Step.GENERATE_TOKEN_FINISH_THREE_DS.equals(stateModel.getAdapterContext().getNextStep()));
|
||||
private static boolean isNextThreeDs(GeneralEntryStateModel stateModel) {
|
||||
return stateModel.getAdapterContext() != null && stateModel.getAdapterContext().getStep() != null
|
||||
&& (Step.FINISH_THREE_DS.equals(stateModel.getAdapterContext().getStep())
|
||||
|| Step.GENERATE_TOKEN_FINISH_THREE_DS.equals(stateModel.getAdapterContext().getStep()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step resolveExit(StateModel stateModel) {
|
||||
|
||||
Step step = stateModel.getStep();
|
||||
public Step resolveExit(GeneralExitStateModel stateModel) {
|
||||
Step step = stateModel.getGeneralEntryStateModel().getAdapterContext().getStep();
|
||||
Step nextStep = stateModel.getAdapterContext().getStep();
|
||||
switch (step) {
|
||||
case AUTH_RECURRENT:
|
||||
if (Step.FINISH_THREE_DS.equals(stateModel.getNextStep())) {
|
||||
if (Step.FINISH_THREE_DS.equals(nextStep)) {
|
||||
return Step.GENERATE_TOKEN_FINISH_THREE_DS;
|
||||
} else {
|
||||
return Step.GENERATE_TOKEN_CAPTURE;
|
||||
@ -56,7 +56,7 @@ public class DefaultStepResolverImpl implements StepResolver<StateModel> {
|
||||
case GENERATE_TOKEN_REFUND:
|
||||
return Step.GENERATE_TOKEN_FINISH;
|
||||
default:
|
||||
return stateModel.getNextStep();
|
||||
return nextStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
package com.rbkmoney.adapter.bank.spring.boot.starter.flow;
|
||||
|
||||
import com.rbkmoney.adapter.bank.spring.boot.starter.model.StateModel;
|
||||
import com.rbkmoney.adapter.bank.spring.boot.starter.model.GeneralEntryStateModel;
|
||||
import com.rbkmoney.adapter.bank.spring.boot.starter.model.GeneralExitStateModel;
|
||||
import com.rbkmoney.adapter.common.enums.Step;
|
||||
|
||||
public interface StepResolver<T extends StateModel> {
|
||||
public interface StepResolver<N extends GeneralEntryStateModel, X extends GeneralExitStateModel> {
|
||||
|
||||
Step resolveEntry(T stateModel);
|
||||
Step resolveEntry(N entryStateModel);
|
||||
|
||||
Step resolveExit(T stateModel);
|
||||
Step resolveExit(X exitStateModel);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.rbkmoney.adapter.bank.spring.boot.starter.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import com.rbkmoney.adapter.common.enums.TargetStatus;
|
||||
import com.rbkmoney.adapter.common.model.AdapterContext;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@ -11,8 +12,44 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public class GeneralEntryStateModel {
|
||||
|
||||
private OperationModel operationModel;
|
||||
private StateModel stateModel;
|
||||
private TransactionInfo transactionInfo;
|
||||
@ToString.Exclude
|
||||
private String pan;
|
||||
@ToString.Exclude
|
||||
private Byte expMonth;
|
||||
@ToString.Exclude
|
||||
private Short expYear;
|
||||
@ToString.Exclude
|
||||
private String cvv2;
|
||||
@ToString.Exclude
|
||||
private String cardHolder;
|
||||
|
||||
private String orderId;
|
||||
private Long amount;
|
||||
private Short currencyCode;
|
||||
private String currencySymbolCode;
|
||||
private String createdAt;
|
||||
|
||||
private String ip;
|
||||
private String email;
|
||||
private String phone;
|
||||
|
||||
private Long refundAmount;
|
||||
private String refundId;
|
||||
private String invoiceDetails;
|
||||
private String callbackUrl;
|
||||
|
||||
private Map<String, String> options;
|
||||
|
||||
private AdapterContext adapterContext;
|
||||
private TargetStatus targetStatus;
|
||||
|
||||
private String recToken;
|
||||
private boolean makeRecurrent;
|
||||
|
||||
private String cryptogram;
|
||||
private String eci;
|
||||
|
||||
private String trxId;
|
||||
private Map<String, String> trxExtra;
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.rbkmoney.adapter.bank.spring.boot.starter.model;
|
||||
|
||||
import com.rbkmoney.adapter.common.enums.Step;
|
||||
import com.rbkmoney.adapter.common.model.AdapterContext;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@ -15,7 +14,6 @@ import java.util.Map;
|
||||
@AllArgsConstructor
|
||||
public class GeneralExitStateModel {
|
||||
|
||||
private Step nextStep;
|
||||
private String errorCode;
|
||||
private String errorMessage;
|
||||
private AdapterContext adapterContext;
|
||||
|
@ -1,41 +0,0 @@
|
||||
package com.rbkmoney.adapter.bank.spring.boot.starter.model;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class OperationModel {
|
||||
|
||||
@ToString.Exclude
|
||||
private String pan;
|
||||
@ToString.Exclude
|
||||
private Byte expMonth;
|
||||
@ToString.Exclude
|
||||
private Short expYear;
|
||||
@ToString.Exclude
|
||||
private String cvv2;
|
||||
@ToString.Exclude
|
||||
private String cardHolder;
|
||||
|
||||
private String orderId;
|
||||
private Long amount;
|
||||
private Short currencyCode;
|
||||
private String currencySymbolCode;
|
||||
private String createdAt;
|
||||
|
||||
private String ip;
|
||||
private String email;
|
||||
private String phone;
|
||||
|
||||
private Long refundAmount;
|
||||
private String refundId;
|
||||
private String invoiceDetails;
|
||||
private String callbackUrl;
|
||||
|
||||
private Map<String, String> options;
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package com.rbkmoney.adapter.bank.spring.boot.starter.model;
|
||||
|
||||
import com.rbkmoney.adapter.common.enums.Step;
|
||||
import com.rbkmoney.adapter.common.enums.TargetStatus;
|
||||
import com.rbkmoney.adapter.common.model.AdapterContext;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StateModel {
|
||||
|
||||
private AdapterContext adapterContext;
|
||||
private TargetStatus targetStatus;
|
||||
|
||||
private String recToken;
|
||||
private boolean makeRecurrent;
|
||||
|
||||
private String cryptogram;
|
||||
private String eci;
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.rbkmoney.adapter.bank.spring.boot.starter.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TransactionInfo {
|
||||
|
||||
private String trxId;
|
||||
private Map<String, String> trxExtra;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user