To get order data placed on the CS-Cart Add-on Market, you need to configure a Webhook called License number issued on the Administration Webhooks page.

Enter the URL in the relevant field to receive the numbers of the paid orders (order IDs) with issued licenses. The data is sent as JSON and contains only one value — the number of the order.

You can get all the necessary order details using our standard API.

By using API (GET method /orders/:id) you will additionally get external_id and license_number

External ID value can be found in products[].extra[].external_id. The issued license number is sent to products[]. extra[].license_number.

How do I get an API key?

For the integration of your external source with our Add-on Market an API key is also required. To get it, please follow the steps below:

  • Go to Developer's administrators Developer's administrators menu.
  • Go to the API access tab and select the user you want to give access to.
  • Press Generate a new API key button.

To receive data from the Marketplace:

  1. Get a new order number.
  2. Connect to marketplace.cs-cart.com.
  3. Get order data.
  4. Prepare data before import.
  5. Place an order.

1. Get a new order number

$result = new OperationResult();
if (!empty($_REQUEST['order_id'])) {
 $result = fn_get_order_from_marketplace($_REQUEST['order_id']);
} else {
 $result->addError('order', __('error_empty_order')); }
// Notifications (errors/successful import)
 $result->showNotifications();
// Error logging


Example of the fn_get_order_from_marketplace function used above:

function fn_get_order_from_marketplace(order_id) {
try {
   $order = new Orders($params);
   $order_info = $order->getOrder("orders/{$order_id}");
   $order_id = $order->placeOrder($order_info);
   if (!empty($order_id)) {
       $result->setMessages([
           'message' => __('order_has_been_imported', [
               '[url]' => fn_url("orders.details&order_id=$order_id", AREA),
               '[order_id]' => $order_id
           ])
       ]);
       $result->setSuccess(true);
   }
} catch (Exception $e) {
  $result->setErrors(['error' => $e->getMessage()]);
  // Error logging
} catch (\Throwable $e) {
  $result->setErrors(['error' => $e->getMessage()]);
  // Error logging
} finally {
  return $result;
}
return $result;

2. Connect to marketplace.cs-cart.com

The connection to the Marketplace is operated via the Orders class.

Orders class description:

public function __construct($params)
{
  if (empty($params['login'])) {
      throw new Exception(__('error_empty_login'));
  }
  if (empty($params['access_token'])) {
      throw new Exception(__('error_empty_access_token'));
  }
  $this->headers = [
     'Accept: application/json',
     'Authorization: Basic ' . base64_encode($params['login'] . ':' . $params['access_token'])
  ];
}


Class parameters:

new Orders($params); 

$params — an array with data minimally required for connection:

$params['login'] and $params['access_token'] 

access_token — the access key that can be found in the user's data on the vendor's control panel on marketplace.cs-cart.com 

3. Get order data: getOrder function 

function getOrder($url, $data) {
if (empty($url)) {
    throw new Exception(__('error_empty_url'));
}
$order_data = Http::get(
    self::API_URL . $url,
    $data,
    [
        'headers' => $this->headers,
        'connection_timeout' => self::DEFAULT_CONNECTION_TIMEOUT,
    ]
);
$order_data = json_decode($order_data, true);
if (Http::getError()) {
    throw new Exception(Http::getError());
}
try {
    $order_data = $this->prepareOrderData($order_data);
} catch (Exception $e) {
    throw new Exception($e->getMessage());
}
return $order_data;
}

4. Preparing the data

prepareOrderData($data_from_getOrder)

Prepare the data before importing the order, because its structure may differ from the one used on marketplace.cs-cart.com.

5. Placing an order on your resource

placeOrder(data_from_prepareOrderData)


Order statuses

Here you can find a list of order statuses that are used on the Marketplace:

  • P — Paid
  • C — Complete
  • O — Open
  • F — Failed
  • D — Declined
  • B — Backordered
  • I — Canceled
  • A — Awaiting call
  • E — Returned
  • H — External (when placing an order via API)
  • J — Awaiting payment