Language

2Checkout Documentation

Create Option

The create_option call is used to create a new product option.

URL: https://www.2checkout.com/api/products/create_option

HTTP Method: POST


Input Parameters

Parameter Description
option_name Name of new product option. Required.
option_value_name Name of option value. Multiples allowed but must equal number of option_value_surcharges supplied (&option_value_name=xxxxxxxx&option_value_name=yyyyyyyyy). Required.
option_value_surcharge Amount of option value. Multiples allowed but must equal number of option_value_names supplied (&option_value_surcharge=xxxxxxxx&option_value_surcharge=yyyyyyyyy). Required.

Data Returned

Parameter Description
response_code Tells the user whether or not the operation was successful.
response_message Tells the user why the operation was or was not successful.
option_id ID assigned to the option by 2Checkout.

Example API Call

Twocheckout::username('APIuser1817037');
Twocheckout::password('APIpass1817037');

$args = array(
    'option_name' => 'Example Option',
    'option_value_name' => 'Example Option Value Name',
    'option_value_surcharge' => 1.00
);
$option = Twocheckout_Option::create($args);

Twocheckout::API.credentials = { :username => 'APIuser1817037', :password => 'APIpass1817037' }

new_option = Twocheckout::Option.create({:option_name => "test option", :option_value_name => "test option value", :option_value_surcharge => 1.00})
option.delete!
args = {
    option_name: "test option",
    option_value_name: "value name",
    option_value_surcharge: "0.01"
};

tco.productOptions.create(args, function (error, data) {
    if (error) {
        console.log(error);
    } else {
        console.log(data.response_code);
    }
});
twocheckout.Api.credentials({'username':'APIuser1817037', 'password':'APIpass1817037'})

params = {
    'option_name': 'Example Option',
    'option_value_name': 'Test',
    'option_value_surcharge': 1.00
    }

result = twocheckout.Option.create(params)
var ServiceObject = new OptionService();
var ArgsObject = new OptionCreateServiceOptions();
ArgsObject.option_name = "Test Option";
ArgsObject.option_value_name = "Test Opiton Value";
ArgsObject.option_value_surcharge = (decimal)2.00;

var result = ServiceObject.Create(ArgsObject);
HashMap params = new HashMap();
params.put("option_name", "test");
params.put("option_value_name", "test");
params.put("option_value_surcharge", "1.00");

TwocheckoutResponse result = TwocheckoutOption.create(params);
curl -X POST https://www.2checkout.com/api/products/create_option \
    -H 'Accept: application/json' -u 'username:password' \
    -d 'option_name=test' -d 'option_value_name=red' -d 'option_value_surcharge=1.00' \
    -d 'option_value_name=blue' -d 'option_value_surcharge=1.00'

Example Successful Response

    {
       "option_id" : "1234567890",
       "response_code" : "OK",
       "response_message" : "Option created successfully"
    }

Common Error Codes

Code Description
PARAMETER_MISSING Required parameter missing:
PARAMETER_INVALID Invalid value for parameter: