Update channelOrigin as String
This commit is contained in:
parent
63f20d33b4
commit
d89606362c
4
pom.xml
4
pom.xml
@ -77,6 +77,10 @@
|
|||||||
<groupId>io.quarkus</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>quarkus-smallrye-health</artifactId>
|
<artifactId>quarkus-smallrye-health</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
|||||||
Binary file not shown.
@ -40,6 +40,14 @@ public class MessageHelper {
|
|||||||
this.errorMappings = initializeErrorMappings();
|
this.errorMappings = initializeErrorMappings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Response handleSuccess(Object data, String statusCode) {
|
||||||
|
log.info(
|
||||||
|
"Respuesta exitosa controlada: {}",
|
||||||
|
statusCode
|
||||||
|
);
|
||||||
|
return buildResponse(data, statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
public Response handleException(HttpStatusCodeException exception) {
|
public Response handleException(HttpStatusCodeException exception) {
|
||||||
log.error(
|
log.error(
|
||||||
"Error interno controlado: {} -> {}",
|
"Error interno controlado: {} -> {}",
|
||||||
@ -110,6 +118,25 @@ public class MessageHelper {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Response buildResponse(Object data, String statusCode) {
|
||||||
|
ErrorMapping mapping = errorMappings.getOrDefault(
|
||||||
|
statusCode, errorMappings.getOrDefault(
|
||||||
|
statusCode, createDefaultMapping()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
StatusResponse status = createError(mapping, null);
|
||||||
|
|
||||||
|
log.error(
|
||||||
|
"[Success] Message {} -> {}",
|
||||||
|
statusCode,
|
||||||
|
status.getMessage()
|
||||||
|
);
|
||||||
|
|
||||||
|
return Response.status(mapping.getHttpCode())
|
||||||
|
.entity(new ApiResponse<>(data, status))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
private Map<String, ErrorMapping> initializeErrorMappings() {
|
private Map<String, ErrorMapping> initializeErrorMappings() {
|
||||||
try {
|
try {
|
||||||
String json;
|
String json;
|
||||||
|
|||||||
@ -1,12 +1,17 @@
|
|||||||
package com.banesco.common.application.helper;
|
package com.banesco.common.application.helper;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import io.netty.util.internal.StringUtil;
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
|
||||||
import java.util.Base64;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
@ -33,6 +38,14 @@ public class SerializationHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String encodeStringToBase64(String text) {
|
||||||
|
if (StringUtil.isNullOrEmpty(text)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Base64.getEncoder().encodeToString(text.getBytes(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
public <T> T decodeBase64(String base64String, Class<T> clazz) {
|
public <T> T decodeBase64(String base64String, Class<T> clazz) {
|
||||||
try {
|
try {
|
||||||
byte[] decodedBytes = Base64.getDecoder().decode(base64String);
|
byte[] decodedBytes = Base64.getDecoder().decode(base64String);
|
||||||
@ -44,4 +57,116 @@ public class SerializationHelper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String encodeSha256(String json) {
|
||||||
|
return DigestUtils.sha256Hex(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> String toJsonString(T element) {
|
||||||
|
if (element == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return objectMapper.writeValueAsString(element);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
log.error("Error al convertir objeto a Json String: {}", e.getMessage());
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> Map<String, Object> toMap(T element) {
|
||||||
|
return toMap(element, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> Map<String, Object> toMap(
|
||||||
|
T element,
|
||||||
|
List<String> excludedFields
|
||||||
|
) {
|
||||||
|
if (element == null) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Map<String, Object> map = objectMapper.convertValue(
|
||||||
|
element, new TypeReference<>() {}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (excludedFields != null && !excludedFields.isEmpty()) {
|
||||||
|
Set<String> excludedSet = new HashSet<>(excludedFields);
|
||||||
|
excludedSet.forEach(map::remove);
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error al convertir objeto a Map: {}", e.getMessage());
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> Map<String, Object> toTreeMap(T element) {
|
||||||
|
return toTreeMap(element, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> Map<String, Object> toTreeMap(
|
||||||
|
T element,
|
||||||
|
List<String> excludedFields
|
||||||
|
) {
|
||||||
|
if (element == null) {
|
||||||
|
return new TreeMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Map<String, Object> tempMap = objectMapper.convertValue(
|
||||||
|
element, new TypeReference<>() {}
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, Object> treeMap = new TreeMap<>(tempMap);
|
||||||
|
|
||||||
|
if (excludedFields != null && !excludedFields.isEmpty()) {
|
||||||
|
Set<String> excludedSet = new HashSet<>(excludedFields);
|
||||||
|
excludedSet.forEach(treeMap::remove);
|
||||||
|
}
|
||||||
|
|
||||||
|
return treeMap;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error al convertir objeto a TreeMap: {}", e.getMessage());
|
||||||
|
return new TreeMap<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generateSignature(
|
||||||
|
Object operation,
|
||||||
|
String channelOrigin
|
||||||
|
) {
|
||||||
|
Map<String, Object> operationSortedMap = toTreeMap(operation);
|
||||||
|
StringBuilder concatenatedValues = new StringBuilder();
|
||||||
|
String channelBase64 = encodeStringToBase64(channelOrigin);
|
||||||
|
|
||||||
|
for (Object value : operationSortedMap.values()) {
|
||||||
|
if(!Objects.isNull(value)) {
|
||||||
|
concatenatedValues.append(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String finalString = concatenatedValues + channelBase64;
|
||||||
|
|
||||||
|
log.info("1. Operation concatenando valores: {}", concatenatedValues);
|
||||||
|
log.info("2. Channel Origin codificado: {}", channelBase64);
|
||||||
|
|
||||||
|
return encodeSha256(finalString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generateSignature(
|
||||||
|
Long id,
|
||||||
|
String channelOrigin
|
||||||
|
) {
|
||||||
|
String channelBase64 = encodeStringToBase64(channelOrigin);
|
||||||
|
String finalString = id + channelBase64;
|
||||||
|
|
||||||
|
log.info("1. Operation concatenando valores: {}", finalString);
|
||||||
|
log.info("2. Channel Origin codificado: {}", channelBase64);
|
||||||
|
|
||||||
|
return encodeSha256(finalString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -34,56 +36,61 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T execute(HttpRequest request) {
|
public <T> T execute(HttpRequest request) {
|
||||||
return executeInternal(request);
|
return executeRequest(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T, R> Either<T, R> executeEither(HttpRequest request) {
|
||||||
|
return executeEitherInternal(request, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T, R> Either<List<T>, R> executeEitherList(HttpRequest request) {
|
||||||
|
return executeEitherInternal(request, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> ApiResponse<T> executeApiResponse(HttpRequest request) {
|
public <T> ApiResponse<T> executeApiResponse(HttpRequest request) {
|
||||||
return executeInternal(request);
|
return executeRequest(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> ApiResponse<List<T>> executeApiResponseList(
|
public <T> ApiResponse<List<T>> executeApiResponseList(HttpRequest request) {
|
||||||
HttpRequest request
|
return executeRequest(request);
|
||||||
) {
|
|
||||||
return executeInternal(request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> ApiPrivateResponse<Either<T, ApiPrivateError>> executeApiPrivateResponse(
|
public <T> ApiPrivateResponse<Either<T, ApiPrivateError>> executeApiPrivateResponse(HttpRequest request) {
|
||||||
HttpRequest request
|
return executeRequest(request);
|
||||||
) {
|
|
||||||
return executeInternal(request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> ApiPrivateResponse<Either<List<T>, ApiPrivateError>> executeApiPrivateResponseList(
|
public <T> ApiPrivateResponse<Either<List<T>, ApiPrivateError>> executeApiPrivateResponseList(HttpRequest request) {
|
||||||
HttpRequest request
|
return executeRequest(request);
|
||||||
) {
|
|
||||||
return executeInternal(request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T executeInternal(HttpRequest request) {
|
private <T, R> Either<T, R> executeEitherInternal(HttpRequest request, boolean isList) {
|
||||||
String finalUrl = buildFinalUrl(request);
|
|
||||||
|
|
||||||
if (request.isLogRequestBody()) {
|
|
||||||
log.info("URL final: {}", finalUrl);
|
|
||||||
|
|
||||||
if (request.getHeaders() != null && !request.getHeaders().isEmpty()) {
|
|
||||||
log.info("Headers: {}", request.getHeaders());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.getQueryParams() != null && !request.getQueryParams().isEmpty()) {
|
|
||||||
log.info("Query params: {}", request.getQueryParams());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.getBody() != null) {
|
|
||||||
log.info("Body: {}", request.getBody());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Client client = createClient(request.getConnectTimeout(), request.getReadTimeout())) {
|
try (Client client = createClient(request.getConnectTimeout(), request.getReadTimeout())) {
|
||||||
WebTarget target = client.target(finalUrl);
|
WebTarget target = client.target(buildFinalUrl(request));
|
||||||
|
Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
if (request.getHeaders() != null) {
|
||||||
|
request.getHeaders().forEach(builder::header);
|
||||||
|
}
|
||||||
|
|
||||||
|
Response response = buildRequest(builder, request);
|
||||||
|
return handleEitherResponse(request, response, isList);
|
||||||
|
|
||||||
|
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw handleConnectionError(request, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T> T executeRequest(HttpRequest request) {
|
||||||
|
try (Client client = createClient(request.getConnectTimeout(), request.getReadTimeout())) {
|
||||||
|
WebTarget target = client.target(buildFinalUrl(request));
|
||||||
Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON);
|
Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
if (request.getHeaders() != null) {
|
if (request.getHeaders() != null) {
|
||||||
@ -95,14 +102,122 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error de conexion {}: {}", request.getMethod(), e.getMessage());
|
throw handleConnectionError(request, e);
|
||||||
throw HttpStatusCodeException.serviceUnavailable(
|
|
||||||
"503",
|
|
||||||
"Error de conexion con el servicio externo: " + e.getMessage()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private <T, R> Either<T, R> handleEitherResponse(HttpRequest request, Response response, boolean isList) {
|
||||||
|
int statusCode = response.getStatus();
|
||||||
|
|
||||||
|
try (response) {
|
||||||
|
String responseBody = response.readEntity(String.class);
|
||||||
|
logResponse(request, statusCode, responseBody);
|
||||||
|
|
||||||
|
if (statusCode >= 200 && statusCode < 300) {
|
||||||
|
Object successData = isList
|
||||||
|
? parseSuccessListResponse(request, responseBody)
|
||||||
|
: parseSuccessResponse(request, responseBody);
|
||||||
|
return Either.left((T) successData);
|
||||||
|
} else {
|
||||||
|
logErrorResponse(request, statusCode, responseBody);
|
||||||
|
R errorData = tryParseErrorResponse(request, responseBody);
|
||||||
|
|
||||||
|
if (errorData != null) {
|
||||||
|
return Either.right(errorData);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw mapHttpStatusToException(statusCode, responseBody);
|
||||||
|
}
|
||||||
|
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw handleProcessingError(request, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private <T> T parseSuccessResponse(HttpRequest request, String responseBody) throws JsonProcessingException {
|
||||||
|
Type successType = extractSuccessType(request);
|
||||||
|
|
||||||
|
if (successType != null) {
|
||||||
|
if (successType instanceof Class) {
|
||||||
|
return objectMapper.readValue(responseBody, (Class<T>) successType);
|
||||||
|
} else if (successType instanceof ParameterizedType) {
|
||||||
|
JavaType javaType = objectMapper.getTypeFactory().constructType(successType);
|
||||||
|
return objectMapper.readValue(responseBody, javaType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getResponseType() != null && request.getResponseType() != Object.class) {
|
||||||
|
return objectMapper.readValue(responseBody, objectMapper.getTypeFactory().constructType(request.getResponseType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (T) objectMapper.readValue(responseBody, Object.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private <T> List<T> parseSuccessListResponse(HttpRequest request, String responseBody) throws JsonProcessingException {
|
||||||
|
Type successType = extractSuccessType(request);
|
||||||
|
|
||||||
|
if (
|
||||||
|
successType instanceof ParameterizedType paramType &&
|
||||||
|
paramType.getRawType() == List.class &&
|
||||||
|
paramType.getActualTypeArguments().length > 0
|
||||||
|
) {
|
||||||
|
Type elementType = paramType.getActualTypeArguments()[0];
|
||||||
|
if (elementType instanceof Class) {
|
||||||
|
JavaType javaType = objectMapper.getTypeFactory().constructCollectionType(
|
||||||
|
List.class, (Class<T>) elementType
|
||||||
|
);
|
||||||
|
return objectMapper.readValue(responseBody, javaType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return objectMapper.readValue(responseBody, List.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Type extractSuccessType(HttpRequest request) {
|
||||||
|
if (
|
||||||
|
request.getComplexType() != null &&
|
||||||
|
request.getComplexType() instanceof ParameterizedType paramType &&
|
||||||
|
paramType.getRawType() == Either.class &&
|
||||||
|
paramType.getActualTypeArguments().length > 0
|
||||||
|
) {
|
||||||
|
return paramType.getActualTypeArguments()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getGenericType() != null) {
|
||||||
|
return request.getGenericType();
|
||||||
|
}
|
||||||
|
|
||||||
|
return request.getResponseType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private <R> R tryParseErrorResponse(HttpRequest request, String responseBody) {
|
||||||
|
if (responseBody == null || responseBody.trim().isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (request.getErrorType() != null) {
|
||||||
|
return (R) objectMapper.readValue(responseBody, request.getErrorType());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getComplexType() != null && request.getComplexType() instanceof ParameterizedType paramType) {
|
||||||
|
Type[] typeArgs = paramType.getActualTypeArguments();
|
||||||
|
if (typeArgs.length >= 2 && typeArgs[1] instanceof Class) {
|
||||||
|
return objectMapper.readValue(responseBody, (Class<R>) typeArgs[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("No se pudo parsear la respuesta como error type: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private String buildFinalUrl(HttpRequest request) {
|
private String buildFinalUrl(HttpRequest request) {
|
||||||
String finalUrl = request.getUrl();
|
String finalUrl = request.getUrl();
|
||||||
|
|
||||||
@ -113,7 +228,11 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return appendQueryParams(finalUrl, request.getQueryParams());
|
String url = appendQueryParams(finalUrl, request.getQueryParams());
|
||||||
|
|
||||||
|
log.info("Url Final: {}", url);
|
||||||
|
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String appendQueryParams(String url, Map<String, String> queryParams) {
|
private String appendQueryParams(String url, Map<String, String> queryParams) {
|
||||||
@ -132,20 +251,24 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
urlBuilder.append("&");
|
urlBuilder.append("&");
|
||||||
}
|
}
|
||||||
|
|
||||||
urlBuilder.append(entry.getKey())
|
String encodedKey = URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8);
|
||||||
.append("=")
|
String encodedValue = entry.getValue() != null
|
||||||
.append(entry.getValue() != null ? entry.getValue() : "");
|
? URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8)
|
||||||
|
: "";
|
||||||
|
|
||||||
|
urlBuilder.append(encodedKey).append("=").append(encodedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return urlBuilder.toString();
|
return urlBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response buildRequest(
|
private Response buildRequest(Invocation.Builder builder, HttpRequest request) {
|
||||||
Invocation.Builder builder,
|
|
||||||
HttpRequest request
|
|
||||||
) {
|
|
||||||
log.info("Metodo HTTP: {}", request.getMethod().name());
|
log.info("Metodo HTTP: {}", request.getMethod().name());
|
||||||
|
|
||||||
|
if(request.getBody() != null) {
|
||||||
|
log.info("Peticion Cuerpo: {}", request.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
return switch (request.getMethod()) {
|
return switch (request.getMethod()) {
|
||||||
case GET -> builder.get();
|
case GET -> builder.get();
|
||||||
case POST -> builder.post(Entity.entity(request.getBody(), MediaType.APPLICATION_JSON));
|
case POST -> builder.post(Entity.entity(request.getBody(), MediaType.APPLICATION_JSON));
|
||||||
@ -160,43 +283,26 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
|
|
||||||
private Client createClient(int connectTimeout, int readTimeout) {
|
private Client createClient(int connectTimeout, int readTimeout) {
|
||||||
return ClientBuilder.newBuilder()
|
return ClientBuilder.newBuilder()
|
||||||
.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
|
.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
|
||||||
.readTimeout(readTimeout, TimeUnit.MILLISECONDS)
|
.readTimeout(readTimeout, TimeUnit.MILLISECONDS)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T handleResponse(
|
private <T> T handleResponse(HttpRequest request, Response response) {
|
||||||
HttpRequest request,
|
|
||||||
Response response
|
|
||||||
) {
|
|
||||||
int statusCode = response.getStatus();
|
int statusCode = response.getStatus();
|
||||||
log.info("Respuesta {} - Status: {}", request.getMethod(), statusCode);
|
|
||||||
|
|
||||||
try (response) {
|
try (response) {
|
||||||
String responseBody = response.readEntity(String.class);
|
String responseBody = response.readEntity(String.class);
|
||||||
|
logResponse(request, statusCode, responseBody);
|
||||||
if (request.isLogResponseBody()) {
|
|
||||||
log.info("Respuesta Cuerpo: {}", responseBody);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (statusCode >= 200 && statusCode < 300) {
|
if (statusCode >= 200 && statusCode < 300) {
|
||||||
if (request.getResponseType() == Void.class || request.getResponseType() == void.class) {
|
if (request.getResponseType() == Void.class || request.getResponseType() == void.class) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
T result = responseResult(request, responseBody);
|
return responseResult(request, responseBody);
|
||||||
|
|
||||||
log.debug("Respuesta exitosa {} {}: {}", request.getMethod(), request.getUrl(), result);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
} else {
|
} else {
|
||||||
log.error(
|
logErrorResponse(request, statusCode, responseBody);
|
||||||
"Error HTTP {} {} - Status: {} - Body: {}",
|
|
||||||
request.getMethod(),
|
|
||||||
request.getUrl(),
|
|
||||||
statusCode,
|
|
||||||
responseBody
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isApiResponseFormat(responseBody)) {
|
if (isApiResponseFormat(responseBody)) {
|
||||||
ApiResponse<?> apiResponse = deserializeApiResponse(responseBody, request);
|
ApiResponse<?> apiResponse = deserializeApiResponse(responseBody, request);
|
||||||
@ -208,53 +314,72 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(
|
throw handleProcessingError(request, e);
|
||||||
"Error procesando respuesta {} {}: {}",
|
|
||||||
request.getMethod(),
|
|
||||||
request.getUrl(),
|
|
||||||
e.getMessage()
|
|
||||||
);
|
|
||||||
throw HttpStatusCodeException.internalServer(
|
|
||||||
"500", "Error procesando respuesta del servicio externo: " + e.getMessage()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T responseResult(
|
private void logResponse(HttpRequest request, int statusCode, String responseBody) {
|
||||||
HttpRequest request,
|
if (request.isLogResponseBody()) {
|
||||||
String responseBody
|
log.info("Respuesta {} - Status: {}", request.getMethod(), statusCode);
|
||||||
) throws JsonProcessingException {
|
log.info("Respuesta Cuerpo: {}", responseBody);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logErrorResponse(HttpRequest request, int statusCode, String responseBody) {
|
||||||
|
log.error(
|
||||||
|
"Error HTTP {} {} - Status: {} - Body: {}",
|
||||||
|
request.getMethod(),
|
||||||
|
request.getUrl(),
|
||||||
|
statusCode,
|
||||||
|
responseBody
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private HttpStatusCodeException handleConnectionError(HttpRequest request, Exception e) {
|
||||||
|
log.error("Error de conexion {}: {}", request.getMethod(), e.getMessage());
|
||||||
|
|
||||||
|
return HttpStatusCodeException.serviceUnavailable(
|
||||||
|
"503", "Error de conexion con el servicio externo: " + e.getMessage()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private HttpStatusCodeException handleProcessingError(HttpRequest request, Exception e) {
|
||||||
|
log.error(
|
||||||
|
"Error procesando respuesta {} {}: {}",
|
||||||
|
request.getMethod(),
|
||||||
|
request.getUrl(),
|
||||||
|
e.getMessage()
|
||||||
|
);
|
||||||
|
return HttpStatusCodeException.internalServer(
|
||||||
|
"500", "Error procesando respuesta del servicio externo: " + e.getMessage()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T> T responseResult(HttpRequest request, String responseBody) throws JsonProcessingException {
|
||||||
if (request.isApiPrivateResponse() && request.isEitherResponse()) {
|
if (request.isApiPrivateResponse() && request.isEitherResponse()) {
|
||||||
return handleApiPrivateResponseWithEither(request, responseBody);
|
return handleApiPrivateResponseWithEither(request, responseBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
T result;
|
|
||||||
|
|
||||||
if (request.getResponseType() == ApiResponse.class) {
|
if (request.getResponseType() == ApiResponse.class) {
|
||||||
result = deserializeApiResponse(responseBody, request);
|
return deserializeApiResponse(responseBody, request);
|
||||||
} else if (request.getComplexType() != null) {
|
} else if (request.getComplexType() != null) {
|
||||||
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
||||||
request.getResponseType(), objectMapper.getTypeFactory().constructType(request.getComplexType())
|
request.getResponseType(), objectMapper.getTypeFactory().constructType(request.getComplexType())
|
||||||
);
|
);
|
||||||
result = objectMapper.readValue(responseBody, javaType);
|
return objectMapper.readValue(responseBody, javaType);
|
||||||
} else if (request.getGenericType() != null) {
|
} else if (request.getGenericType() != null) {
|
||||||
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
||||||
request.getResponseType(), objectMapper.getTypeFactory().constructType(request.getGenericType())
|
request.getResponseType(), objectMapper.getTypeFactory().constructType(request.getGenericType())
|
||||||
);
|
);
|
||||||
result = objectMapper.readValue(responseBody, javaType);
|
return objectMapper.readValue(responseBody, javaType);
|
||||||
} else {
|
} else {
|
||||||
result = objectMapper.readValue(
|
return objectMapper.readValue(
|
||||||
responseBody, objectMapper.getTypeFactory().constructType(request.getResponseType())
|
responseBody, objectMapper.getTypeFactory().constructType(request.getResponseType())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T handleApiPrivateResponseWithEither(
|
private <T> T handleApiPrivateResponseWithEither(HttpRequest request, String responseBody) throws JsonProcessingException {
|
||||||
HttpRequest request,
|
|
||||||
String responseBody
|
|
||||||
) throws JsonProcessingException {
|
|
||||||
JsonNode rootNode = objectMapper.readTree(responseBody);
|
JsonNode rootNode = objectMapper.readTree(responseBody);
|
||||||
String status = rootNode.has("estatus") ? rootNode.get("estatus").asText() : null;
|
String status = rootNode.has("estatus") ? rootNode.get("estatus").asText() : null;
|
||||||
String message = rootNode.has("mensaje") ? rootNode.get("mensaje").asText() : null;
|
String message = rootNode.has("mensaje") ? rootNode.get("mensaje").asText() : null;
|
||||||
@ -268,12 +393,7 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T> T handleSuccessResponse(
|
private <T> T handleSuccessResponse(HttpRequest request, String status, String message, JsonNode detailNode) {
|
||||||
HttpRequest request,
|
|
||||||
String status,
|
|
||||||
String message,
|
|
||||||
JsonNode detailNode
|
|
||||||
) {
|
|
||||||
Object successData;
|
Object successData;
|
||||||
|
|
||||||
if (request.isListResponse()) {
|
if (request.isListResponse()) {
|
||||||
@ -295,10 +415,7 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object handleListSuccess(
|
private Object handleListSuccess(HttpRequest request, JsonNode detailNode) {
|
||||||
HttpRequest request,
|
|
||||||
JsonNode detailNode
|
|
||||||
) {
|
|
||||||
Class<?> elementType = getElementTypeFromRequest(request);
|
Class<?> elementType = getElementTypeFromRequest(request);
|
||||||
JavaType listType = objectMapper.getTypeFactory().constructCollectionType(List.class, elementType);
|
JavaType listType = objectMapper.getTypeFactory().constructCollectionType(List.class, elementType);
|
||||||
|
|
||||||
@ -309,10 +426,7 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object handleObjectSuccess(
|
private Object handleObjectSuccess(HttpRequest request, JsonNode detailNode) {
|
||||||
HttpRequest request,
|
|
||||||
JsonNode detailNode
|
|
||||||
) {
|
|
||||||
Class<?> elementType = getElementTypeFromRequest(request);
|
Class<?> elementType = getElementTypeFromRequest(request);
|
||||||
|
|
||||||
if (detailNode != null && !detailNode.isNull()) {
|
if (detailNode != null && !detailNode.isNull()) {
|
||||||
@ -323,11 +437,7 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T> T handleErrorResponse(
|
private <T> T handleErrorResponse(String status, String message, JsonNode detailNode) {
|
||||||
String status,
|
|
||||||
String message,
|
|
||||||
JsonNode detailNode
|
|
||||||
) {
|
|
||||||
ApiPrivateError error = buildApiPrivateError(detailNode, message);
|
ApiPrivateError error = buildApiPrivateError(detailNode, message);
|
||||||
ApiPrivateResponse<Either<Object, ApiPrivateError>> response = new ApiPrivateResponse<>();
|
ApiPrivateResponse<Either<Object, ApiPrivateError>> response = new ApiPrivateResponse<>();
|
||||||
|
|
||||||
@ -338,10 +448,7 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
return (T) response;
|
return (T) response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiPrivateError buildApiPrivateError(
|
private ApiPrivateError buildApiPrivateError(JsonNode detailNode, String message) {
|
||||||
JsonNode detailNode,
|
|
||||||
String message
|
|
||||||
) {
|
|
||||||
if (detailNode != null && !detailNode.isNull()) {
|
if (detailNode != null && !detailNode.isNull()) {
|
||||||
try {
|
try {
|
||||||
return objectMapper.convertValue(detailNode, ApiPrivateError.class);
|
return objectMapper.convertValue(detailNode, ApiPrivateError.class);
|
||||||
@ -385,15 +492,11 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T> T deserializeApiResponse(
|
private <T> T deserializeApiResponse(String responseBody, HttpRequest request) {
|
||||||
String responseBody,
|
|
||||||
HttpRequest request
|
|
||||||
) {
|
|
||||||
try {
|
try {
|
||||||
if (request.getGenericType() != null) {
|
if (request.getGenericType() != null) {
|
||||||
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
||||||
ApiResponse.class,
|
ApiResponse.class, objectMapper.getTypeFactory().constructType(request.getGenericType())
|
||||||
objectMapper.getTypeFactory().constructType(request.getGenericType())
|
|
||||||
);
|
);
|
||||||
return objectMapper.readValue(responseBody, javaType);
|
return objectMapper.readValue(responseBody, javaType);
|
||||||
} else {
|
} else {
|
||||||
@ -427,10 +530,7 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpStatusCodeException mapHttpStatusToException(
|
private HttpStatusCodeException mapHttpStatusToException(int statusCode, String errorBody) {
|
||||||
int statusCode,
|
|
||||||
String errorBody
|
|
||||||
) {
|
|
||||||
String errorCode = "HTTP_" + statusCode;
|
String errorCode = "HTTP_" + statusCode;
|
||||||
String defaultMessage = "Error en servicio externo: HTTP " + statusCode;
|
String defaultMessage = "Error en servicio externo: HTTP " + statusCode;
|
||||||
String message = errorBody != null && !errorBody.isEmpty()
|
String message = errorBody != null && !errorBody.isEmpty()
|
||||||
|
|||||||
@ -8,6 +8,10 @@ public interface HttpClientUseCase {
|
|||||||
|
|
||||||
<T> T execute(HttpRequest request);
|
<T> T execute(HttpRequest request);
|
||||||
|
|
||||||
|
<T, R> Either<T, R> executeEither(HttpRequest request);
|
||||||
|
|
||||||
|
<T, R> Either<List<T>, R> executeEitherList(HttpRequest request);
|
||||||
|
|
||||||
<T> ApiResponse<T> executeApiResponse(HttpRequest request);
|
<T> ApiResponse<T> executeApiResponse(HttpRequest request);
|
||||||
|
|
||||||
<T> ApiResponse<List<T>> executeApiResponseList(HttpRequest request);
|
<T> ApiResponse<List<T>> executeApiResponseList(HttpRequest request);
|
||||||
|
|||||||
@ -6,7 +6,9 @@ public class RequestContext {
|
|||||||
|
|
||||||
private RequestContext() {}
|
private RequestContext() {}
|
||||||
|
|
||||||
private static final String REQUEST_ID = "requestId";
|
public static final String REQUEST_ID = "requestId";
|
||||||
|
public static final String DEVICE = "device";
|
||||||
|
public static final String DEVICE_SESSION_REFERENCE = "deviceSessionReference";
|
||||||
|
|
||||||
public static String getRequestId() {
|
public static String getRequestId() {
|
||||||
return MDC.get(REQUEST_ID);
|
return MDC.get(REQUEST_ID);
|
||||||
|
|||||||
@ -6,15 +6,88 @@ import jakarta.ws.rs.container.ContainerRequestFilter;
|
|||||||
import jakarta.ws.rs.container.ContainerResponseContext;
|
import jakarta.ws.rs.container.ContainerResponseContext;
|
||||||
import jakarta.ws.rs.container.ContainerResponseFilter;
|
import jakarta.ws.rs.container.ContainerResponseFilter;
|
||||||
import jakarta.ws.rs.ext.Provider;
|
import jakarta.ws.rs.ext.Provider;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Provider
|
@Provider
|
||||||
public class RequestIdFilter implements ContainerRequestFilter, ContainerResponseFilter {
|
public class RequestIdFilter implements ContainerRequestFilter, ContainerResponseFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void filter(ContainerRequestContext requestContext) {
|
public void filter(ContainerRequestContext requestContext) {
|
||||||
RequestContext.setRequestId(UUID.randomUUID().toString().substring(0, 13));
|
String requestId = requestContext.getHeaderString(RequestContext.DEVICE_SESSION_REFERENCE);
|
||||||
|
|
||||||
|
if (isEmpty(requestId)) {
|
||||||
|
requestId = requestContext.getUriInfo()
|
||||||
|
.getQueryParameters()
|
||||||
|
.getFirst(RequestContext.DEVICE_SESSION_REFERENCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isEmpty(requestId) && hasJsonBody(requestContext)) {
|
||||||
|
requestId = extractRequestIdFromBody(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isEmpty(requestId)) {
|
||||||
|
requestId = UUID.randomUUID().toString().substring(0, 13);
|
||||||
|
}
|
||||||
|
|
||||||
|
RequestContext.setRequestId(requestId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isEmpty(String value) {
|
||||||
|
return value == null || value.trim().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasJsonBody(ContainerRequestContext context) {
|
||||||
|
try {
|
||||||
|
String method = context.getMethod();
|
||||||
|
String contentType = context.getHeaderString("Content-Type");
|
||||||
|
|
||||||
|
return ("POST".equals(method) || "PUT".equals(method))
|
||||||
|
&& contentType != null
|
||||||
|
&& contentType.contains("application/json");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("La peticion no es un POST o PUT: {}", e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String extractRequestIdFromBody(ContainerRequestContext context) {
|
||||||
|
try {
|
||||||
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
context.getEntityStream().transferTo(buffer);
|
||||||
|
byte[] bodyBytes = buffer.toByteArray();
|
||||||
|
|
||||||
|
context.setEntityStream(new ByteArrayInputStream(bodyBytes));
|
||||||
|
|
||||||
|
String bodyString = new String(bodyBytes, StandardCharsets.UTF_8);
|
||||||
|
io.vertx.core.json.JsonObject jsonObject = new io.vertx.core.json.JsonObject(bodyString);
|
||||||
|
|
||||||
|
if (jsonObject.containsKey(RequestContext.DEVICE)) {
|
||||||
|
io.vertx.core.json.JsonObject device = jsonObject.getJsonObject(RequestContext.DEVICE);
|
||||||
|
|
||||||
|
if (device.containsKey(RequestContext.DEVICE_SESSION_REFERENCE)) {
|
||||||
|
return device.getString(RequestContext.DEVICE_SESSION_REFERENCE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jsonObject.containsKey(RequestContext.REQUEST_ID)) {
|
||||||
|
return jsonObject.getString(RequestContext.REQUEST_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jsonObject.containsKey(RequestContext.DEVICE_SESSION_REFERENCE)) {
|
||||||
|
return jsonObject.getString(RequestContext.DEVICE_SESSION_REFERENCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error extrayendo el requestId del cuerpo de la peticion: {}", e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -22,6 +95,10 @@ public class RequestIdFilter implements ContainerRequestFilter, ContainerRespons
|
|||||||
ContainerRequestContext requestContext,
|
ContainerRequestContext requestContext,
|
||||||
ContainerResponseContext responseContext
|
ContainerResponseContext responseContext
|
||||||
) {
|
) {
|
||||||
RequestContext.clear();
|
try {
|
||||||
|
RequestContext.clear();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error limpiando el filtro: {}", e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,4 +7,5 @@ public enum BankingProductType {
|
|||||||
BROKERED_PRODUCT,
|
BROKERED_PRODUCT,
|
||||||
TERM_DEPOSIT_PRODUCT,
|
TERM_DEPOSIT_PRODUCT,
|
||||||
MOBILE_PAYMENT,
|
MOBILE_PAYMENT,
|
||||||
|
NETUNO
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,10 @@
|
|||||||
package com.banesco.module.instruction.domain.model;
|
package com.banesco.module.instruction.domain.model;
|
||||||
|
|
||||||
import com.banesco.common.domain.exception.HttpStatusCodeException;
|
|
||||||
import com.banesco.common.domain.model.Identifier;
|
import com.banesco.common.domain.model.Identifier;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@Builder
|
@Builder
|
||||||
@ -19,21 +15,12 @@ import java.util.Objects;
|
|||||||
public class Instruction {
|
public class Instruction {
|
||||||
private InstructionIdentification instructionIdentifier; // Request JSON: "id"
|
private InstructionIdentification instructionIdentifier; // Request JSON: "id"
|
||||||
private String instructionDescription; // Request JSON: "signature"
|
private String instructionDescription; // Request JSON: "signature"
|
||||||
private InstructionPurposeType instructionPurposeType; // Request JSON: "channelOrigin" (BOLE)
|
private String instructionPurposeType; // Request JSON: "channelOrigin" (BOLE)
|
||||||
|
|
||||||
public static Instruction fromResource(
|
public static Instruction fromResource(
|
||||||
String paymentStatusId,
|
String paymentStatusId,
|
||||||
String channelCode,
|
String channelCode
|
||||||
String signatureIdentifier
|
|
||||||
) {
|
) {
|
||||||
boolean isChannelCodeValid = (Arrays.stream(
|
|
||||||
InstructionPurposeType.values()
|
|
||||||
).anyMatch(type -> Objects.equals(type.name(), channelCode)));
|
|
||||||
|
|
||||||
if(!isChannelCodeValid) {
|
|
||||||
throw HttpStatusCodeException.badRequest("VDE02", "channelCode");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Instruction.builder()
|
return Instruction.builder()
|
||||||
.instructionIdentifier(
|
.instructionIdentifier(
|
||||||
InstructionIdentification.builder()
|
InstructionIdentification.builder()
|
||||||
@ -45,8 +32,7 @@ public class Instruction {
|
|||||||
.identificationType(InstructionIdentificationType.INSTRUCTION_NUMBER)
|
.identificationType(InstructionIdentificationType.INSTRUCTION_NUMBER)
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.instructionPurposeType(InstructionPurposeType.valueOf(channelCode))
|
.instructionPurposeType(channelCode)
|
||||||
.instructionDescription(signatureIdentifier)
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
package com.banesco.module.instruction.domain.model;
|
|
||||||
|
|
||||||
public enum InstructionPurposeType {
|
|
||||||
BOLE,
|
|
||||||
BOL,
|
|
||||||
}
|
|
||||||
@ -35,8 +35,4 @@ public class PaymentStatus {
|
|||||||
private String uuidPasskey;
|
private String uuidPasskey;
|
||||||
private String dateCreate;
|
private String dateCreate;
|
||||||
private String dateModify;
|
private String dateModify;
|
||||||
|
|
||||||
private Long codError;
|
|
||||||
private String mensajeError;
|
|
||||||
private String constraintName;
|
|
||||||
}
|
}
|
||||||
@ -38,7 +38,8 @@ public class PaymentStatusClient implements PaymentStatusUseCase {
|
|||||||
PaymentStatusRequest params,
|
PaymentStatusRequest params,
|
||||||
Class<T> responseType
|
Class<T> responseType
|
||||||
) {
|
) {
|
||||||
String signatureIdentifier = serializationHelper.encodeBase64(params);
|
String fintechId = params.getFintechId();
|
||||||
|
String signatureIdentifier = getSignatureIdentifier(params);
|
||||||
HttpRequest request = HttpRequest.forApiPrivateResponse(
|
HttpRequest request = HttpRequest.forApiPrivateResponse(
|
||||||
paymentStatusConfig.getUrl(),
|
paymentStatusConfig.getUrl(),
|
||||||
paymentStatusConfig.getStatusSuccess(),
|
paymentStatusConfig.getStatusSuccess(),
|
||||||
@ -46,14 +47,12 @@ public class PaymentStatusClient implements PaymentStatusUseCase {
|
|||||||
responseType
|
responseType
|
||||||
)
|
)
|
||||||
.withPathParams(Map.of("signatureIdentifier", signatureIdentifier))
|
.withPathParams(Map.of("signatureIdentifier", signatureIdentifier))
|
||||||
.withHeaders(Map.of("fintechId", params.getFintechId()))
|
.withHeaders(Map.of("fintechId", fintechId))
|
||||||
.withTimeout(
|
.withTimeout(
|
||||||
paymentStatusConfig.getTimeout().getConnect(),
|
paymentStatusConfig.getTimeout().getConnect(),
|
||||||
paymentStatusConfig.getTimeout().getResponse()
|
paymentStatusConfig.getTimeout().getResponse()
|
||||||
);
|
);
|
||||||
|
|
||||||
log.debug("Request configurado: {}", request);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ApiPrivateResponse<Either<T, ApiPrivateError>> response =
|
ApiPrivateResponse<Either<T, ApiPrivateError>> response =
|
||||||
httpClientUseCase.executeApiPrivateResponse(request);
|
httpClientUseCase.executeApiPrivateResponse(request);
|
||||||
@ -63,7 +62,7 @@ public class PaymentStatusClient implements PaymentStatusUseCase {
|
|||||||
log.error(
|
log.error(
|
||||||
"API retorno exitoso pero con detalle vacio. Codigo: {}, Mensaje: {}",
|
"API retorno exitoso pero con detalle vacio. Codigo: {}, Mensaje: {}",
|
||||||
response.getEstatus(),
|
response.getEstatus(),
|
||||||
response.getMensaje()
|
response.getMensaje()
|
||||||
);
|
);
|
||||||
|
|
||||||
throw ApiPrivateException.builder()
|
throw ApiPrivateException.builder()
|
||||||
@ -89,8 +88,8 @@ public class PaymentStatusClient implements PaymentStatusUseCase {
|
|||||||
throw ApiPrivateException.builder()
|
throw ApiPrivateException.builder()
|
||||||
.statusCode(response.getEstatus())
|
.statusCode(response.getEstatus())
|
||||||
.message((error.getCodError() != null)
|
.message((error.getCodError() != null)
|
||||||
? error.getCodError() + ":" + error.getMensajeError()
|
? error.getCodError() + ":" + error.getMensajeError()
|
||||||
: "EMPTY_MESSAGE"
|
: "EMPTY_MESSAGE"
|
||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
} catch (ApiPrivateException e) {
|
} catch (ApiPrivateException e) {
|
||||||
@ -108,4 +107,23 @@ public class PaymentStatusClient implements PaymentStatusUseCase {
|
|||||||
throw HttpStatusCodeException.serviceUnavailable("503");
|
throw HttpStatusCodeException.serviceUnavailable("503");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getSignatureIdentifier(PaymentStatusRequest params) {
|
||||||
|
Map<String, Object> paymentStatusRequest = serializationHelper.toMap(params);
|
||||||
|
String signature = serializationHelper.generateSignature(
|
||||||
|
params.getId(), params.getChannelOrigin()
|
||||||
|
);
|
||||||
|
|
||||||
|
paymentStatusRequest.put("signature", signature);
|
||||||
|
|
||||||
|
paymentStatusRequest.remove("fintechId");
|
||||||
|
|
||||||
|
String signatureIdentifier = serializationHelper.encodeBase64(paymentStatusRequest);
|
||||||
|
|
||||||
|
log.info("3. Firma generada: {}", signature);
|
||||||
|
log.info("4. Parametros de la solicitud: {}", paymentStatusRequest);
|
||||||
|
log.info("5. Solicitud final: {} -> {}", paymentStatusRequest, signatureIdentifier);
|
||||||
|
|
||||||
|
return signatureIdentifier;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -9,6 +9,7 @@ import com.banesco.module.service_issue_payment_status.domain.dto.request.Servic
|
|||||||
import com.banesco.module.service_issue_payment_status.domain.dto.response.ServiceIssuePaymentStatusResponse;
|
import com.banesco.module.service_issue_payment_status.domain.dto.response.ServiceIssuePaymentStatusResponse;
|
||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -28,27 +29,32 @@ public class ServiceIssuePaymentStatusService implements ServiceIssuePaymentStat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiResponse<ServiceIssuePaymentStatusResponse> execute(
|
public Response execute(
|
||||||
ServiceIssuePaymentStatusRequest request
|
ServiceIssuePaymentStatusRequest request
|
||||||
) {
|
) {
|
||||||
log.info("Iniciando ejecucion para el id: {}", request.getId());
|
log.info("Iniciando ejecucion para el id: {}", request.getId());
|
||||||
|
|
||||||
|
Response response;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return apiPrivate(request);
|
ApiResponse<ServiceIssuePaymentStatusResponse> apiResponse = apiPrivate(request);
|
||||||
} catch (ApiPrivateException e) {
|
|
||||||
log.warn(
|
response = messageHelper.handleSuccess(
|
||||||
"Excepcion de la api privada: {} -> {}",
|
apiResponse.getData(),
|
||||||
e.getStatusCode(),
|
apiResponse.getStatusResponse().getStatusCode()
|
||||||
e.getMessage()
|
|
||||||
);
|
);
|
||||||
throw HttpStatusCodeException.badRequest("400");
|
} catch (ApiPrivateException e) {
|
||||||
|
log.warn("Excepcion de la api privada: {} -> {}", e.getStatusCode(), e.getMessage());
|
||||||
|
response = messageHelper.handleException(HttpStatusCodeException.badRequest("400"));
|
||||||
} catch (HttpStatusCodeException e) {
|
} catch (HttpStatusCodeException e) {
|
||||||
log.error("Excepcion HTTP del api privada: {} - {}", e.getStatusCode(), e.getErrorCode());
|
log.error("Excepcion HTTP del api privada: {} - {}", e.getStatusCode(), e.getErrorCode());
|
||||||
throw e;
|
response = messageHelper.handleException(e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Excepcion generica del api privada: {}", e.getMessage());
|
log.error("Excepcion generica del api privada: {}", e.getMessage());
|
||||||
throw e;
|
response = messageHelper.handleGenericException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiResponse<ServiceIssuePaymentStatusResponse> apiPrivate(
|
private ApiResponse<ServiceIssuePaymentStatusResponse> apiPrivate(
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
package com.banesco.module.service_issue_payment_status.application.usecase;
|
package com.banesco.module.service_issue_payment_status.application.usecase;
|
||||||
|
|
||||||
import com.banesco.common.domain.model.ApiResponse;
|
|
||||||
import com.banesco.module.service_issue_payment_status.domain.dto.request.ServiceIssuePaymentStatusRequest;
|
import com.banesco.module.service_issue_payment_status.domain.dto.request.ServiceIssuePaymentStatusRequest;
|
||||||
import com.banesco.module.service_issue_payment_status.domain.dto.response.ServiceIssuePaymentStatusResponse;
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
public interface ServiceIssuePaymentStatusUseCase {
|
public interface ServiceIssuePaymentStatusUseCase {
|
||||||
ApiResponse<ServiceIssuePaymentStatusResponse> execute(
|
Response execute(
|
||||||
ServiceIssuePaymentStatusRequest request
|
ServiceIssuePaymentStatusRequest request
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,18 @@
|
|||||||
package com.banesco.module.service_issue_payment_status.domain.dto.request;
|
package com.banesco.module.service_issue_payment_status.domain.dto.request;
|
||||||
|
|
||||||
|
import com.banesco.common.domain.model.Device;
|
||||||
|
import com.banesco.common.infrastructure.context.RequestContext;
|
||||||
import com.banesco.module.instruction.domain.model.Instruction;
|
import com.banesco.module.instruction.domain.model.Instruction;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import io.netty.util.internal.StringUtil;
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static java.util.Map.entry;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@Builder
|
@Builder
|
||||||
@ -17,8 +26,43 @@ public class ServiceIssuePaymentStatusRequest {
|
|||||||
private String appId;
|
private String appId;
|
||||||
@NonNull
|
@NonNull
|
||||||
private Instruction procedureRequest;
|
private Instruction procedureRequest;
|
||||||
|
@NonNull
|
||||||
|
private Device device;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return getProcedureRequest().getInstructionIdentifier().getIdentification().getIdentifierValue();
|
return procedureRequest
|
||||||
|
.getInstructionIdentifier()
|
||||||
|
.getIdentification()
|
||||||
|
.getIdentifierValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getChannelCode() {
|
||||||
|
return procedureRequest
|
||||||
|
.getInstructionPurposeType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Map<String, String> toParams() {
|
||||||
|
return Map.ofEntries(
|
||||||
|
entry("paymentStatusId", Objects.toString(getId(), "")),
|
||||||
|
entry("channelCode", Objects.toString(getChannelCode(), ""))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Map<String, String> toQueryString() {
|
||||||
|
return Map.ofEntries(
|
||||||
|
entry("appId", Objects.toString(getAppId(), "")),
|
||||||
|
entry("customerReferenceFintechId", Objects.toString(getCustomerReferenceFintechId(), "")),
|
||||||
|
entry("deviceType", Objects.toString(getDevice().getDeviceType(), "")),
|
||||||
|
entry("deviceDescription", Objects.toString(getDevice().getDeviceDescription(), "")),
|
||||||
|
entry("deviceIp", Objects.toString(getDevice().getDeviceIp(), "")),
|
||||||
|
entry("deviceSessionReference", (!StringUtil.isNullOrEmpty(getDevice().getDeviceSessionReference()))
|
||||||
|
? getDevice().getDeviceSessionReference()
|
||||||
|
: RequestContext.getRequestId()
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,8 +23,7 @@ public class ServicingIssueMapper {
|
|||||||
return PaymentStatusRequest.builder()
|
return PaymentStatusRequest.builder()
|
||||||
.fintechId(request.getCustomerReferenceFintechId())
|
.fintechId(request.getCustomerReferenceFintechId())
|
||||||
.id(Long.valueOf(request.getId()))
|
.id(Long.valueOf(request.getId()))
|
||||||
.channelOrigin(request.getProcedureRequest().getInstructionPurposeType().name())
|
.channelOrigin(request.getChannelCode())
|
||||||
.signature(request.getProcedureRequest().getInstructionDescription())
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,19 +159,25 @@ public class ServicingIssueMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return switch (codeStatusRequest.toUpperCase()) {
|
return switch (codeStatusRequest.toUpperCase()) {
|
||||||
|
case "ACT", "ACTIVO", "ACTIVA" -> TransactionStatusType.ACTIVE;
|
||||||
case "PENDIENTE" -> TransactionStatusType.PENDING;
|
case "PENDIENTE" -> TransactionStatusType.PENDING;
|
||||||
case "EXITO", "EXITOSA", "COMPLETADO", "FINALIZADO" -> TransactionStatusType.COMPLETED;
|
case "EXITO", "EXITOSA", "COMPLETADO", "FINALIZADO" -> TransactionStatusType.COMPLETED;
|
||||||
case "APROBADO", "CONFIRMADO" -> TransactionStatusType.CONFIRMED;
|
case "APROBADO", "APROBADA" -> TransactionStatusType.APPROVED;
|
||||||
|
case "CONF", "CONFIRMADO", "CONFIRMADA" -> TransactionStatusType.CONFIRMED;
|
||||||
case "INICIADO" -> TransactionStatusType.INITIATED;
|
case "INICIADO" -> TransactionStatusType.INITIATED;
|
||||||
case "EN_PROCESO", "PROCESANDO", "EN CURSO" -> TransactionStatusType.IN_PROGRESS;
|
case "EN_PROCESO", "PROCESANDO", "EN CURSO" -> TransactionStatusType.IN_PROGRESS;
|
||||||
case "RECHAZADO", "FALLIDO" -> TransactionStatusType.REJECTED;
|
case "RECH", "RECHAZADO", "FALLA", "FALLIDO", "RECHAZADA", "FALLIDA" -> TransactionStatusType.REJECTED;
|
||||||
case "CANCELADO" -> TransactionStatusType.CANCELLED;
|
case "CANCELADO" -> TransactionStatusType.CANCELLED;
|
||||||
case "SUSPENDIDO" -> TransactionStatusType.SUSPENDED;
|
case "SUSPENDIDO" -> TransactionStatusType.SUSPENDED;
|
||||||
case "NOTIFICADO" -> TransactionStatusType.NOTIFIED;
|
case "NOTIFICADO" -> TransactionStatusType.NOTIFIED;
|
||||||
case "CONTABILIZADO" -> TransactionStatusType.BOOKED;
|
case "CONTABILIZADO" -> TransactionStatusType.BOOKED;
|
||||||
case "EJECUTADO" -> TransactionStatusType.EXECUTED;
|
case "EJECUTADO" -> TransactionStatusType.EXECUTED;
|
||||||
case "EXP" -> TransactionStatusType.EXPIRED;
|
case "EXP", "EXPIRADO", "EXPIRADA" -> TransactionStatusType.EXPIRED;
|
||||||
case "ENVIADO" -> TransactionStatusType.SENT;
|
case "ENVIADO", "ENVIADA" -> TransactionStatusType.SENT;
|
||||||
|
case "RECIBIDO", "RECIBIDA" -> TransactionStatusType.RECEIVED;
|
||||||
|
case "LEIDA" -> TransactionStatusType.READ;
|
||||||
|
case "PROG", "PROGRAMADO", "PROGRAMADA" -> TransactionStatusType.PROGRAMED;
|
||||||
|
case "TRANSATIP" -> TransactionStatusType.ATYPICAL_TRANSACTION;
|
||||||
default -> TransactionStatusType.DEFAULT;
|
default -> TransactionStatusType.DEFAULT;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
package com.banesco.module.service_issue_payment_status.infrastructure.resource;
|
package com.banesco.module.service_issue_payment_status.infrastructure.resource;
|
||||||
|
|
||||||
import com.banesco.common.application.helper.MessageHelper;
|
|
||||||
import com.banesco.common.domain.exception.HttpStatusCodeException;
|
|
||||||
import com.banesco.common.domain.model.ApiResponse;
|
import com.banesco.common.domain.model.ApiResponse;
|
||||||
|
import com.banesco.common.domain.model.Device;
|
||||||
import com.banesco.common.domain.model.StatusResponse;
|
import com.banesco.common.domain.model.StatusResponse;
|
||||||
import com.banesco.module.instruction.domain.model.Instruction;
|
import com.banesco.module.instruction.domain.model.Instruction;
|
||||||
import com.banesco.module.service_issue_payment_status.application.usecase.ServiceIssuePaymentStatusUseCase;
|
import com.banesco.module.service_issue_payment_status.application.usecase.ServiceIssuePaymentStatusUseCase;
|
||||||
@ -31,19 +30,16 @@ import java.util.Objects;
|
|||||||
public class ServiceIssuePaymentStatusResource {
|
public class ServiceIssuePaymentStatusResource {
|
||||||
|
|
||||||
private final ServiceIssuePaymentStatusUseCase useCase;
|
private final ServiceIssuePaymentStatusUseCase useCase;
|
||||||
private final MessageHelper messageHelper;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ServiceIssuePaymentStatusResource(
|
public ServiceIssuePaymentStatusResource(
|
||||||
MessageHelper messageHelper,
|
|
||||||
ServiceIssuePaymentStatusUseCase useCase
|
ServiceIssuePaymentStatusUseCase useCase
|
||||||
) {
|
) {
|
||||||
this.messageHelper = messageHelper;
|
|
||||||
this.useCase = useCase;
|
this.useCase = useCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/retrieve/{paymentStatusId}/{channelCode}/{signatureIdentifier}")
|
@Path("/retrieve/{paymentStatusId}/{channelCode}")
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Recuperar informacion de la transaccion",
|
summary = "Recuperar informacion de la transaccion",
|
||||||
description = "Consulta de una trasanccion de pago por id de archivo"
|
description = "Consulta de una trasanccion de pago por id de archivo"
|
||||||
@ -312,34 +308,48 @@ public class ServiceIssuePaymentStatusResource {
|
|||||||
@Parameter(description = "Codigo del canal (BOL, BOLE)", required = true, example = "BOLE")
|
@Parameter(description = "Codigo del canal (BOL, BOLE)", required = true, example = "BOLE")
|
||||||
String channelCode,
|
String channelCode,
|
||||||
|
|
||||||
@PathParam("signatureIdentifier")
|
|
||||||
@Parameter(description = "Firma del archivo", required = true, example = "add7c6375b8659a798a998258fb049b98119ea97d8116b95e1ee00cc9ffafa84")
|
|
||||||
String signatureIdentifier,
|
|
||||||
|
|
||||||
@QueryParam("customerReferenceFintechId")
|
@QueryParam("customerReferenceFintechId")
|
||||||
@Parameter(description = "ID de la fintech", example = "pranical-test")
|
@Parameter(description = "ID de la fintech", example = "pranical-test")
|
||||||
String customerReferenceFintechId,
|
String customerReferenceFintechId,
|
||||||
|
|
||||||
@QueryParam("appId")
|
@QueryParam("appId")
|
||||||
@Parameter(description = "ID de la aplicacion", example = "DANIAPP")
|
@Parameter(description = "ID de la aplicacion", example = "DANIAPP")
|
||||||
String appId
|
String appId,
|
||||||
|
|
||||||
|
@QueryParam("deviceType")
|
||||||
|
@Parameter(description = "Tipo de dispositivo", example = "Mobile")
|
||||||
|
String deviceType,
|
||||||
|
|
||||||
|
@QueryParam("deviceDescription")
|
||||||
|
@Parameter(description = "Descripcion del dispositivo", example = "Xiaomi Note 11 PRO")
|
||||||
|
String deviceDescription,
|
||||||
|
|
||||||
|
@QueryParam("deviceIp")
|
||||||
|
@Parameter(description = "Direccion IP del dispositivo", example = "127.0.0.1")
|
||||||
|
String deviceIp,
|
||||||
|
|
||||||
|
@QueryParam("deviceSessionReference")
|
||||||
|
@Parameter(description = "Referencia de la peticion del dispositivo", example = "12345678901304")
|
||||||
|
String deviceSessionReference
|
||||||
) {
|
) {
|
||||||
log.info("Iniciando consulta para instruccion de archivo id: {}", paymentStatusId);
|
log.info("Iniciando consulta para instruccion de archivo id: {}", paymentStatusId);
|
||||||
|
|
||||||
try {
|
return useCase.execute(
|
||||||
return Response.ok(useCase.execute(
|
ServiceIssuePaymentStatusRequest.builder()
|
||||||
ServiceIssuePaymentStatusRequest.builder()
|
.customerReferenceFintechId(Objects.toString(customerReferenceFintechId, ""))
|
||||||
.customerReferenceFintechId(Objects.toString(customerReferenceFintechId, ""))
|
.appId(Objects.toString(appId, ""))
|
||||||
.appId(Objects.toString(appId, ""))
|
.procedureRequest(Instruction.fromResource(
|
||||||
.procedureRequest(Instruction.fromResource(
|
paymentStatusId, channelCode
|
||||||
paymentStatusId, channelCode, signatureIdentifier
|
))
|
||||||
))
|
.device(
|
||||||
.build()
|
Device.builder()
|
||||||
)).build();
|
.deviceType(deviceType)
|
||||||
} catch (HttpStatusCodeException e) {
|
.deviceDescription(deviceDescription)
|
||||||
return messageHelper.handleException(e);
|
.deviceIp(deviceIp)
|
||||||
} catch (Exception e) {
|
.deviceSessionReference(deviceSessionReference)
|
||||||
return messageHelper.handleGenericException(e);
|
.build()
|
||||||
}
|
)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,6 +7,7 @@ public enum TransactionStatusType {
|
|||||||
EXECUTED,
|
EXECUTED,
|
||||||
CANCELLED,
|
CANCELLED,
|
||||||
CONFIRMED,
|
CONFIRMED,
|
||||||
|
APPROVED,
|
||||||
SUSPENDED,
|
SUSPENDED,
|
||||||
PENDING,
|
PENDING,
|
||||||
COMPLETED,
|
COMPLETED,
|
||||||
@ -15,4 +16,9 @@ public enum TransactionStatusType {
|
|||||||
REJECTED,
|
REJECTED,
|
||||||
EXPIRED,
|
EXPIRED,
|
||||||
SENT,
|
SENT,
|
||||||
|
RECEIVED,
|
||||||
|
ACTIVE,
|
||||||
|
READ,
|
||||||
|
PROGRAMED,
|
||||||
|
ATYPICAL_TRANSACTION,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,6 @@ api:
|
|||||||
dom-service-issue-payment-status:
|
dom-service-issue-payment-status:
|
||||||
messages:
|
messages:
|
||||||
key: 'dom-service-issue-payment-status'
|
key: 'dom-service-issue-payment-status'
|
||||||
content: '[{"backendCode":"200","httpCode":200,"statusCode":"200","description":"Operacion exitosa"},{"backendCode":"R404","httpCode":404,"statusCode":"404","description":"Datos de validacion no encontrado."},{"backendCode":"503","httpCode":503,"statusCode":"503","description":"Uso interno"},{"backendCode":"422","httpCode":422,"statusCode":"422","description":"Uso interno"},{"backendCode":"500","httpCode":500,"statusCode":"500","description":"Uso interno"},{"backendCode":"100","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"OSB-382505","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"OSB-380002","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"ERROR","httpCode":400,"statusCode":"400","description":"Uso interno"},{"backendCode":"400","httpCode":400,"statusCode":"400","description":"Uso interno"},{"backendCode":"401","httpCode":401,"statusCode":"401","description":"Uso interno"},{"backendCode":"403","httpCode":403,"statusCode":"403","description":"Uso interno"},{"backendCode":"404","httpCode":404,"statusCode":"404","description":"Uso interno"},{"backendCode":"default","httpCode":409,"statusCode":"409","description":"Conflicto"},{"backendCode":"424","httpCode":424,"statusCode":"424","description":"Error de dependencia"},{"backendCode":"VDE01","httpCode":400,"statusCode":"VDE01","description":"VDE01 - Error en dato de entrada obligatorio: %s"},{"backendCode":"VDE02","httpCode":400,"statusCode":"VDE02","description":"VDE02 - Error en valor permitido para campo: %s"},{"backend_code":"204","http_code":"200","status_code":"200","description":"Cliente sin productos","status":"ok"}]'
|
content: '[{"backendCode":"200","httpCode":200,"statusCode":"200","description":"Operacion exitosa"},{"backendCode":"R404","httpCode":404,"statusCode":"404","description":"Datos de validacion no encontrado."},{"backendCode":"503","httpCode":503,"statusCode":"503","description":"Uso interno"},{"backendCode":"422","httpCode":422,"statusCode":"422","description":"Uso interno"},{"backendCode":"500","httpCode":500,"statusCode":"500","description":"Uso interno"},{"backendCode":"100","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"OSB-382505","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"OSB-380002","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"ERROR","httpCode":400,"statusCode":"400","description":"Uso interno"},{"backendCode":"400","httpCode":400,"statusCode":"400","description":"Uso interno"},{"backendCode":"401","httpCode":401,"statusCode":"401","description":"Uso interno"},{"backendCode":"403","httpCode":403,"statusCode":"403","description":"Uso interno"},{"backendCode":"404","httpCode":404,"statusCode":"404","description":"Uso interno"},{"backendCode":"default","httpCode":409,"statusCode":"409","description":"Conflicto"},{"backendCode":"424","httpCode":424,"statusCode":"424","description":"Error de dependencia"},{"backendCode":"VDE01","httpCode":400,"statusCode":"VDE01","description":"VDE01 - Error en dato de entrada obligatorio: %s"},{"backendCode":"VDE02","httpCode":400,"statusCode":"VDE02","description":"VDE02 - Error en valor permitido para campo: %s"},{"backendCode":"VRN02","httpCode":"204","statusCode":"VRN02","description":"Cliente sin productos"}]'
|
||||||
rest-client:
|
rest-client:
|
||||||
payment-status-by-id: '{"url":"http://10.135.193.156:8080/RequestPayment/notificationRequestPayment/v1/querys/getRequestPayStatusById/{signatureIdentifier}","timeout":{"connect":10000,"response":10000},"statusSuccess":"00"}'
|
payment-status-by-id: '{"url":"http://10.135.193.156:8080/RequestPayment/notificationRequestPayment/v1/querys/getRequestPayStatusById/{signatureIdentifier}","timeout":{"connect":10000,"response":10000},"statusSuccess":"00"}'
|
||||||
Loading…
x
Reference in New Issue
Block a user