@Test public void testGetPaymentResultFromStatusOrPaymentResponseFailure() throws IOException { TerminalAPIResponse terminalAPIResponse = createResponseFromFile(TEST_RESPONSE_DIR+"SaleToPOIResponseInProgress.json"); ResultType statusResult = TerminalAPIUtil.getPaymentResultFromStatusOrPaymentResponse(terminalAPIResponse); assertNotNull(statusResult); assertEquals(ResultType.FAILURE, statusResult); }
public static ResultType getPaymentResultFromStatusOrPaymentResponse(TerminalAPIResponse terminalApiResponse) { if (terminalApiResponse != null && terminalApiResponse.getSaleToPOIResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getPaymentResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getPaymentResponse().getResponse() != null) { return terminalApiResponse.getSaleToPOIResponse().getPaymentResponse().getResponse().getResult(); } } else if (terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody().getPaymentResponse() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody().getPaymentResponse().getResponse() != null) { return terminalApiResponse.getSaleToPOIResponse() .getTransactionStatusResponse() .getRepeatedMessageResponse() .getRepeatedResponseMessageBody() .getPaymentResponse() .getResponse() .getResult(); } } } return ResultType.FAILURE; }
TerminalAPIUtil { public static ResultType getPaymentResultFromStatusOrPaymentResponse(TerminalAPIResponse terminalApiResponse) { if (terminalApiResponse != null && terminalApiResponse.getSaleToPOIResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getPaymentResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getPaymentResponse().getResponse() != null) { return terminalApiResponse.getSaleToPOIResponse().getPaymentResponse().getResponse().getResult(); } } else if (terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody().getPaymentResponse() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody().getPaymentResponse().getResponse() != null) { return terminalApiResponse.getSaleToPOIResponse() .getTransactionStatusResponse() .getRepeatedMessageResponse() .getRepeatedResponseMessageBody() .getPaymentResponse() .getResponse() .getResult(); } } } return ResultType.FAILURE; } }
TerminalAPIUtil { public static ResultType getPaymentResultFromStatusOrPaymentResponse(TerminalAPIResponse terminalApiResponse) { if (terminalApiResponse != null && terminalApiResponse.getSaleToPOIResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getPaymentResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getPaymentResponse().getResponse() != null) { return terminalApiResponse.getSaleToPOIResponse().getPaymentResponse().getResponse().getResult(); } } else if (terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody().getPaymentResponse() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody().getPaymentResponse().getResponse() != null) { return terminalApiResponse.getSaleToPOIResponse() .getTransactionStatusResponse() .getRepeatedMessageResponse() .getRepeatedResponseMessageBody() .getPaymentResponse() .getResponse() .getResult(); } } } return ResultType.FAILURE; }  }
TerminalAPIUtil { public static ResultType getPaymentResultFromStatusOrPaymentResponse(TerminalAPIResponse terminalApiResponse) { if (terminalApiResponse != null && terminalApiResponse.getSaleToPOIResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getPaymentResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getPaymentResponse().getResponse() != null) { return terminalApiResponse.getSaleToPOIResponse().getPaymentResponse().getResponse().getResult(); } } else if (terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody().getPaymentResponse() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody().getPaymentResponse().getResponse() != null) { return terminalApiResponse.getSaleToPOIResponse() .getTransactionStatusResponse() .getRepeatedMessageResponse() .getRepeatedResponseMessageBody() .getPaymentResponse() .getResponse() .getResult(); } } } return ResultType.FAILURE; }  static ResultType getStatusResultFromStatusResponse(TerminalAPIResponse terminalApiResponse); static ErrorConditionType getErrorConditionForPaymentFromStatusResponse(TerminalAPIResponse terminalApiResponse); static ErrorConditionType getErrorConditionForPaymentResponse(TerminalAPIResponse terminalApiResponse); static ErrorConditionType getErrorConditionForStatusFromStatusResponse(TerminalAPIResponse terminalApiResponse); static ResultType getPaymentResultFromStatusOrPaymentResponse(TerminalAPIResponse terminalApiResponse); static String getReceiptFromPaymentResponse(TerminalAPIResponse terminalApiResponse); static String getReceiptFromStatusResponse(TerminalAPIResponse terminalApiResponse); static String formatTerminalAPIReceipt(List<PaymentReceipt> paymentReceipts); static String getErrorMessageForNonAuthorizedPosPayment(TerminalAPIResponse terminalApiResponse); static String getErrorMessageByPosErrorCondition(ErrorConditionType errorCondition); }
TerminalAPIUtil { public static ResultType getPaymentResultFromStatusOrPaymentResponse(TerminalAPIResponse terminalApiResponse) { if (terminalApiResponse != null && terminalApiResponse.getSaleToPOIResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getPaymentResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getPaymentResponse().getResponse() != null) { return terminalApiResponse.getSaleToPOIResponse().getPaymentResponse().getResponse().getResult(); } } else if (terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse() != null) { if (terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody().getPaymentResponse() != null && terminalApiResponse.getSaleToPOIResponse().getTransactionStatusResponse().getRepeatedMessageResponse().getRepeatedResponseMessageBody().getPaymentResponse().getResponse() != null) { return terminalApiResponse.getSaleToPOIResponse() .getTransactionStatusResponse() .getRepeatedMessageResponse() .getRepeatedResponseMessageBody() .getPaymentResponse() .getResponse() .getResult(); } } } return ResultType.FAILURE; }  static ResultType getStatusResultFromStatusResponse(TerminalAPIResponse terminalApiResponse); static ErrorConditionType getErrorConditionForPaymentFromStatusResponse(TerminalAPIResponse terminalApiResponse); static ErrorConditionType getErrorConditionForPaymentResponse(TerminalAPIResponse terminalApiResponse); static ErrorConditionType getErrorConditionForStatusFromStatusResponse(TerminalAPIResponse terminalApiResponse); static ResultType getPaymentResultFromStatusOrPaymentResponse(TerminalAPIResponse terminalApiResponse); static String getReceiptFromPaymentResponse(TerminalAPIResponse terminalApiResponse); static String getReceiptFromStatusResponse(TerminalAPIResponse terminalApiResponse); static String formatTerminalAPIReceipt(List<PaymentReceipt> paymentReceipts); static String getErrorMessageForNonAuthorizedPosPayment(TerminalAPIResponse terminalApiResponse); static String getErrorMessageByPosErrorCondition(ErrorConditionType errorCondition); static final Logger LOGGER; }