Skip to content

Product_Create

Jacob McConnell edited this page Jun 10, 2014 · 2 revisions

You must specify your API username and password using the Twocheckout.apiusername & Twocheckout.apipassword class variables before calling a method in this class.

##Method

###create

Use to create a product.

####Arguments

  • hash Parameters
  • Hash containing create_product parameters. Parameters -> API Create Product

####Returns

Returns a TwocheckoutResponse object.

####Example Usage:

HashMap<String, String> params = new HashMap<String, String>();
params.put("name", "test");
params.put("price", "1.00");
params.put("vendor_product_id", "Test");
params.put("description", "Test Short Description");
params.put("long_description", "Test Long Description");
params.put("approved_url", "http://www.2checkout.com");
params.put("tangible", "1");
params.put("weight", "1.50");
params.put("handling", "1.00");
params.put("recurring", "1");
params.put("recurrence", "1 Month");
params.put("duration", "Forever");
TwocheckoutResponse result = TwocheckoutProduct.create(params);

Product product = TwocheckoutProduct.retrieve(result.getProductId());

####Example Response (toJson):

{
   "assigned_product_id" : "20",
   "product_id" : "4774544749",
   "response_code" : "OK",
   "response_message" : "Product successfully created"
}

Clone this wiki locally