2Checkout Documentation


To pass a sale to your custom checkout page, you can use one of the methods provided in the TwocheckoutCharge class. This class provides you you with several methods to pass the sale and the buyer to 2Checkout.



Use automatically pass the buyer and sale to 2Checkout.


  • hash Parameters


Returns an HTML form from the parameters passed in and submits it automatically.

Example Usage: (Using Spark)

import spark.*;
import static spark.Spark.*;

  get(new Route("/") {
     public Object handle(Request request, Response response) {

         HashMap params = new HashMap();
         params.put("sid", "1817037");
         params.put("mode", "2CO");
         params.put("li_0_type", "product");
         params.put("li_0_name", "Example Product");
         params.put("li_0_price", "1.00");

         String form = TwocheckoutCharge.submit(params);

         form = "" + form + "";

         return form;

Example Response:

<form id="2checkout" action="" method="post">
<input type="hidden" name="sid" value="1817037" />
<input type="hidden" name="mode" value="2CO" />
<input type="hidden" name="li_0_type" value="product" />
<input type="hidden" name="li_0_name" value="Example Product" />
<input type="hidden" name="li_0_price" value="1.00" />
<script type="text/javascript">document.getElementById('2checkout').submit();</script>