update error messages into private api; update generals
This commit is contained in:
parent
63d971880c
commit
a9e5d0394f
Binary file not shown.
@ -28,10 +28,12 @@ public class PartyValidateHelper {
|
|||||||
!Objects.isNull(blackListRec) &&
|
!Objects.isNull(blackListRec) &&
|
||||||
!StringUtil.isNullOrEmpty(blackListRec.getBlackListBanesco()) &&
|
!StringUtil.isNullOrEmpty(blackListRec.getBlackListBanesco()) &&
|
||||||
!StringUtil.isNullOrEmpty(blackListRec.getBlackListCbn()) &&
|
!StringUtil.isNullOrEmpty(blackListRec.getBlackListCbn()) &&
|
||||||
blackListRec.getBlackListBanesco().equalsIgnoreCase("N") &&
|
(
|
||||||
blackListRec.getBlackListCbn().equalsIgnoreCase("N")
|
!blackListRec.getBlackListBanesco().equalsIgnoreCase("N") ||
|
||||||
|
!blackListRec.getBlackListCbn().equalsIgnoreCase("N")
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
return;
|
throw HttpStatusCodeException.unauthorized("VRN13");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +48,17 @@ public class PartyValidateHelper {
|
|||||||
List<String> errors = extractErrorCodes(status);
|
List<String> errors = extractErrorCodes(status);
|
||||||
|
|
||||||
if(!errors.isEmpty()) {
|
if(!errors.isEmpty()) {
|
||||||
|
if(
|
||||||
|
errors.size() == 1 &&
|
||||||
|
(
|
||||||
|
Objects.equals(errors.get(0), "388") ||
|
||||||
|
errors.get(0).equalsIgnoreCase("AFPM388")
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
log.error("Error del estatus controlado: {}", errors.get(0));
|
||||||
|
throw HttpStatusCodeException.forbidden("VRN20");
|
||||||
|
}
|
||||||
|
|
||||||
AdditionalStatus additionalStatus = getFirstAdditionalStatus(status);
|
AdditionalStatus additionalStatus = getFirstAdditionalStatus(status);
|
||||||
String error = String.join("-", errors);
|
String error = String.join("-", errors);
|
||||||
String desc = (!Objects.isNull(additionalStatus))
|
String desc = (!Objects.isNull(additionalStatus))
|
||||||
@ -75,7 +88,6 @@ public class PartyValidateHelper {
|
|||||||
|
|
||||||
private static List<String> extractErrorCodes(Status status) {
|
private static List<String> extractErrorCodes(Status status) {
|
||||||
List<String> errors = new ArrayList<>();
|
List<String> errors = new ArrayList<>();
|
||||||
|
|
||||||
List<AdditionalStatus> additionalStatuses = status.getAdditionalStatus();
|
List<AdditionalStatus> additionalStatuses = status.getAdditionalStatus();
|
||||||
|
|
||||||
if(Objects.isNull(additionalStatuses) || additionalStatuses.isEmpty()) {
|
if(Objects.isNull(additionalStatuses) || additionalStatuses.isEmpty()) {
|
||||||
|
|||||||
@ -58,117 +58,117 @@ public class HttpRequest {
|
|||||||
private boolean logResponseBody = true;
|
private boolean logResponseBody = true;
|
||||||
|
|
||||||
public static <T> HttpRequest forApiResponse(
|
public static <T> HttpRequest forApiResponse(
|
||||||
String url,
|
String url,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> dataType
|
Class<T> dataType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(ApiResponse.class)
|
.responseType(ApiResponse.class)
|
||||||
.genericType(dataType)
|
.genericType(dataType)
|
||||||
.apiResponse(true)
|
.apiResponse(true)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> HttpRequest forApiResponseList(
|
public static <T> HttpRequest forApiResponseList(
|
||||||
String url,
|
String url,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> elementType
|
Class<T> elementType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(ApiResponse.class)
|
.responseType(ApiResponse.class)
|
||||||
.complexType(TypeBuilder.listOf(elementType))
|
.complexType(TypeBuilder.listOf(elementType))
|
||||||
.apiResponse(true)
|
.apiResponse(true)
|
||||||
.listResponse(true)
|
.listResponse(true)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> HttpRequest forApiPrivateResponse(
|
public static <T> HttpRequest forApiPrivateResponse(
|
||||||
String url,
|
String url,
|
||||||
String statusSuccess,
|
String statusSuccess,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> successType
|
Class<T> successType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(ApiPrivateResponse.class)
|
.responseType(ApiPrivateResponse.class)
|
||||||
.complexType(TypeBuilder.parametricType(
|
.complexType(TypeBuilder.parametricType(
|
||||||
Either.class,
|
Either.class,
|
||||||
successType,
|
successType,
|
||||||
ApiPrivateError.class
|
ApiPrivateError.class
|
||||||
))
|
))
|
||||||
.apiPrivateResponse(true)
|
.apiPrivateResponse(true)
|
||||||
.eitherResponse(true)
|
.eitherResponse(true)
|
||||||
.errorType(ApiPrivateError.class)
|
.errorType(ApiPrivateError.class)
|
||||||
.statusSuccess(statusSuccess)
|
.statusSuccess(statusSuccess)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> HttpRequest forApiPrivateResponseList(
|
public static <T> HttpRequest forApiPrivateResponseList(
|
||||||
String url,
|
String url,
|
||||||
String statusSuccess,
|
String statusSuccess,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> elementType
|
Class<T> elementType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(ApiPrivateResponse.class)
|
.responseType(ApiPrivateResponse.class)
|
||||||
.complexType(TypeBuilder.parametricType(
|
.complexType(TypeBuilder.parametricType(
|
||||||
Either.class,
|
Either.class,
|
||||||
TypeBuilder.listOf(elementType),
|
TypeBuilder.listOf(elementType),
|
||||||
ApiPrivateError.class
|
ApiPrivateError.class
|
||||||
))
|
))
|
||||||
.apiPrivateResponse(true)
|
.apiPrivateResponse(true)
|
||||||
.eitherResponse(true)
|
.eitherResponse(true)
|
||||||
.listResponse(true)
|
.listResponse(true)
|
||||||
.errorType(ApiPrivateError.class)
|
.errorType(ApiPrivateError.class)
|
||||||
.statusSuccess(statusSuccess)
|
.statusSuccess(statusSuccess)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> HttpRequest forDirectResponse(
|
public static <T> HttpRequest forDirectResponse(
|
||||||
String url,
|
String url,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> responseType
|
Class<T> responseType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(responseType)
|
.responseType(responseType)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T, R> HttpRequest forDirectResponse(
|
public static <T, R> HttpRequest forDirectResponse(
|
||||||
String url,
|
String url,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> responseType,
|
Class<T> responseType,
|
||||||
Class<R> errorType
|
Class<R> errorType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(responseType)
|
.responseType(responseType)
|
||||||
.errorType(errorType)
|
.errorType(errorType)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T, U> HttpRequest forGenericResponse(
|
public static <T, U> HttpRequest forGenericResponse(
|
||||||
String url,
|
String url,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> rawType,
|
Class<T> rawType,
|
||||||
Class<U> genericType
|
Class<U> genericType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(rawType)
|
.responseType(rawType)
|
||||||
.complexType(TypeBuilder.parametricType(rawType, genericType))
|
.complexType(TypeBuilder.parametricType(rawType, genericType))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpRequest withHeaders(Map<String, String> headers) {
|
public HttpRequest withHeaders(Map<String, String> headers) {
|
||||||
|
|||||||
@ -1,14 +0,0 @@
|
|||||||
package com.banesco.common.domain.model;
|
|
||||||
|
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@ToString
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@RegisterForReflection
|
|
||||||
public class Location {
|
|
||||||
private String locationValue; // directorio
|
|
||||||
}
|
|
||||||
@ -32,8 +32,7 @@ public class PaymentInitiationRequestRequest {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public String getPaymentTransactionType() {
|
public String getPaymentTransactionType() {
|
||||||
return paymentInitiationTransaction
|
return paymentInitiationTransaction
|
||||||
.getPaymentTransactionType()
|
.getPaymentTransactionType();
|
||||||
.name();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import java.math.BigDecimal;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@RegisterForReflection
|
@RegisterForReflection
|
||||||
public class PaymentInitiationTransactionInstanceRecord {
|
public class PaymentInitiationTransactionInstanceRecord {
|
||||||
private PaymentTransactionType paymentTransactionType; // operationTypeCode
|
private String paymentTransactionType; // operationTypeCode
|
||||||
private Payer payerReference; // applicantId
|
private Payer payerReference; // applicantId
|
||||||
private Payee payeeReference; // recipientId
|
private Payee payeeReference; // recipientId
|
||||||
private BigDecimal amount; // amount
|
private BigDecimal amount; // amount
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
package com.banesco.module.payment_initiation_request.domain.model;
|
|
||||||
|
|
||||||
public enum PaymentTransactionType {
|
|
||||||
MOBILE_PAYMENT,
|
|
||||||
}
|
|
||||||
@ -227,7 +227,7 @@ public class PaymentInitiationRequestResource {
|
|||||||
"customerReferenceFintechId": "provider-test",
|
"customerReferenceFintechId": "provider-test",
|
||||||
"appId": "DANIAPP",
|
"appId": "DANIAPP",
|
||||||
"paymentInitiationTransaction": {
|
"paymentInitiationTransaction": {
|
||||||
"paymentTransactionType": "MOBILE_PAYMENT",
|
"paymentTransactionType": "PAGO_MOVIL",
|
||||||
"payerReference": {
|
"payerReference": {
|
||||||
"partyIdentification": [
|
"partyIdentification": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@RegisterForReflection
|
@RegisterForReflection
|
||||||
@ -13,4 +15,5 @@ public class SecurityTraceConfig {
|
|||||||
private String url;
|
private String url;
|
||||||
private TimeoutConfig timeout;
|
private TimeoutConfig timeout;
|
||||||
private SecurityTraceRequest request;
|
private SecurityTraceRequest request;
|
||||||
|
private Map<String, String> converters;
|
||||||
}
|
}
|
||||||
@ -6,6 +6,7 @@ import com.banesco.common.domain.model.ApiResponse;
|
|||||||
import com.banesco.common.domain.model.HttpRequest;
|
import com.banesco.common.domain.model.HttpRequest;
|
||||||
import com.banesco.common.infrastructure.config.RestClientConfig;
|
import com.banesco.common.infrastructure.config.RestClientConfig;
|
||||||
import com.banesco.module.payment_initiation_request.domain.dto.request.PaymentInitiationRequestRequest;
|
import com.banesco.module.payment_initiation_request.domain.dto.request.PaymentInitiationRequestRequest;
|
||||||
|
import com.banesco.module.payment_initiation_request.domain.dto.response.PaymentInitiationRequestResponse;
|
||||||
import com.banesco.module.security_trace.application.usecase.SecurityTraceUseCase;
|
import com.banesco.module.security_trace.application.usecase.SecurityTraceUseCase;
|
||||||
import com.banesco.module.security_trace.domain.dto.request.SecurityTraceRequest;
|
import com.banesco.module.security_trace.domain.dto.request.SecurityTraceRequest;
|
||||||
import com.banesco.module.security_trace.domain.model.SecurityTraceConfig;
|
import com.banesco.module.security_trace.domain.model.SecurityTraceConfig;
|
||||||
@ -17,6 +18,7 @@ import jakarta.ws.rs.core.Response;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
@ -92,15 +94,13 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
|||||||
int statusHttp = apiResponse.getStatus();
|
int statusHttp = apiResponse.getStatus();
|
||||||
String payerId = apiRequest.getPayerId();
|
String payerId = apiRequest.getPayerId();
|
||||||
String payeeId = apiRequest.getPayeeId();
|
String payeeId = apiRequest.getPayeeId();
|
||||||
String codMon = (!StringUtil.isNullOrEmpty(apiRequest.getCurrency()))
|
ApiResponse<PaymentInitiationRequestResponse> apiResponseData =
|
||||||
? apiRequest.getCurrency()
|
(ApiResponse<PaymentInitiationRequestResponse>) apiResponse.getEntity();
|
||||||
: securityTraceConfig.getRequest().getCodMon();
|
|
||||||
ApiResponse<?> apiResponseData = (ApiResponse<?>) apiResponse.getEntity();
|
|
||||||
|
|
||||||
return SecurityTraceRequest.builder()
|
return SecurityTraceRequest.builder()
|
||||||
.sp(securityTraceConfig.getRequest().getSp())
|
.sp(securityTraceConfig.getRequest().getSp())
|
||||||
.codBan(securityTraceConfig.getRequest().getCodBan())
|
.codBan(securityTraceConfig.getRequest().getCodBan())
|
||||||
.codMon(codMon)
|
.codMon(getCodMon(apiRequest))
|
||||||
.codEve(securityTraceConfig.getRequest().getCodEve())
|
.codEve(securityTraceConfig.getRequest().getCodEve())
|
||||||
.codEve2(securityTraceConfig.getRequest().getCodEve2())
|
.codEve2(securityTraceConfig.getRequest().getCodEve2())
|
||||||
.login(apiRequest.getChannelCode())
|
.login(apiRequest.getChannelCode())
|
||||||
@ -110,6 +110,7 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
|||||||
.nacBen(payeeId.substring(0, 1).toUpperCase())
|
.nacBen(payeeId.substring(0, 1).toUpperCase())
|
||||||
.cedBen(getPartyIdNumber(payeeId.substring(1)))
|
.cedBen(getPartyIdNumber(payeeId.substring(1)))
|
||||||
.monto(apiRequest.getAmount())
|
.monto(apiRequest.getAmount())
|
||||||
|
.referencia(getReference(apiResponseData))
|
||||||
.desPago(apiRequest.getPurpose())
|
.desPago(apiRequest.getPurpose())
|
||||||
.objeto(
|
.objeto(
|
||||||
restClientConfig.toJsonString(SecurityTraceObject.builder()
|
restClientConfig.toJsonString(SecurityTraceObject.builder()
|
||||||
@ -128,6 +129,46 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getCodMon(
|
||||||
|
PaymentInitiationRequestRequest apiRequest
|
||||||
|
) {
|
||||||
|
String defaultCurrency = securityTraceConfig.getRequest().getCodMon();
|
||||||
|
|
||||||
|
if (StringUtil.isNullOrEmpty(apiRequest.getCurrency())) {
|
||||||
|
log.info("Moneda asignada por defecto: {}", defaultCurrency);
|
||||||
|
return defaultCurrency;
|
||||||
|
}
|
||||||
|
|
||||||
|
String currency = apiRequest.getCurrency().toUpperCase();
|
||||||
|
|
||||||
|
defaultCurrency = securityTraceConfig.getConverters()
|
||||||
|
.getOrDefault(currency, currency);
|
||||||
|
|
||||||
|
log.info("Moneda convertida o por defecto: {} -> {}", currency, defaultCurrency);
|
||||||
|
|
||||||
|
return defaultCurrency;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getReference(
|
||||||
|
ApiResponse<PaymentInitiationRequestResponse> apiResponseData
|
||||||
|
) {
|
||||||
|
if(
|
||||||
|
!Objects.isNull(apiResponseData) &&
|
||||||
|
!Objects.isNull(apiResponseData.getData()) &&
|
||||||
|
!Objects.isNull(apiResponseData.getData().getPaymentInitiationTransaction()) &&
|
||||||
|
!Objects.isNull(apiResponseData.getData().getPaymentInitiationTransaction().getTransaction()) &&
|
||||||
|
!Objects.isNull(apiResponseData.getData().getPaymentInitiationTransaction().getTransaction().getTransactionIdentification())
|
||||||
|
) {
|
||||||
|
return apiResponseData.getData()
|
||||||
|
.getPaymentInitiationTransaction()
|
||||||
|
.getTransaction()
|
||||||
|
.getTransactionIdentification()
|
||||||
|
.getIdentifierValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private String getStatusMessage(
|
private String getStatusMessage(
|
||||||
ApiResponse<?> apiResponseData,
|
ApiResponse<?> apiResponseData,
|
||||||
int statusHttp
|
int statusHttp
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user