" dynamic="no"} Language Libraries | Developer Documentation | 2Checkout
Language

2Checkout Documentation

Link

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.

Method

link

Use automatically pass the buyer and sale to 2Checkout.

Arguments

  • hash Parameters

Returns

Purchase query string from the parameters passed in.

Example Usage: (Using Spark)

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

  get(new Route("/") {
     @Override
     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 link = TwocheckoutCharge.link(params);

         link = "" + link + "";

         return link;
    }
  });

Example Response:

https://www.2checkout.com/checkout/purchase?sid=1817037&mode=2CO&li_0_type=product&li_0_name=Example Product&li_0_price=1.00