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 get the order list by requesting a query to the API service using software methods.

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

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

In response, your system will receive the order data.

Parameters Transferred in the Query

You can transfer the filters as follows:

begin_date - invoice “from” date, with the format 01.01.2017
end_date - invoice “to” date, with the format 01.02.2017
paid - (bool) only paid orders
goods - (string or array) product's ID that is taken from the address bar when editing the product

In the begin_date – end_date interval, you can enter a time interval for a month or less.
If these values are not transmitted, then the data is given for the current day.
If the end date is not specified, then the current moment is taken for it.
If the dates make an interval of more than a month, then it is cut down to a month in a way that the end date remains the one that the user transferred (or the current one, if the user did not specify it), but the initial one is cut.
If you specify the parameter paid = true, you will get the invoices that have been paid at the specified time interval.

How Does It Work?

You call the GetOrdersWithGoods API function.

Your system will receive the result of the function performing and an array with order data in the result variable in response.

The data array will look as follows:

Array (
[0] => stdClass Object (
[id] => invoice number,
[first_name] => name
[last_name] => surname
[middle_name] => middle name
[email] => email
[phone] => telephone number
[city] => city
[country] => country
[address] => address
[region] => region
[postalcode] => postal code
[created] => date of creating the invoice
[pay_status] => invoice status
[paid] => date of paying the invoice
[type] => order type
[payway] => way of the payment
[comment] => comment on the invoice
[domain] => order domain
[link] => link to paying for the order page
[good_count] => the number of products in the order
[price] => product price
[is_recurrent] => Is the bill recurrent? true/false
[bill_sum_topay] => left to pay
[tag] => tag
[kupon] => used coupon
[utm] => stdClass Object
(
[medium] => channel utm-parameter (if exists)
[source] => source utm-parameter (if exists)
[campaign] => campaign utm-parameter (if exists)
[content] => advertisement utm-parameter (if exists)
[term] => key utm-parameter (if exists)
)

[items] => Array (
[0] => stdClass Object (
[id] => product identifier
[title] => product name
[sum] => the actual cost
[price] => product price from settings
[partners] => Array
(
[0] => stdClass Object
(
[partner_lvl] => affiliate program level
[partner_id] => partner’s ID
[partner_name] => partner’s login
[partner_fee] => partner’s fee
)

[1] => stdClass Object
(
[partner_lvl] => affiliate program level
[partner_id] => partner’s ID
[partner_name] => partner’s login
[partner_fee] => partner’s fee
)
)
)

[1] => stdClass Object (
[id] => product identifier
[title] => product name
[sum] => the actual cost
[price] => product price from settings
[partners] => Array
(
[0] => stdClass Object
(
[partner_lvl] => affiliate program level
[partner_id] => partner’s ID
[partner_name] => partner’s login
[partner_fee] => partner’s fee
)

[1] => stdClass Object
(
[partner_lvl] => affiliate program level
[partner_id] => partner’s ID
[partner_name] => partner’s login
[partner_fee] => partner’s fee
)
)
)
)
)

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

Example of Getting the Orders List in PHP

We retrieve the information about the orders from 01/01/2017 to 01/02/2017 for products with 1, 2, 3 id.

GetHash Function forms the hash to the transferred data.

CheckHash Function checks the hash to the service response.

// Login to 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 data array for transferring to the API.
$send_data = array(
    'begin_date' => '01.01.2017',
    'end_date' => '01.02.2017',
    'paid' => 'true', // only paid invoices or false
    'goods' => array(1, 2, 3) //products ID
);

// Forming the hash to the transmitted data.
$send_data['hash'] = GetHash($send_data, $user_rs);

//Calling the GetOrdersWithGoods function and decoding the received data.
$resp = json_decode(Send('http://username.justclick.io/api/getOrdersWithGoods', $send_data));

// Checking the service response.
if(!CheckHash($resp, $user_rs)){
	echo "Error! The response hash is not true!" ; print_r($resp);
	exit;
}

if($resp->error_code == 0){
	echo “Order information”;
	print_r($resp->result);
}
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...