Content
You will be able to transfer data between services without the help of programmers.
Learn more about integration via Zapier
You can change the status of the order, transfer the date of sending, the date of payment, and the tracking number.
The query is sent by the POST method in the URLencode format to the address: https://username.justclick.io/api/UpdateOrderStatus.
Parameters Transferred in the Query
- bill_id is the order number;
- status is the order status (sent means the order was sent by mail, paid means payment for the order was made, return means the customer returned the order, cancel means the order was canceled);
- date is the time of sending the order by mail or its payment, in seconds from January 1, 1970, the so-called UNIX times tamp (required forsent and paid statuses);
- rpo is the tracking number of the postal item (required for the sentstatus).
How Does It Work?
You transfer the order number, its status and additional data. The system changes the order status and add the given parameters to the order information.
Your system will receive the result of the function in JSON format in response. For more details, see the API Service Responses.
Example Of Updating the Order in PHP
In the example, we change the status of the 100000 order to “sent.” The tracking code is 10000000000000. The sending date is March 3, 2013 00:00, which corresponds to timestamp 1362254400.
GetHash Function forms the hash to the transferred data.
CheckHash Function checks the hash to the service response.
<?php // Login to the JustClick system $user_rs['user_id'] = 'username'; // The key for forming a hash. See API section (the link in the bottom right corner of the personal account) $user_rs['user_rps_key'] = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; // Forming the data array for transferring to the API $send_data = array( 'bill_id' => '100000', 'status' => 'sent', 'date' => '1362254400', 'rpo' => '10000000000000', ); // Forming the hash to the transmitted data $send_data['hash'] = GetHash($send_data, $user_rs); // Calling the UpdateOrderStatus API function and decoding the received data $resp = json_decode(Send('https://username.justclick.io/api/UpdateOrderStatus', $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 status is updated: {$resp->error_code}"; 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 } ?>