Foren

CCAvenue Integration

Mohamed Saleem, geändert vor 8 Jahren.

CCAvenue Integration

Junior Member Beiträge: 37 Beitrittsdatum: 16.12.15 Neueste Beiträge
I have integrated CCAvenue Gateway in both 6.1 and 6.2 . It is working in 6.1 But it is not working in 6.2 . Please anyone help me soon.
thumbnail
Andrew Jardine, geändert vor 8 Jahren.

RE: CCAvenue Integration

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hi Mohamed,

Can you elaborate a little more on "not working"? Are you seeing exception in the logs? Can you explain how you are integrating it with 6.2? We need more details before we are able to help.
Mohamed Saleem, geändert vor 8 Jahren.

RE: CCAvenue Integration

Junior Member Beiträge: 37 Beitrittsdatum: 16.12.15 Neueste Beiträge
Thanks Andrew Jardine for Immediate response.
Actually I have integrated CCAvenue JSP_Kit to my portal. Till payment every thing is working properly that means after filling all the payment details and submitting no error is coming. But we are getting a response as null.

Below is the code of ReponseHandler.jsp.

encResp is coming null after payment or after cancel the request.

<%
String workingKey = "working key"; //32 Bit Alphanumeric Working Key should be entered here so that data can be decrypted.
String encResp= request.getParameter("encResp");
AesCryptUtil aesUtil=new AesCryptUtil(workingKey);
String decResp = aesUtil.decrypt(encResp);
StringTokenizer tokenizer = new StringTokenizer(decResp, "&");
Hashtable hs=new Hashtable();
String pair=null, pname=null, pvalue=null;
while (tokenizer.hasMoreTokens()) {
pair = (String)tokenizer.nextToken();
if(pair!=null) {
StringTokenizer strTok=new StringTokenizer(pair, "=");
pname=""; pvalue="";
if(strTok.hasMoreTokens()) {
pname=(String)strTok.nextToken();
if(strTok.hasMoreTokens())
pvalue=(String)strTok.nextToken();
hs.put(pname, pvalue);
}
}
}
%>
thumbnail
Andrew Jardine, geändert vor 8 Jahren.

RE: CCAvenue Integration

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hi Mohamed,

Can you help me understand what you mean by "integrated into the portal"? Remember, I have never used this tool before so I need to understand how you interacxt with it. For example,

Q1. Is there a library that you include in the classpath that gives you an API to call?

Q2. or is it just a service call? (REST, SOAP, etc?)

Q3. Are there log levels that you can increase (from there side) to see the transaction details?

Q4. What are you expecting for a result? just a message with the status or a full confirmation page to be displayed?

.. that sort of stuff. Take some time and detail out your solution for us emoticon
Mohamed Saleem, geändert vor 8 Jahren.

RE: CCAvenue Integration

Junior Member Beiträge: 37 Beitrittsdatum: 16.12.15 Neueste Beiträge
Hi Andrew Jardine,

I am using ready made CCAvenue integration API's. Using merchant login we can download the CCAvenue jsp Kit (from CCAvenue website).

It should be full confirmation Response page to be displayed.
thumbnail
Andrew Jardine, geändert vor 8 Jahren.

RE: CCAvenue Integration

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hi Mohamed,

Thanks for your answers. The part that I am still not clear on however is the "ResponseHandler.jsp". Where does this file live? Have you created it using a hook? Is it a view as part of a custom portlet you have created?

Unfortunately without understanding how the "JSP kit" is part of your solution... and what your solution looks like, it will be very difficult for us to help. What we need is something like this --

!! This is an Example of a more thorough explanation only !!

"I have am ecommerce website that uses CCSAvenue for the payment processing. The user will go through the usual purchase path of selecting items and placing them in their cart. We have written custom portlets to manage this feature. Upon checkout the user is taken to another custom portlet we created called the "Payment Processor Portlet". They enter their payment details and on the last step hit submit. The submit button triggers a portlet action URL for a action method called submit. To this method we pass all the payment details. We then use the CCA Avenue JSP kit to call the payment processing service like this

// insert your calling code here

The CCA Avenue will returns a response that is encrypted. The response should contain all the HTML that is used to display to the user the success/failure of the call. This is the code we used to decrypt the response

// insert response processing code here

The porblem is ... "


I realize that English might not be your first language but if you can take the time to outline the whole case in a little more detail it would probably make this go a little quicker emoticon
Mohamed Saleem, geändert vor 8 Jahren.

RE: CCAvenue Integration

Junior Member Beiträge: 37 Beitrittsdatum: 16.12.15 Neueste Beiträge
Hi Andrew,

Thanks for reply.

CCAvenue is a payment portal like paypal. We are integrated in ecommerce portal, to integrate we need a kit from CCAvenue using merchant login. In order to get the kit we need to register with CCAvenue, after registration they will give us merchant login credentials.
I have create a separate portlet for CCAvenue. In CCAvenue kit we will get three jsp files 1) ccavRequestHandler.jsp - used to send request to CCAvenue portal 2) ccavResponseHandler.jsp - used to get the response from the CCAvenue portal 3) dataForm.jsp - used for customer details which fetches the data from db and one jar file ccavutil.jar.

After adding the product in shopping cart when user click's on checkout button it will ask for payment gateway and after selecting CCAvenue it will redirect to CCAvenue page upon filling the bank details once user click on "Paynow" backed end we will get a response from the CCAvenue about the payment status which means whether the payment is successfull or not. But here I am getting a response as a null. Instead I should get the status about the payment.

Below is the code of 3 files

1) dataForm.jsp

&lt;%
/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
%&gt;

&lt;%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %&gt;
&lt;%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %&gt;
<portlet:renderurl var="responseURL">
<portlet:param name="jspPage" value="/html/ccavResponseHandler.jsp" />
</portlet:renderurl>

<portlet:renderurl var="requestURL">
<portlet:param name="jspPage" value="/html/ccavRequestHandler.jsp" />
</portlet:renderurl>

<portlet:defineobjects />





<aui:form method="post" name="customerData" action="<%=requestURL.toString()%>">

<aui:input name="Parameter Name:" />

<aui:input name="Parameter Value:" />
<p>Compulsory information</p>
<aui:input label="MerchentId" name="merchant_id" id="merchant_id" value="56242"></aui:input>
<aui:input name="order_id" value="Ord123"></aui:input>
<aui:input name="currency" value="INR" />
<aui:input name="amount" value="01.00" />
<aui:input name="redirect_url" value="<%=responseURL.toString() %>" />
<aui:input type="hidden" name="cancel_url" value="<%=responseURL.toString() %>" />
<aui:input type="hidden" name="language" id="language" value="EN" />
Billing Address(optional)
<aui:input type="hidden" name="billing_name" value="Pugalendhi" />
<aui:input type="hidden" name="billing_address" value="Bangalore" />
<aui:input type="hidden" name="billing_city" value="Bangalore" />
<aui:input type="hidden" name="billing_state" value="Karnataka" />
<aui:input type="hidden" name="billing_zip" value="560068" />
<aui:input type="hidden" name="billing_country" value="India" />
<aui:input type="hidden" name="billing_tel" value="7676020371" />
<aui:input name="billing_email" value="pugalendhi@esquareinfo.com" />
Shipping information(optional):
<aui:input type="hidden" name="delivery_name" value="Pugalendhi" />
<aui:input type="hidden" name="delivery_address" value="Bangalore" />
<aui:input type="hidden" name="delivery_city" value="Bangalore" />
<aui:input type="hidden" name="delivery_state" value="Karnataka" />
<aui:input type="hidden" name="delivery_zip" value="560068" />
<aui:input type="hidden" name="delivery_country" value="India" />
<aui:input type="hidden" name="delivery_tel" value="7676020371" />
<aui:button type="submit" value="ChekOut" />
</aui:form>


2) ccavRequestHandler.jsp

&lt;%
/*
   This is the sample Checkout Page JSP script. It can be directly used for integration with CCAvenue if your application is developed in JSP. You need to simply change the variables to match your variables as well as insert routines (if any) for handling a successful or unsuccessful transaction.
*/
%&gt;
&lt;%@ page import = "java.io.*,java.util.*,com.ccavenue.security.*" %&gt;


	<title>Sub-merchant checkout page</title>
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>


	&lt;%
	 String accessCode= "acess code";		//Put in the Access Code in quotes provided by CCAVENUES.
	 String workingKey = "working key";    //Put in the 32 Bit Working Key provided by CCAVENUES.  
	 Enumeration enumeration=request.getParameterNames();
	 String ccaRequest="", pname="", pvalue="";
	 while(enumeration.hasMoreElements()) {
	      pname = ""+enumeration.nextElement();
	      pvalue = request.getParameter(pname);
	      ccaRequest = ccaRequest + pname + "=" + pvalue + "&amp;";
	 }
	 AesCryptUtil aesUtil=new AesCryptUtil(workingKey);
	 String encRequest = aesUtil.encrypt(ccaRequest);
	%&gt;
	
	<form id="nonseamless" method="post" name="redirect" action="https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction"> 
		<input type="hidden" id="encRequest" name="encRequest" value="<%= encRequest %>">
		<input type="hidden" name="access_code" id="access_code" value="<%= accessCode %>">
		<script language="javascript">document.redirect.submit();</script>
	</form>
	
  



3) ccavResponseHandler.jsp

&lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%&gt;

&lt;%@ page import = "java.io.*,java.util.*,com.ccavenue.security.*" %&gt;


<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Response Handler</title>


	&lt;%
		String workingKey = "working key";		//32 Bit Alphanumeric Working Key should be entered here so that data can be decrypted.
		String encResp= request.getParameter("encResp");
		AesCryptUtil aesUtil=new AesCryptUtil(workingKey);
		String decResp = aesUtil.decrypt(encResp);
		StringTokenizer tokenizer = new StringTokenizer(decResp, "&amp;");
		Hashtable hs=new Hashtable();
		String pair=null, pname=null, pvalue=null;
		while (tokenizer.hasMoreTokens()) {
			pair = (String)tokenizer.nextToken();
			if(pair!=null) {
				StringTokenizer strTok=new StringTokenizer(pair, "=");
				pname=""; pvalue="";
				if(strTok.hasMoreTokens()) {
					pname=(String)strTok.nextToken();
					if(strTok.hasMoreTokens())
						pvalue=(String)strTok.nextToken();
					hs.put(pname, pvalue);
				}
			}
		}
	%&gt;
	<center>
		<font size="4" color="blue"><b>Response Page</b></font>
		<table border="1">
			&lt;%
				Enumeration enumeration = hs.keys();
				while(enumeration.hasMoreElements()) {
					pname=""+enumeration.nextElement();
					pvalue=""+ hs.get(pname);
			%&gt;
				<tbody><tr>
					<td>&lt;%= pname %&gt; </td>
					<td> &lt;%= pvalue %&gt; </td>
				</tr>
			&lt;%
				}
		%&gt;
		</tbody></table>
	</center>


thumbnail
Andrew Jardine, geändert vor 8 Jahren.

RE: CCAvenue Integration

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hi Mohamed,

Thanks very much for taking the time to provide a detailed response. This is MUCH better emoticon. I don't see anything glaringly wrong with what you wrote but there are a few changes that I would suggest we start with to clean it up and see if it makes a difference.

First things first. Portlets, on a page, even if there is only one are simply sections of the larger page so we don't include the page level makup (html, head, body). Those are found in the theme files - normally in the portal_normal.ftl/vm. So I would start by removing from each of the views --










I doubt that will change the result, but it will make your plugins more correct. Next thing to look at. Liferay is a portal but so much more. It is, in my mind, an application development platform. It has an incredibly rich API with tons of tools that can save you writing heaps of code. It takes time to learn and find all the tools but I highly suggest you spend some time to poke through the source. Any file with the name Util for example that is in the portal-service project is worth looking at. For example, you have in your ccaRequest.jsp --


Enumeration enumeration=request.getParameterNames();
String ccaRequest="", pname="", pvalue="";
while(enumeration.hasMoreElements()) {
          pname = ""+enumeration.nextElement();
          pvalue = request.getParameter(pname);
          ccaRequest = ccaRequest + pname + "=" + pvalue + "&amp;";
 }


which if I rad it correctly simply creates a string param1=value1&param2=value2&...&paramN-valueN. You can do the same in one line with the Liferay API.


HttpUtil.parameterMapToString( renderRequest.getParameterMap() );


The one thing I was going to ask you to check is whether or not that logic is actually working? Have you validated that the parameter string is in fact being created?

Last point. I would suggest converting this from JSP pages with all the view and logic to a separation whereby you create a custom portlet class with action handlers that handle the communication between the pages and the communication with CCAvenue. I can help guide you through this as well. Can you send me your portlet.xml file?