mirror of
https://github.com/valitydev/adapter-common-lib.git
synced 2024-11-06 10:15:23 +00:00
Redesign integration with adapter-bank-spring-boot-starter (#4)
This commit is contained in:
parent
72128b3bc9
commit
c115f73db2
2
pom.xml
2
pom.xml
@ -8,7 +8,7 @@
|
||||
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>adapter-common-lib</artifactId>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
<version>0.0.4-SNAPSHOT</version>
|
||||
|
||||
<description></description>
|
||||
|
||||
|
@ -17,7 +17,7 @@ import java.util.function.BiFunction;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public abstract class AdapterController {
|
||||
public class AdapterController {
|
||||
|
||||
private final HellgateAdapterClient hgClient;
|
||||
|
||||
|
@ -3,7 +3,7 @@ package com.rbkmoney.adapter.common.handler.callback;
|
||||
import com.rbkmoney.adapter.common.enums.Step;
|
||||
import com.rbkmoney.adapter.common.model.AdapterContext;
|
||||
import com.rbkmoney.adapter.common.model.Callback;
|
||||
import com.rbkmoney.adapter.common.properties.TimerProperties;
|
||||
import com.rbkmoney.adapter.common.properties.CommonTimerProperties;
|
||||
import com.rbkmoney.adapter.common.serializer.AdapterSerializer;
|
||||
import com.rbkmoney.adapter.common.serializer.CallbackSerializer;
|
||||
import com.rbkmoney.damsel.proxy_provider.PaymentCallbackProxyResult;
|
||||
@ -26,7 +26,7 @@ public class PaymentCallbackHandler implements CallbackHandler<PaymentCallbackRe
|
||||
|
||||
private final CallbackSerializer callbackSerializer;
|
||||
|
||||
private final TimerProperties timerProperties;
|
||||
private final CommonTimerProperties timerProperties;
|
||||
|
||||
@Override
|
||||
public PaymentCallbackResult handleCallback(ByteBuffer callback, PaymentContext context) {
|
||||
|
@ -3,7 +3,7 @@ package com.rbkmoney.adapter.common.handler.callback;
|
||||
import com.rbkmoney.adapter.common.enums.Step;
|
||||
import com.rbkmoney.adapter.common.model.AdapterContext;
|
||||
import com.rbkmoney.adapter.common.model.Callback;
|
||||
import com.rbkmoney.adapter.common.properties.TimerProperties;
|
||||
import com.rbkmoney.adapter.common.properties.CommonTimerProperties;
|
||||
import com.rbkmoney.adapter.common.serializer.AdapterSerializer;
|
||||
import com.rbkmoney.adapter.common.serializer.CallbackSerializer;
|
||||
import com.rbkmoney.damsel.proxy_provider.RecurrentTokenCallbackResult;
|
||||
@ -28,7 +28,7 @@ public class RecurrentTokenCallbackHandler implements CallbackHandler<RecurrentT
|
||||
|
||||
private final CallbackSerializer callbackSerializer;
|
||||
|
||||
private final TimerProperties timerProperties;
|
||||
private final CommonTimerProperties timerProperties;
|
||||
|
||||
@Override
|
||||
public RecurrentTokenCallbackResult handleCallback(ByteBuffer callback, RecurrentTokenContext context) {
|
||||
|
@ -2,26 +2,24 @@ package com.rbkmoney.adapter.common.properties;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class AdapterProperties {
|
||||
@Validated
|
||||
public class CommonAdapterProperties {
|
||||
|
||||
@NotEmpty
|
||||
private String url;
|
||||
|
||||
@NotEmpty
|
||||
private String callbackUrl;
|
||||
|
||||
@NotEmpty
|
||||
private String pathCallbackUrl;
|
||||
|
||||
@NotEmpty
|
||||
private String pathRecurrentCallbackUrl;
|
||||
|
||||
@NotEmpty
|
||||
private String tagPrefix;
|
||||
|
||||
}
|
@ -2,12 +2,14 @@ package com.rbkmoney.adapter.common.properties;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class TimerProperties {
|
||||
@Validated
|
||||
public class CommonTimerProperties {
|
||||
|
||||
@NotNull
|
||||
private int redirectTimeout;
|
@ -12,7 +12,7 @@ import java.math.BigDecimal;
|
||||
import java.util.Random;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class PaymentDataConverterUtils {
|
||||
public final class PaymentDataConverter {
|
||||
|
||||
private static final String DEFAULT_ID = "1";
|
||||
|
||||
@ -47,30 +47,4 @@ public final class PaymentDataConverterUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static TargetStatus getTargetStatus(PaymentContext paymentContext) {
|
||||
if (paymentContext == null) {
|
||||
throw new IllegalArgumentException("PaymentContext cannot be empty");
|
||||
} else if (paymentContext.getSession() == null) {
|
||||
throw new IllegalArgumentException("Payment context session cannot be empty");
|
||||
} else {
|
||||
return getTargetStatus(paymentContext.getSession().getTarget());
|
||||
}
|
||||
}
|
||||
|
||||
public static TargetStatus getTargetStatus(TargetInvoicePaymentStatus targetInvoicePaymentStatus) {
|
||||
if (targetInvoicePaymentStatus != null) {
|
||||
if (targetInvoicePaymentStatus.isSetProcessed()) {
|
||||
return TargetStatus.PROCESSED;
|
||||
} else if (targetInvoicePaymentStatus.isSetCancelled()) {
|
||||
return TargetStatus.CANCELLED;
|
||||
} else if (targetInvoicePaymentStatus.isSetCaptured()) {
|
||||
return TargetStatus.CAPTURED;
|
||||
} else if (targetInvoicePaymentStatus.isSetRefunded()) {
|
||||
return TargetStatus.REFUNDED;
|
||||
}
|
||||
}
|
||||
|
||||
throw new UnknownTargetStatusException();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.rbkmoney.adapter.common.utils.converter;
|
||||
|
||||
import com.rbkmoney.adapter.common.enums.TargetStatus;
|
||||
import com.rbkmoney.adapter.common.exception.UnknownTargetStatusException;
|
||||
import com.rbkmoney.damsel.domain.TargetInvoicePaymentStatus;
|
||||
import com.rbkmoney.damsel.proxy_provider.PaymentContext;
|
||||
|
||||
public final class TargetStatusResolver {
|
||||
|
||||
public static TargetStatus getTargetStatus(PaymentContext paymentContext) {
|
||||
if (paymentContext == null) {
|
||||
throw new IllegalArgumentException("PaymentContext cannot be empty");
|
||||
} else if (paymentContext.getSession() == null) {
|
||||
throw new IllegalArgumentException("Payment context session cannot be empty");
|
||||
} else {
|
||||
return getTargetStatus(paymentContext.getSession().getTarget());
|
||||
}
|
||||
}
|
||||
|
||||
public static TargetStatus getTargetStatus(TargetInvoicePaymentStatus targetInvoicePaymentStatus) {
|
||||
if (targetInvoicePaymentStatus != null) {
|
||||
if (targetInvoicePaymentStatus.isSetProcessed()) {
|
||||
return TargetStatus.PROCESSED;
|
||||
} else if (targetInvoicePaymentStatus.isSetCancelled()) {
|
||||
return TargetStatus.CANCELLED;
|
||||
} else if (targetInvoicePaymentStatus.isSetCaptured()) {
|
||||
return TargetStatus.CAPTURED;
|
||||
} else if (targetInvoicePaymentStatus.isSetRefunded()) {
|
||||
return TargetStatus.REFUNDED;
|
||||
}
|
||||
}
|
||||
|
||||
throw new UnknownTargetStatusException();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user