@Test public void testFormatTerminalAPIReceipt() throws IOException { TerminalAPIResponse terminalAPIResponse = createResponseFromFile(TEST_RESPONSE_DIR+"SaleToPOIResponseStatusResponseWithReceipt.json"); String formattedReceipt = TerminalAPIUtil.formatTerminalAPIReceipt(terminalAPIResponse.getSaleToPOIResponse() .getTransactionStatusResponse() .getRepeatedMessageResponse() .getRepeatedResponseMessageBody() .getPaymentResponse() .getPaymentReceipt()); assertNotNull(formattedReceipt); assertTrue(formattedReceipt.contains("table class")); }
public static String formatTerminalAPIReceipt(List<PaymentReceipt> paymentReceipts) { String formattedHtml = "<table class='terminal-api-receipt'>"; for (PaymentReceipt paymentReceipt : paymentReceipts) { if (paymentReceipt.getDocumentQualifier() == DocumentQualifierType.CUSTOMER_RECEIPT) { for (OutputText outputText : paymentReceipt.getOutputContent().getOutputText()) { Map<String, String> map = Splitter.on("&").withKeyValueSeparator('=').split(outputText.getText()); formattedHtml += "<tr class='terminal-api-receipt'>"; if ((map.get("name") != null)) { formattedHtml += "<td class='terminal-api-receipt-name'>" + map.get("name") + "</td>"; } else { formattedHtml += "<td class='terminal-api-receipt-name'>&nbsp;</td>"; } if (map.get("value") != null) { formattedHtml += "<td class='terminal-api-receipt-value' align='right'>" + map.get("value") + "</td>"; } else { formattedHtml += "<td class='terminal-api-receipt-value' align='right'>&nbsp;</td>"; } formattedHtml += "</tr>"; } } } formattedHtml += "</table>"; try { formattedHtml = URLDecoder.decode(formattedHtml, "UTF-8"); } catch (UnsupportedEncodingException e) { LOGGER.debug("Exception in receipt generation " + e.getMessage()); } return formattedHtml; }
TerminalAPIUtil { public static String formatTerminalAPIReceipt(List<PaymentReceipt> paymentReceipts) { String formattedHtml = "<table class='terminal-api-receipt'>"; for (PaymentReceipt paymentReceipt : paymentReceipts) { if (paymentReceipt.getDocumentQualifier() == DocumentQualifierType.CUSTOMER_RECEIPT) { for (OutputText outputText : paymentReceipt.getOutputContent().getOutputText()) { Map<String, String> map = Splitter.on("&").withKeyValueSeparator('=').split(outputText.getText()); formattedHtml += "<tr class='terminal-api-receipt'>"; if ((map.get("name") != null)) { formattedHtml += "<td class='terminal-api-receipt-name'>" + map.get("name") + "</td>"; } else { formattedHtml += "<td class='terminal-api-receipt-name'>&nbsp;</td>"; } if (map.get("value") != null) { formattedHtml += "<td class='terminal-api-receipt-value' align='right'>" + map.get("value") + "</td>"; } else { formattedHtml += "<td class='terminal-api-receipt-value' align='right'>&nbsp;</td>"; } formattedHtml += "</tr>"; } } } formattedHtml += "</table>"; try { formattedHtml = URLDecoder.decode(formattedHtml, "UTF-8"); } catch (UnsupportedEncodingException e) { LOGGER.debug("Exception in receipt generation " + e.getMessage()); } return formattedHtml; } }
TerminalAPIUtil { public static String formatTerminalAPIReceipt(List<PaymentReceipt> paymentReceipts) { String formattedHtml = "<table class='terminal-api-receipt'>"; for (PaymentReceipt paymentReceipt : paymentReceipts) { if (paymentReceipt.getDocumentQualifier() == DocumentQualifierType.CUSTOMER_RECEIPT) { for (OutputText outputText : paymentReceipt.getOutputContent().getOutputText()) { Map<String, String> map = Splitter.on("&").withKeyValueSeparator('=').split(outputText.getText()); formattedHtml += "<tr class='terminal-api-receipt'>"; if ((map.get("name") != null)) { formattedHtml += "<td class='terminal-api-receipt-name'>" + map.get("name") + "</td>"; } else { formattedHtml += "<td class='terminal-api-receipt-name'>&nbsp;</td>"; } if (map.get("value") != null) { formattedHtml += "<td class='terminal-api-receipt-value' align='right'>" + map.get("value") + "</td>"; } else { formattedHtml += "<td class='terminal-api-receipt-value' align='right'>&nbsp;</td>"; } formattedHtml += "</tr>"; } } } formattedHtml += "</table>"; try { formattedHtml = URLDecoder.decode(formattedHtml, "UTF-8"); } catch (UnsupportedEncodingException e) { LOGGER.debug("Exception in receipt generation " + e.getMessage()); } return formattedHtml; }  }
TerminalAPIUtil { public static String formatTerminalAPIReceipt(List<PaymentReceipt> paymentReceipts) { String formattedHtml = "<table class='terminal-api-receipt'>"; for (PaymentReceipt paymentReceipt : paymentReceipts) { if (paymentReceipt.getDocumentQualifier() == DocumentQualifierType.CUSTOMER_RECEIPT) { for (OutputText outputText : paymentReceipt.getOutputContent().getOutputText()) { Map<String, String> map = Splitter.on("&").withKeyValueSeparator('=').split(outputText.getText()); formattedHtml += "<tr class='terminal-api-receipt'>"; if ((map.get("name") != null)) { formattedHtml += "<td class='terminal-api-receipt-name'>" + map.get("name") + "</td>"; } else { formattedHtml += "<td class='terminal-api-receipt-name'>&nbsp;</td>"; } if (map.get("value") != null) { formattedHtml += "<td class='terminal-api-receipt-value' align='right'>" + map.get("value") + "</td>"; } else { formattedHtml += "<td class='terminal-api-receipt-value' align='right'>&nbsp;</td>"; } formattedHtml += "</tr>"; } } } formattedHtml += "</table>"; try { formattedHtml = URLDecoder.decode(formattedHtml, "UTF-8"); } catch (UnsupportedEncodingException e) { LOGGER.debug("Exception in receipt generation " + e.getMessage()); } return formattedHtml; }  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 String formatTerminalAPIReceipt(List<PaymentReceipt> paymentReceipts) { String formattedHtml = "<table class='terminal-api-receipt'>"; for (PaymentReceipt paymentReceipt : paymentReceipts) { if (paymentReceipt.getDocumentQualifier() == DocumentQualifierType.CUSTOMER_RECEIPT) { for (OutputText outputText : paymentReceipt.getOutputContent().getOutputText()) { Map<String, String> map = Splitter.on("&").withKeyValueSeparator('=').split(outputText.getText()); formattedHtml += "<tr class='terminal-api-receipt'>"; if ((map.get("name") != null)) { formattedHtml += "<td class='terminal-api-receipt-name'>" + map.get("name") + "</td>"; } else { formattedHtml += "<td class='terminal-api-receipt-name'>&nbsp;</td>"; } if (map.get("value") != null) { formattedHtml += "<td class='terminal-api-receipt-value' align='right'>" + map.get("value") + "</td>"; } else { formattedHtml += "<td class='terminal-api-receipt-value' align='right'>&nbsp;</td>"; } formattedHtml += "</tr>"; } } } formattedHtml += "</table>"; try { formattedHtml = URLDecoder.decode(formattedHtml, "UTF-8"); } catch (UnsupportedEncodingException e) { LOGGER.debug("Exception in receipt generation " + e.getMessage()); } return formattedHtml; }  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; }