Handling relay response using Java

Created by Richard Moore, Modified on Wed, 12 Apr 2023 at 12:02 PM by Richard Moore

The Relay Response sample code below shows how the merchant could respond upon receiving the transaction results from E-xact.  In this JSP example, the developer would change each merchant.com placeholder URL to the merchant's absolute URL equivalent.


<%@ page language="java" import="java.lang.*" %>
<!DOCTYPE html
   PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
 <title>Receipt</title>
 <script type="text/javascript" src="http://merchant.com/javascript.js" ></script>
 <link rel="stylesheet" href="http://merchant.com/style.css" type="text/css" />
</head>
<body>
 <h1>Merchant.com Online Store</h1>

 <h2><%=request.getParameter("x_response_reason_text")%></h2>

 <% if(request.getParameter("x_response_code") == '1') { %>
   <p>
     Your payment was processed successfully.
     Your order will be shipped in two business days.
     Here is your receipt.
   </p>
   <pre>
     <%=request.getParameter("exact_ctr")%>
   </pre>

   <% if(request.getParameter("exact_issname") != null) { %>
     <p>
       Issuer:     <%=request.getParameter("exact_issname")%><br/>
       Confirmation Number:     <%=request.getParameter("exact_issconf")%>
     </p>
   <% } %>

   <p>
     <% String track_url = "http://merchant.com/order_tracking/" + request.getParameter("x_invoice_num"); %>
     You can track it at <a href="<%= track_url%>"><%= track_url %></a>.
   </p>
 <% } %>

 <% if(request.getParameter("x_response_code") == '2') { %>
   <p>
     Your payment failed.
     Here is your receipt.
   </p>
   <pre>
     <%=request.getParameter("exact_ctr")%>
   </pre>
 <% } %>

 <% if(request.getParameter("x_response_code") == '3') { %>
   <p>
     An error occurred while processing your payment.
     Please try again later.
   </p>
 <% } %>

 <p>
   Return to <a href="http://merchant.com/home">home</a>.
 </p>
</body>
</html>

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article