To integrate with other services and applications, we recommend setting up integration via Zapier.
You will be able to transfer data between services without the help of programmers.
Learn more about integration via Zapier

You can create orders in your shop by sending a query to the API service using software methods.

You can form one order but with several products for each customer once using the function. Products should already be present in your shop in JustClick.

The query is sent by the POST method in the URLencode format to the address:   https://username.justclick.io/api/CreateOrder.

Where username is the login of the user in the system, as well as their domain of the third level in the JustClick service.

Parameters Transferred in the Query

  • goods are the data array on ordered products. It consists of pairs of product IDs, product price:
    • good_name is the product ID in the JustClick system;
    • good_sum is the product price in this order. It may differ from the price indicated in the store. If this parameter is left out, the product price from the shop settings is taken;
  • bill_first_name is the customer’s name;
  • bill_surnameis the customer’s surname;
  • bill_middle_name is the customer’s middle name;
  • bill_emailis the customer’s email;
  • bill_phoneis the customer’s telephone number;
  • bill_country is the country of delivery;
  • bill_region is the delivery region;
  • bill_city is the city of the customer’s residence;
  • bill_address is the delivery address;
  • bill_postal_code is the postal code;
  • bill_kupon is the discount coupon (as in the shop settings);
  • bill_tag is an unspecified order marker (tag);
  • bill_comment is the comment on the order,
  • bill_ip is the customer’s IP;
  • bill_timer_kill isthe time of the invoice cancellation (true – the time is taken from the product settings; false – the invoice will not be auto-cancelled; the time in the UNIX timestamp format – the account will be cancelled at this time);
  • bill_created is the time when the order was created in the UNIX timestamp format;
  • bill_domain is the domain of accepting the order;
  • utm [utm_medium]is the channel utm-parameter (optional);
  • utm [utm_source]is the source utm-parameter (optional);
  • utm [utm_campaign]is the campaign utm-parameter (optional);
  • utm [utm_content] is the advertisement parameter (optional);
  • utm [utm_term]is the key utm-parameter (optional);
  • utm [aff_medium]is the channel affiliate parameter (optional);
  • utm [aff_source]is the source affiliate parameter (optional);
  • utm [aff_campaign]is the campaign affiliate parameter (optional);
  • utm [aff_content] is the advertisement affiliate parameter (optional);
  • utm [aff_term]is the key affiliate parameter (optional);

bill_email and goods, and in it good_name fields are required. bill_first_name, bill_surname, bill_country, bill_city, bill_address are also required for the physical goods to be sent by mail. The other parameters are up to you.

If you want to pass information that the client has come from a partner, pass 2 parameters utm [utm_medium] and utm [utm_source] as follows:

 'utm[utm_medium]' => 'affiliate', // only 'affiliate' and nothing else
 'utm[utm_source]' => 'username',// partner’s login in justclick system

You also can use affiliate utm_marks (utm [aff_ …]). In this case, the specified partner must necessarily be a member of the affiliate program. The data of the tag (utm [aff_ …]) will be displayed only in the partner’s cabinet.

In the bill_domain parameter, we recommend using your JustClick system website address or the address of the linked site without specifying the protocol (http://). If you don’t put anything in this parameter, then when you follow the link to the order payment page $resp->result[‘link’], you will need to check the transition to the necessary domain after calling GetOrderDetails by yourself. Otherwise, this link would already contain the protocol and domain necessary for use, for example:

header("Location: " . $resp->result['link']);

How Does It Work?

You create an order in your system and transfer the data using CreateOrder API function.

Your system will receive the result of the function performing and the number of the created order in the result->bill_id variable in response.

The response is coded in JSON format. For more details, see the API Service Responses.

Example Of Creating a New Order in PHP

In the example, we add an order with two products. The login in the system is “username”.

GetHash Function forms the hash to the transferred data.

CheckHash Function checks the hash to the service response.

// Login in the JustClick system
 $user_rs['user_id'] = 'username';
  // The key for forming a hash. See API section (the link in the right bottom corner of the personal account)
 $user_rs['user_rps_key'] = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
 
 // Forming the array of bought goods for transferring to the API
$good1 = array(
	'good_name' => 'invoice', // product ID in the JustClick system
	'good_sum' => 1500, // the product price 
	);
$good2 = array(
	'good_name' => 'sales', // product ID in the JustClick system
	// You do not have to set the price of the product. The price is got from the settings, then
	);
 
 // Forming the data array for transferring to the API
 $send_data = array(
 'goods' => array ($good1, $good2),
 'bill_first_name' => "Name",
 'bill_surname' => "Surname",
 'bill_middle_name' => "Middle Name",
 'bill_email' => "[email protected]",
 'bill_phone' => "+39287777777",
 'bill_country' => "USA",
 'bill_region' => "New York",
 'bill_city' => "New York",
 'bill_address' => "Wall St.",
 'bill_postal_code' => "345678", // postal code
 'bill_kupon' => "skidka50", // discount coupon (as in the shop settings)
 'bill_tag' => 'AdWords', // free order tag
 'bill_comment' => 'in a beautiful box', // comment on product
 'bill_ip' => '192.168.0.1', // customer’s IP
 'bill_timer_kill' => true, // is there a limit on payment order time, where:
// false or 0 means the invoice is not automatically canceled;
// true or 1 means the invoice is automatically cancelled according to the product settings;
// transferring time in unixtime format means the invoice auto-cancelling is set for this time.
 'bill_created' => 1291001819, // the order creation time UNIX timestamp
 'bill_domain' => 'www.shop.io', // order domain
 'utm[utm_medium]' => 'cpc',
 'utm[utm_source]' => 'direct',
 'utm[utm_campaign]' => 'my campaign',
 'utm[utm_content]' => 'content_123',
 'utm[utm_term]' => 'my_label',
 );
 
// Forming the hash to the transmitted data
$send_data['hash'] = GetHash($send_data, $user_rs);
 
// Calling the CreateOrder function and decoding the received data
$resp = json_decode(Send('https://username.justclick.io/api/CreateOrder', $send_data));
 
// Checking the service response
if(!CheckHash($resp, $user_rs)){
	echo "Error! The response hash is not true!";
	exit;
}
 
if($resp->error_code == 0)
	echo "The order is created {$resp->result->bill_id}. Service response: {$resp->error_text}";
else
	echo "Error code:{$resp->error_code} - description: {$resp->error_text}";
 
// =========== Functions of sending, receiving and processing a response ============
 
// Sending the Query to the API service
function Send($url, $data)
{
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // outputting the response to the variable
 
	$res = curl_exec($ch);
 
	curl_close($ch);
	return $res;
}
 
// Forming the transferred to the API data hash
function GetHash($params, $user_rs) {
	$params = http_build_query($params);
	$user_id = $user_rs['user_id'];
	$secret = $user_rs['user_rps_key'];
	$params = "$params::$user_id::$secret";
	return md5($params);
}
 
// Checking the received response hash
function CheckHash($resp, $user_rs) {
	$secret = $user_rs['user_rps_key'];
	$code = $resp->error_code;
	$text = $resp->error_text;
	$hash = md5("$code::$text::$secret");
	if($hash == $resp->hash)
		return true; // the hash is correct
	else
		return false; // the hash is not correct
}

 

Rate article

1 star2 stars3 stars4 stars5 stars (No votes)
Loading...