Sending carts and displaying the game

Steps and examples to send shopping carts and display the game.

Java integration

Files location and description

java/luckycart.jar: the Java library
java/lc_plugin_sample.jsp: an example of use
java/ the library dependencies
java/ library documentation

Integration steps

1. Library installation

Copy the library luckycart.jar and its its dependencies (contained in, into the lib directory of your web or server application.

Be careful not to duplicate libraries. It is possible that a log4, commons-logging or commons-codec version is already installed on your application server.

2. Library inclusion

Modify the order confirmation page code in order to include the library

// Include LC library
import com.luckycart.client.LuckyCart;
import com.luckycart.client.domain.*;

3. Library initialisation and data sending

Always in the order confirmation page code

// Create a LuckyCart object with your key and secret
LuckyCart luckyCart = LuckyCart.builder().setKey("key").setSecret("secret").createLuckyCart();

// Create a LuckyCartTransaction object
// Assuming data from the site are store in a customer and cart object. 
LuckyCartTransaction transaction = new LuckyCartTransaction();
// mandatory data
  new LuckyCartProduct(cart.products[0].getId(), cart.products[0].getHt(),
    cart.products[0].getTtc(), cart.products[0].getQty()),
  new LuckyCartProduct(cart.products[1].getId(), cart.products[1].getHt(),
    cart.products[1].getTtc(), cart.products[1].getQty())

// You can add more transaction information by overriding the LuckyCartTransaction class

// Sends the request to LC servers
LuckyCartPluginResponse pluginResponse = luckyCart.plugin(transaction);

4. Game display

Completed by positioning the following containers on the order confirmation page:

<!-- Add this div tag anywhere in the order confirmation page to render the game plugin -->
<% out.println(pluginResponse.getGamediv()); %>
<!-- Add this script tag at the bottom of the page (in order not to interfere with page loading) -->
<% out.println(pluginResponse.getScript()); %>

5. Sending additional data

The LuckyCartTransaction class contains predefined mandatory and optional attributes.

If required, it is possible to send additional information for each cart by overloading the LuckyCartTransaction class according to the following method:

public class MyCompanyLuckyCartTransaction extends LuckyCartTransaction
    private String myExtraInfo;
    public String getMyExtraInfo() {
        return myExtraInfo;

    public void setMyExtraInfo(String myExtraInfo) {
        this.myExtraInfo = myExtraInfo;