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

Your system will receive a list of products in the orders in response, depending on the specified status in addition to its numbers. If the status is not specified, it will receive all orders.

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

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

  • email is the customer’s email, which you need to receive a list of orders and products from (required).
  • pay_status is the order status: paid – paid, waiting – expected, cancel – cancelled. Attention! If this parameter is not specified, all orders are displayed.

The one and only required field is the email field.

How Does It Work?

You transfer the customer’s email to GetBills API function.

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

The data array will look as follows:

$resp->result = array
(
   [№ 1 order] => array
       (
           [product code] => array
               (
                   [good_name] => Product 1 ID
                   [good_title] => Product 1 name
               )
       )
)
   [№ 2 order] => array
       (
           [product code] => array
               (
                   [good_name] => product 2 ID
                   [good_title] => product 2 name
               )
           [product code] => array
               (
                   [good_name] => product 3 ID
                   [good_title] => product 3 name
               )
       )
)

For example, shopping list:

 array
(
    [258367] => array
        (
            [12549] => array
                (
                    [good_name] => payment
                    [good_title] => payment for training
                )
        )
 
    [258368] => array
        (
            [13011] => array
                (
                    [good_name] => sales
                    [good_title] => sales in cinemas
                )
            [28363] => array
                (
                    [good_name] => 222
                    [good_title] => 222 ways
                )
        )
)

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

Example of Getting the Orders and Products List in PHP

In the example, we are searching for all orders for the customer with the [email protected] e-mail. Your 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 generating the signature. see "API" (bottom right of your JustClick personal account) => "API Key"
 $user_rs['user_rps_key'] = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
 
 // We form an array of data for transfer to the API
$send_data['email'] = '[email protected]'; // e-mail of the client for whom we receive a shopping list
$send_data['pay_status'] = 'paid'; // order status: paid - paid, waiting - pending, cancel - canceled.

// We form a signature for the transmitted data
$send_data['hash'] = GetHash($send_data, $user_rs);

// We call the function to receive a list of purchased products by the client's email and decode the received data
$resp = json_decode(Send('https://username.justclick.io/api/GetBills', $send_data));

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

if($resp->error_code == 0){

echo "Shopping list:";

print_r($resp->result);

}
else
	echo "Error code: {$resp->error_code} - description: {$resp->error_text}";

// =========== Functions for sending, receiving and processing a response ============

// Sending a request to the service API
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); // we output the answer to a variable

	$res = curl_exec($ch);

	curl_close($ch);
	return $res;
}

// Form the 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);
}

// Check the 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; // hash is correct
	else
		return false; // hash is not correct
}

Rate article

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