<%@ page language="java" session="true"%>
<%@ page import="java.util.Random" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.io.*" %>
<%@ page import="com.aciworldwide.commerce.gateway.plugins.e24PaymentPipe" %>
<%
String AliasCount = "1";
session.setAttribute("name",request.getParameter("name"));
session.setAttribute("city",request.getParameter("city"));
session.setAttribute("addr",request.getParameter("addr"));
session.setAttribute("state",request.getParameter("state"));
session.setAttribute("country",request.getParameter("country"));
session.setAttribute("postalcd",request.getParameter("postalcd"));
Random rnd = new Random(System.currentTimeMillis());
String trackId = String.valueOf(Math.abs(rnd.nextLong())); //Merchant must generate the Track Id
session.setAttribute("trackId",trackId);
String amount= String.valueOf(session.getAttribute("amount"));
String InstituteID=request.getParameter("InstituteID"); //Must be 1 for the merchant having only one bank(mandatory must be initilized)
File basePath = new File(pageContext.getServletContext().getRealPath("/"));
File usersFile = new File(basePath+"/WEB-INF/", "config.txt");
BufferedInputStream in = new BufferedInputStream(new FileInputStream(usersFile));
BufferedReader br = new BufferedReader (new FileReader(usersFile));
String str,resourcePath="",aliasName="",instituteName,instituteDesc,currency="";
String language="",action="",receiptURL=" ",errorURL="",headerCount,header;
int index =0;
while ((str = br.readLine()) != null)
{
if ( str.substring(0,str.indexOf("=")) .equals("tran.currency") )
currency=str.substring(str.indexOf("=")+1);
if ( str.substring(0,str.indexOf("=")) .equals("consumer.language") )
language=str.substring(str.indexOf("=")+1);
if ( str.substring(0,str.indexOf("=")) .equals("tran.action") )
action=str.substring(str.indexOf("=")+1);
if ( str.substring(0,str.indexOf("=")) .equals("merchant.receiptURL") )
receiptURL=str.substring(str.indexOf("=")+1);
if ( str.substring(0,str.indexOf("=")) .equals("merchant.errorURL") )
errorURL=str.substring(str.indexOf("=")+1);
if ( str.substring(0,str.indexOf("=")) .equals("gateway.headerCount") )
{
index=str.indexOf("=");
headerCount=str.substring(index+1, str.length());
if ( headerCount.equals(InstituteID) )
{
str=br.readLine();
resourcePath=str.substring(str.indexOf("=")+1);
while ((str = br.readLine()) != null)
{
if(str.substring(0,str.indexOf("=")) .equals("gateway.header"))
{
index=str.indexOf("=");
header=str.substring(index+1, str.length());
if(header.equals(AliasCount))
{
str=br.readLine();
aliasName=str.substring(str.indexOf("=")+1);
break;
}
}
}
}
}
}
System.out.println("\n%%%%%%%%%%% in The Action " + resourcePath);
//Following is the code which initilize e24PaymentPipe with proper value
e24PaymentPipe pipe=new e24PaymentPipe();
pipe.setResourcePath(resourcePath); //mandatory
System.out.println("\n %%%%%%%%% Hello I" + resourcePath ); //Sa
pipe.setAlias(aliasName); //mandatory
System.out.println("\n%%%%%%%%%% iN tHE aLIAS " + aliasName );
pipe.setAction( action ); //mandatory
System.out.println("\n%%%%%%%%%%% in The Action " + action);
pipe.setResponseURL(receiptURL ); //mandatory
System.out.println("\n%%%%%%%%%%%%%% In The ResponseUrl " + receiptURL);
pipe.setErrorURL(errorURL ); //mandatory
System.out.println("\n%%%%%%%%%%%%%%%%% In The SetErrorURL " + errorURL);
pipe.setAmt(amount); //mandatory
System.out.println("\n%%%%%%%%%%%%%%%%%% In The Amount " + amount);
pipe.setCurrency(currency);
pipe.setLanguage(language);
pipe.setTrackId(trackId);
System.out.println("HEllo It is The Result " + pipe.getResult());
System.out.println("HEllo It is The Result " + pipe.getDebugMsg());
System.out.println("HEllo It is The Result " + pipe.getAuth());
System.out.println("HEllo It is The Result " + pipe.getRef());
System.out.println(pipe.getWebAddress()+":::"+pipe.getRedirectContent());
pipe.setUdf5("This is sample UserDefined Udf5");
System.out.println("hello i am pipe performance " + pipe.performPaymentInitialization());
System.out.println("paymend iddddd " + pipe.SUCCESS + " sfaaaaaaaaag");
if(pipe.performPaymentInitialization() != pipe.SUCCESS)
{
out.println("Error sending Payment Initialization Request: ");
response.sendRedirect(response.encodeRedirectURL("HostedPaymentError.jsp?ErrorText= :: "+pipe.getErrorMsg()+" ### Error sending Payment Initialization Request: ####"+ "@@@"+pipe.getPaymentPage()));
}
else
{
String PaymentID = pipe.getPaymentId();
//out.println("Error sending Payment Initialization Request: ");
String payURL = pipe.getPaymentPage();
response.sendRedirect(response.encodeRedirectURL( payURL + "?PaymentID=" + PaymentID ));
}
%>