Configuring Integration of Online Store and Offline Cashbox 1С-Bitrix
Customer places an order online and selects "pay on delivery". Courier delivers the order and prints a check on a mobile cashbox. The fiscal receipt is issued, but in Bitrix the order is still in "awaiting payment" status. Warehouse did not deduct items, accounting does not see the payment. Integration of online store with offline cashbox is not just about fiscalization, but also about order state synchronization.
Payment fiscalization scheme
According to 54-FZ, every settlement fact must be accompanied by a receipt. In Bitrix, the salescenter module and bitrix:salescenter.cashbox component implement integration with online cashboxes via OFD. For offline cashbox, the scheme is different: the receipt is issued by the cashbox device (АТОЛ, Эвотор, Штрих-М), and Bitrix must learn about this fact.
Two directions of data:
- Bitrix → cashbox: order data (items, amounts, VAT) for receipt formation
- Cashbox → Bitrix: receipt processing confirmation with number and fiscal mark
Integration via cashbox software API
Most modern cashbox systems have REST API or webhook. Эвотор provides Cloud API, АТОЛ has its own API for cloud cashbox.
On Bitrix side, when order status changes (e.g., "delivered to courier"):
AddEventHandler('sale', 'OnSaleStatusOrderChange', function(\Bitrix\Main\Event $event) {
$order = $event->getParameter('ENTITY');
$status = $order->getField('STATUS_ID');
if ($status !== 'DE') { // 'DE' = delivered, per your status scheme
return;
}
// Prepare cashbox data
$items = [];
foreach ($order->getBasket() as $item) {
$items[] = [
'name' => $item->getField('NAME'),
'quantity' => $item->getQuantity(),
'price' => $item->getPrice(),
'vat' => getVatTag($item->getField('VAT_RATE')),
];
}
// Send to cashbox system (example for Эвотор)
$evotorApi->sendReceipt($order->getId(), $items, $order->getPrice());
});
Receiving confirmation from cashbox
Cashbox sends webhook on successful receipt processing. Endpoint in Bitrix:
// /local/ajax/cashbox-callback.php
$data = json_decode(file_get_contents('php://input'), true);
if ($data['event'] === 'receipt.created') {
$orderId = $data['external_id'];
$fiscalSign = $data['fiscal_document_number'];
$order = \Bitrix\Sale\Order::load($orderId);
if ($order) {
// Fix payment
$payment = $order->getPaymentCollection()->current();
$payment->setField('PAID', 'Y');
$payment->setField('EXTERNAL_PAYMENT', $fiscalSign);
// Move order to correct status
$order->setField('STATUS_ID', 'F'); // Finalized
$order->save();
}
}
Inventory synchronization
Offline cashbox sale without binding to online order — for example, someone bought something in store that was simultaneously awaited for online order — should decrease inventory in b_catalog_product or b_catalog_store_product.
Two approaches:
- Via 1C: 1C accounts for all sales (online + offline) and synchronizes inventory in Bitrix by schedule
-
Direct cashbox integration with Bitrix: cashbox calls Bitrix API on each sale to deduct inventory via
CCatalogProduct::Update()or REST APIcatalog.product.update
VAT and rate tag
Error in VAT rate when sending to cashbox is violation of 54-FZ. VAT rates in Bitrix are stored in b_catalog_vat and b_sale_tax. When preparing receipt data, mapping is:
-
VAT_RATE = 20→ tag 1105 (VAT 20%) -
VAT_RATE = 10→ tag 1104 (VAT 10%) -
VAT_RATE = 0→ tag 1106 (VAT 0%) -
VAT_INCLUDE = N(no VAT) → tag 1107
What we configure
-
OnSaleStatusOrderChangehandler to send data to cashbox system - Webhook-endpoint to receive fiscalization confirmation
- Mapping of VAT rates between Bitrix and cashbox system
- Updating payment status and fiscal mark field in
b_sale_payment - Inventory synchronization mechanism for offline sales
- Logging of all cashbox API calls for diagnostics







