Untitled
plain_text
a month ago
15 kB
0
Indexable
Never
public void inputValidationGenerateDeeplink(GenerateDeeplinkRequestV3 request) { List<DetailedErrorItem> detailedErrorItemList = new ArrayList<>(); // 4. if (StringUtils.isEmpty(request.getBilledAmountType())) { request.setBilledAmountType("A1"); } else { if (!PAYMENT_CHANNEL_BAY_CMS.equals(request.getPaymentChannel())) { detailedErrorItemList.add( new DetailedErrorItem("Unsupported operation for the selected paymentChannel") ); } if (!"A1".equals(request.getBilledAmountType()) && !ObjectUtils.isEmpty(request.getWithholdingTaxInformationItems())) { detailedErrorItemList.add( new DetailedErrorItem("billedAmountType must not be sent or sent as A1 when withholdingTaxInformationItems is provided") ); } } // 5. if (StringUtils.isEmpty(request.getExpiryDateTime())) { } else { } // 6. if (!ObjectUtils.isEmpty(request.getWithholdingTaxInformationItems()) && !PAYMENT_CHANNEL_BAY_CMS.equals(request.getPaymentChannel())) { if (ObjectUtils.isEmpty(request.getReportingInformation()) || StringUtils.isEmpty(request.getReportingInformation().getWithholdingTaxProcessingType())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.withholdingTaxProcessingType must be provided when paymentChannel is not BAY_CMS and withholdingTaxInformationItems is provided") ); } else { if ("WHT".equals(request.getReportingInformation().getWithholdingTaxProcessingType()) || "WHT_CERT".equals(request.getReportingInformation().getWithholdingTaxProcessingType())) { if (StringUtils.isEmpty(request.getReportingInformation().getWithholdingTaxFormNumber())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.withholdingTaxFormNumber must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is WHT or WHT_CERT") ); } if ("WHT_CERT".equals(request.getReportingInformation().getWithholdingTaxProcessingType())) { if (StringUtils.isEmpty(request.getReportingInformation().getPayerBranchCode())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payerBranchCode must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is WHT_CERT") ); } if (StringUtils.isEmpty(request.getReportingInformation().getPayeeIdentificationNumber())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payeeIdentificationNumber must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is WHT_CERT") ); } if (StringUtils.isEmpty(request.getReportingInformation().getPayeeTypeOfIdentification())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payeeTypeOfIdentification must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is WHT_CERT") ); } if (StringUtils.isEmpty(request.getReportingInformation().getPayeeBranchCode())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payeeBranchCode must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is WHT_CERT") ); } if (StringUtils.isEmpty(request.getReportingInformation().getPayerFirstName())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payerFirstName must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is WHT_CERT") ); } if (StringUtils.isEmpty(request.getReportingInformation().getPayerAddress())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payerAddress must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is WHT_CERT") ); } if (StringUtils.isEmpty(request.getReportingInformation().getPayeeFirstName())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payeeFirstName must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is WHT_CERT") ); } if (StringUtils.isEmpty(request.getReportingInformation().getPayeeAddress())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payeeAddress must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is WHT_CERT") ); } } } else if ("EWHT".equals(request.getReportingInformation().getWithholdingTaxProcessingType()) || "EWHT_CERT".equals(request.getReportingInformation().getWithholdingTaxProcessingType())) { if (StringUtils.isEmpty(request.getReportingInformation().getPayerBranchCode())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payerBranchCode must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is EWHT or EWHT_CERT") ); } if (StringUtils.isEmpty(request.getReportingInformation().getPayeeIdentificationNumber())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payeeIdentificationNumber must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is EWHT or EWHT_CERT") ); } if (StringUtils.isEmpty(request.getReportingInformation().getPayeeTypeOfIdentification())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payeeTypeOfIdentification must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is EWHT or EWHT_CERT") ); } if (StringUtils.isEmpty(request.getReportingInformation().getPayeeBranchCode())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payeeBranchCode must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is EWHT or EWHT_CERT") ); } if ("EWHT_CERT".equals(request.getReportingInformation().getWithholdingTaxProcessingType())) { if (StringUtils.isEmpty(request.getReportingInformation().getPayerFirstName())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payerFirstName must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is EWHT_CERT") ); } if (StringUtils.isEmpty(request.getReportingInformation().getPayerAddress())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payerAddress must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is EWHT_CERT") ); } if (StringUtils.isEmpty(request.getReportingInformation().getPayeeFirstName())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payeeFirstName must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is EWHT_CERT") ); } if (StringUtils.isEmpty(request.getReportingInformation().getPayeeAddress())) { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation.payeeAddress must be provided when paymentChannel is not BAY_CMS and reportingInformation.withholdingTaxProcessingType is EWHT_CERT") ); } } } } } // 7. if (request.getSmartFinancialPaymentIndicator() == null) { request.setSmartFinancialPaymentIndicator(false); } else if (request.getSmartFinancialPaymentIndicator()) { if (!PAYMENT_CHANNEL_BAY_CMS.equals(request.getPaymentChannel())) { detailedErrorItemList.add( new DetailedErrorItem("paymentChannel must be BAY_CMS when smartFinancialPaymentIndicator is true") ); } if (ObjectUtils.isEmpty(request.getPresentmentEntryItems())) { detailedErrorItemList.add( new DetailedErrorItem("presentmentEntryItems[] must be provided when smartFinancialPaymentIndicator is true") ); } else { for (int i = 0; i < request.getPresentmentEntryItems().size(); i++) { PresentmentEntryItemRequest presentmentEntry = request.getPresentmentEntryItems().get(i); String prefixMessage = "presentmentEntryItems[" + i + "]."; if (StringUtils.isEmpty(presentmentEntry.getSellerIdentificationNumber())) { detailedErrorItemList.add( new DetailedErrorItem(prefixMessage + "sellerIdentificationNumber must be provided when smartFinancialPaymentIndicator is true") ); } if (StringUtils.isEmpty(presentmentEntry.getSellerBranchCode())) { detailedErrorItemList.add( new DetailedErrorItem(prefixMessage + "sellerBranchCode must be provided when smartFinancialPaymentIndicator is true") ); } if (StringUtils.isEmpty(presentmentEntry.getDocumentType())) { detailedErrorItemList.add( new DetailedErrorItem(prefixMessage + "documentType must be provided when smartFinancialPaymentIndicator is true") ); } if (StringUtils.isEmpty(presentmentEntry.getDocumentNumber())) { detailedErrorItemList.add( new DetailedErrorItem(prefixMessage + "documentNumber must be provided when smartFinancialPaymentIndicator is true") ); } if (StringUtils.isEmpty(presentmentEntry.getIssueDatetime())) { detailedErrorItemList.add( new DetailedErrorItem(prefixMessage + "issueDatetime must be provided when smartFinancialPaymentIndicator is true") ); } } } } // 8. if (request.getPayerValidationIndicator() == null) { request.setPayerValidationIndicator(false); } else if (request.getPayerValidationIndicator()) { if (!PAYMENT_CHANNEL_BAY_CMS.equals(request.getPaymentChannel())) { detailedErrorItemList.add( new DetailedErrorItem("paymentChannel must be BAY_CMS when payerValidationIndicator is true") ); } if (!ObjectUtils.isEmpty(request.getReportingInformation())) { boolean isPayerAccountNumberNotEmpty = StringUtils.isNotEmpty(request.getReportingInformation().getPayerAccountNumber()); boolean isPayerIdentificationNumberAndPayerTypeOfIdentificationNotEmpty = StringUtils.isNotEmpty(request.getReportingInformation().getPayerIdentificationNumber()) && StringUtils.isNotEmpty(request.getReportingInformation().getPayerTypeOfIdentification()); if (!(isPayerAccountNumberNotEmpty || isPayerIdentificationNumberAndPayerTypeOfIdentificationNotEmpty)) { detailedErrorItemList.add( new DetailedErrorItem("payerAccountNumber must be provided or payerIdentificationNumber and payerTypeOfIdentification when payerValidationIndicator is true") ); } } else { detailedErrorItemList.add( new DetailedErrorItem("reportingInformation must be provided when payerValidationIndicator is true") ); } } if (detailedErrorItemList.size() != 0) { throw new InvalidInputException(INVALID_REQUEST_CODE, INVALID_REQUEST_MESSAGE, detailedErrorItemList); } }