Sunday, February 9, 2014

Liferay-Konakart Integration

Liferay-Konakart Integration


This is post about integration Konakart shop functionality with Liferay.

Konakart version: 7.1.1.1
Liferay version: 6.1.1


I. Steps for base Installation:


1. Download clean Konakart ( http://www.konakart.com ) and Liferay ( https://www.liferay.com/ )

2. Install Konakart (into Konakart folder).

3. Go to the Konakart/custom folder.

4. Genarate KonakartStore and KonakartAdmin portlets with the following ant commands:

bin/kkant make_admin_liferay_portlet_war -DLR611=true -DnoAXIS=true

bin/kkant make_liferay_portlet_war -DLR611=true -DnoAXIS=true

(-DLR option specifies Liferay's version; -DnoAXIS option is to disable AXIS web services)

5. The konakart.war and konakartadmin.war files will be generated in Konakart/custom/portlet_war and Konakart/custom/admin_portlet_war folders.

6. Unzip liferay, and copy generated war files into liferay/deploy directory.

7. Startup Liferay, and konakart portlet will be deployed.



II. PayPal module integration:


1. Go to Konakart Administration portlet. Select Modules -> Payment -> Paypal.
2. Fill the PayPal configuration options:

Sort order of display: 1
PayPal Payment Zone: --none--
Callback username: admin@konakart.com
Callback Password: princess
Callback URL: http://[YOUR_DOMAIN]/konakart/PayPalCallback.action
Return URL: http://[YOUR_DOMAIN]/konakart/CheckoutFinished.action
Cancel URL: http://[YOUR_DOMAIN]/konakart/CatalogCheckoutExternalPaymentErrorPage.action
Test Mode: true
PayPal Id: [YOUR_EMAIL]
Transaction Currency: USD

3. Go to KonaKart Storefront portet. Try to buy product.

Possible issue:

Error 'There has been an unexpected problem Unfortunately we have encountered a malfunction.' when you try to pay with PayPal in KonaKart Storefront portet.

Links with the same issue:

http://www.konakart.com/forum/index.php/topic,1911.0.html
http://www.konakart.com/forum/index.php/topic,1910.msg7369.html
https://www.liferay.com/community/forums/-/message_boards/message/33936472

How To Fix:

1. Check your tomcat logs, if you have 'com.konakart.app.KKException: The String parameter called hostPort must be given a value. It cannot be set to null or be left empty.' exception.

If so, go to Konakart/custom/modules/src/com/konakart/bl/modules/payment directory, open PaymentMgr.java class, and add the following code at the beginning of getPaymentDetails method:

if (hostAndPort == null || hostAndPort.length() == 0) {
    hostAndPort = "YOUR DOMAIN HERE...";
}

Compile classes with ant 'compile_modules' command, and replace this class inside konakart/WEB-INF/lib/konakart.jar file.

This code will avoid the above exception.

2. Add the following code to your konakart/WEB-INF/web.xml file:


<filter>
<filter-name>struts2</filter-name>
<filterclass>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>



3. Change konakart/WEB-INF/jsp/CatalogCheckoutExternalPaymentBody.jsp file - replace
document.forms[0].submit(); code with document.getElementById('konakartPaymentForm').submit(); and specify the id for the form below. This will submit the paypal form to the PayPal instead of first form on the portal page.

4. Modify konakart/WEB-INF/classes/konakart-logging.properties file to enable DEBUG:



# Modules

log4j.logger.com.konakart.bl.modules.payment = DEBUG

log4j.logger.com.konakart.bl.modules.ordertotal = DEBUG

#log4j.logger.com.konakart.bl.modules.shipping = DEBUG

# Gateways
log4j.logger.com.konakart.actions.gateways = DEBUG
log4j.logger.com.konakart.actions.ipn = DEBUG

5. Restart Liferay, and try it again :)