Full‑Cycle Return Integration Between 1C and Bitrix
We develop and integrate return processing systems that automate the exchange between Bitrix and 1C. When a customer initiates a return on the site, the back‑office must create several linked documents: a reversal of the sale, a discrepancy report, and an adjusting invoice. If Bitrix and 1C work independently—all this is done manually, and the probability of stock and settlement discrepancies grows every week, impacting profitability.
We implement return integration as a separate circuit within the 1C–Bitrix exchange, because the standard sale module exchanges orders, not corrective documents. Those must be described separately and explicitly. With over 10 years of experience, we have delivered hundreds of such integrations for stores of various sizes.
How a Return Works in Bitrix
A return in Bitrix is an object of the class \Bitrix\Sale\Payment\PaymentReturn in the context of a payment or \Bitrix\Sale\Shipment\ShipmentReturn in the context of a shipment. From the database perspective, records are stored in:
-
b_sale_order_return — return request
-
b_sale_order_return_item — return items
-
b_sale_order_return_shipment — relation to shipment
Return statuses (RETURN_STATUS): NEW, PROCESSED, COMPLETED, REJECTED. The trigger for transfer to 1C should be the transition to COMPLETED—data may change before that.
Exchange Schema
The standard bitrix.1c module transfers orders via sale.order in CommerceML 2. Returns are not described in CommerceML—this is a custom node that must be added to the schema yourself.
Bitrix: return becomes COMPLETED
→ OnSaleReturnComplete event handler
→ Build XML node <Возврат>
→ Write to exchange queue (b_agent / custom table)
→ Next exchange session with 1C
→ 1C creates document "Return of goods from buyer"
→ Confirmation from 1C → return status updated
Use the OnSaleReturnComplete event from the sale module:
\Bitrix\Main\EventManager::getInstance()->addEventHandler(
'sale',
'OnSaleReturnComplete',
function (\Bitrix\Main\Event $event) {
$return = $event->getParameter('ENTITY');
ReturnExchangeQueue::push($return->getId());
}
);
XML Structure for Transfer to 1C
1C works with CommerceML, but it is more convenient to transmit returns as a separate node inside <КоммерческаяИнформация>:
<Возврат>
<Ид>RETURN-{return_id}</Ид>
<НомерДокумента>R-{return_id}</НомерДокумента>
<Дата>{date}</Дата>
<ЗаказИд>{order_id}</ЗаказИд>
<Контрагент>
<Ид>{user_id}</Ид>
<Наименование>{user_name}</Наименование>
</Контрагент>
<Товары>
<Товар>
<Ид>{product_id}</Ид>
<Наименование>{product_name}</Наименование>
<Количество>{qty}</Количество>
<ЦенаЗаЕдиницу>{price}</ЦенаЗаЕдиницу>
<Сумма>{sum}</Сумма>
</Товар>
</Товары>
<СуммаВозврата>{total}</СуммаВозврата>
<Причина>{reason}</Причина>
</Возврат>
On the 1C side, a handler in the configuration reads this node and creates a document “Return of goods from buyer” correctly linked to the original sale via ЗаказИд.
Stock Synchronisation After a Return
After a successful return in 1C, stock is updated. It is important that Bitrix receives this signal and updates b_catalog_store_product. The standard stock exchange (offers.xml) will do this at the next session, but if sessions are infrequent, a separate request is needed:
// 1C calls URL after processing a return
ReturnSyncService::updateStocksFromReturn($returnId);
In updateStocksFromReturn there is a direct update of b_catalog_store_product via \Bitrix\Catalog\StoreProductTable with a call to \Bitrix\Catalog\StoreBatchService if lot recalculation is needed.
Reverse Status Transfer
After creating the document in 1C, a confirmation must be sent back to Bitrix:
| Situation |
Status in Bitrix |
| Document processed in 1C |
COMPLETED, flag 1C_SYNCED = Y |
| Items not in stock for reversal |
ERROR_1C, manager notified |
| Return rejected in 1C |
REJECTED, comment from 1C |
Updating the status on the Bitrix side:
$return = \Bitrix\Sale\OrderReturn::load($returnId);
$return->setField('STATUS', 'COMPLETED');
$return->setField('COMMENTS', '1C: document #' . $doc1cId);
$return->save();
Case Study: Wholesale Distributor, 150+ Returns per Month
The client—a distributor of construction chemicals. Returns came via two paths: through the dealer portal on the website and directly from logistics. The problem: the 1C accounting department did not see returns from the site, processed documents manually with a 3–5 day delay. This led to incorrect stock in Bitrix warehouses and conflicts in subsequent orders.
We implemented the following steps:
- The
OnSaleReturnComplete event writes the return to the local_1c_return_queue queue.
- An agent (every 10 minutes) builds XML and sends it to the 1C endpoint via an HTTP request to the standard exchange handler.
- 1C processes the document, updates stock, sends confirmation to
/api/1c/return-confirm/{returnId}.
- A webhook in Bitrix updates the return status and recalculates
b_catalog_store_product for affected SKUs.
| Metric |
Before |
After |
| Delay in reflecting return in 1C |
3–5 days |
< 15 minutes |
| Stock discrepancies (weekly check) |
8–12 items |
0–1 item |
| Manual operations in 1C |
~150/month |
< 5/month (exceptions) |
What's Included in the Work
- Analysis of the 1C configuration: document type “Return of goods from buyer”, fields linking to the order
- Development of the XML schema and PHP generator for Bitrix
-
OnSaleReturnComplete event handler, exchange queue
- Webhook endpoint for confirmation from 1C
- Stock update in Bitrix after confirmation
- Testing on several scenarios: partial return, return without shipment, return with multiple warehouses
Timeline Estimates
Basic integration (transfer of returns + confirmation) — 3–4 weeks. With real-time stock synchronisation and handling of edge cases — 6–8 weeks. The exact timeline is determined after an audit of your 1C configuration.
Common Pitfalls (Based on Real Projects)
- Forgetting to enable the
sale module’s event system for returns—the event OnSaleReturnComplete will never fire if the return process is customised without using the standard API.
- Mixing return documents with order documents in the XML—1C may interpret a return as a new order if the node structure overlaps.
- Assuming stock is updated via the standard
offers.xml—that exchange only runs on schedule; for real‑time updates a separate webhook is essential.
Our Approach
Every task requires individual analysis and careful planning. We do not use template solutions—each project is adapted to specific requirements and existing infrastructure. Our team has experience with projects of various scales: from small stores to high‑load platforms processing millions of operations per day.
We guarantee the completed work for 12 months. During this period, we fix any issues free of charge. After the project, we provide full documentation and training for your team. Technical support is available for 30 days after launch—we help resolve any questions and provide consultations.
If your company faces the described challenge, contact us for a free consultation. We will analyse your system and propose an optimal solution. The cost of the project depends on complexity and scope, but for typical solutions we always provide an accurate estimate based on a preliminary requirement analysis.
Typical scenario: manual returns take 25 minutes per request
A manager opens an order in /bitrix/admin/sale_order_view.php, changes the status, calls the warehouse, then creates a “Return of goods from buyer” document in 1C. One return consumes 20–30 minutes. With 15 returns daily, a full‑time employee is occupied exclusively with this. Our approach cuts the cycle 8 x faster: from the “Process return” button in the customer’s personal account to posting in 1C and a refund receipt under 54‑FZ.
Why the standard return process fails
Out of the box, 1C‑Bitrix lacks a separate “return” entity. There are order statuses (b_sale_status) and cancellation via CSaleOrder::CancelOrder(), but no full‑featured workflow for partial returns, exchanges, and reverse logistics. You have to build it.
-
Partial return – a customer wants to return 2 of 5 items.
CancelOrder cancels the whole order. Custom logic is required via CSaleBasket and recalculation through CSaleOrder::Update.
-
Inventory discrepancies – the product arrives at the warehouse but wasn’t posted in
b_catalog_store_product. The site shows “Out of stock” even though the box is on the shelf.
-
Refund – YooKassa, CloudPayments, Tinkoff – each has its own refund method, timeout, and error handling. Manual refund via the payment system’s personal account is tedious.
-
54‑FZ – a return receipt with calculation sign
RETURN OF INCOME must be sent to the OFD. Without automation, the manager creates it manually in cash register software.
What we build: from customer cabinet to 1C integration
Customer personal account – self‑service return
A custom section in /personal/returns/ integrated with sale.personal.order.list. The customer does everything:
- selects an order from
b_sale_order and sees items from b_sale_basket;
- marks specific products and picks a reason from the
RETURN_REASONS infoblock property or writes free text;
- uploads photos via
CFile::SaveFile() (defects, delivery damage);
- selects return method: courier (CDEK API), pickup point, or Russian Post;
- chooses refund destination: card (via payment system), internal account (
CSaleUserAccount), or exchange for another product;
- sees request status in real time – custom statuses in
b_sale_status_lang.
Admin panel for manager – no extra clicks
A separate section built on \Bitrix\Main\Engine\Controller:
- request queue with filters (status, amount, reason, date, manager). Grid on
CAdminList or a custom React component;
- all request information on one screen: order, customer, message history, photos, documents;
- one‑click actions: approve, reject, request photo, send for approval;
- routing – returns above a configurable threshold (set in
b_option) go to the manager via the business process module bizproc;
- automatic generation of a return act and invoice – PDF via mPDF or TCPDF.
Automation – minimum manual operations
- Returns up to a configurable threshold (e.g., a set amount) – auto‑approval via
OnSaleOrderSaved event handler.
- 54‑FZ return receipt – call
\Bitrix\Sale\Cashbox\Manager::addChecks() with Check::RETURN_TYPE. Sent to OFD automatically.
- Notification chain: email via
CEvent::Send(), SMS, push.
- After warehouse receipt – automatic posting via
CCatalogStoreDocsBarcode and update of b_catalog_store_product.
- Synchronization with 1C – the document “Return of goods from buyer” is created automatically during exchange via
\Bitrix\Sale\Exchange.
- Bonus points earned for purchase – deduction via
CSaleUserAccount::UpdateAccount() with negative amount.
- Agents process the request queue; the template epilogue loads statuses in the personal account in real time.
Integration with payment systems – handling every error
Each payment gateway has its own refund API, time limits, and error codes. Our certified Bitrix developers cover all scenarios:
-
YooKassa –
POST /v3/refunds, full and partial refund. Refund is possible only within 365 days after payment. Automatic return receipt via receipt API.
-
CloudPayments –
refund method by TransactionId. Refund to card in 1–5 business days. For 3DS payments, refund may take up to 30 days on the bank’s side.
-
Tinkoff Acquiring –
Cancel by PaymentId. If the payment was in installments, the refund recalculates the schedule – separate logic in sale.paysystem.handler.
-
Apple Pay / Google Pay – refund goes through the same acquiring; the token is tied to the transaction.
-
Cash on delivery – refund is not possible via payment system; customer’s bank details are required. A separate form in the personal account.
-
Internal account –
CSaleUserAccount::Pay() with credit of amount. Motivate with an increased coefficient (x1.1) – 10% bonus for choosing return to balance instead of card.
We guarantee correct handling of each error code via custom sale.paysystem.handler implementations.
Compliance and automation – no exceptions
Consumer Protection Law (Article 26.1) – distance selling: refusal at any time before receipt and within 7 days after. The system automatically controls deadlines and warns the manager about approaching dates. Consumer Protection Law (Article 26.1).
-
14 days – return of goods of proper quality. Check:
date_insert of order + delivery date from tracking + 14 days. If overdue, the request is rejected with explanation.
-
54‑FZ – return receipt is mandatory. Federal Law 54‑FZ.
-
Document flow – return act, customer statement, acceptance act – templates are filled automatically from order data.
Extended capabilities: analytics, exchange, reverse logistics
Return analytics – data for decisions
A custom dashboard in the admin panel, pulling data from b_sale_order plus a custom returns table:
- return percentage by categories, brands, managers, periods;
- top return reasons. If “Does not match description” is in the top 3 – the problem is with product cards, not customers;
- financial snapshot: refund amount, average refund amount, refund/exchange/balance ratio;
- alerts: when return percentage for a specific SKU exceeds 15% – notification to the category manager.
Exchange and replacement – retaining the sale
Not every return means lost revenue. Exchange via CSaleOrder::Update with cart recalculation:
- replacement with the same product in a different size/color – new item in
b_sale_basket, old one marked for return;
- exchange for another product with surcharge – automatic calculation of difference, additional payment via the same payment method;
- generation of an invoice for sending the exchange product via delivery service API.
Reverse logistics – integrations
-
CDEK –
POST /v2/orders with type: 2 (return). Automatic pickup request, tracking via webhook.
-
Boxberry – Parsel shop API for selecting a return pickup point.
-
Russian Post – generation of a return invoice via mail API.
- Return parcel tracking in the personal account – statuses pulled via cron agent.
Implementation process: 8 steps
-
Audit of current process – analyze business logic, document statuses and integrations.
-
Workflow design – status scheme, auto‑approval rules, routing.
-
Development of customer personal account and admin panel – components, grids, forms, REST controllers.
-
Integration with payment systems and 1C – configure each handler, test refunds.
-
Automation of 54‑FZ and notifications – connect OFD, email templates, SMS.
-
Integration with delivery services – CDEK, Boxberry, Russian Post.
-
Testing – full cycle: order → return → refund → receipt → 1C.
-
Employee training and documentation handover.
What you get: deliverables and results
| Block |
What You Get |
| Documentation |
Technical specification, workflow description, integration diagram |
| Code and configuration |
Ready components, infoblock settings, HL‑blocks, statuses, permissions |
| Integration with payment systems |
Connection of YooKassa, CloudPayments, Tinkoff, Apple Pay/Google Pay |
| Exchange with 1C |
CommerceML setup, return document in 1C |
| Automation of 54‑FZ |
Return receipt via OFD, fiscalization |
| Training |
Video instructions for managers and administrators |
| Support |
1‑month warranty support after implementation |
Pre‑launch checklist
- Refund via each payment system (partial and full) tested.
- 54‑FZ test: return receipt correct, sent to OFD.
- Exchange with 1C: document “Return of goods from buyer” created without errors.
- Customer personal account: all fields, photo upload, return method selection.
- Auto‑approval up to threshold working.
- Notifications (email/SMS/push) received.
- Inventory after receipt updated.
- Analytics calculates metrics correctly.
Why it pays off in a month
Manual return processing takes 25 minutes; after automation it takes 3 minutes – that is 8 times faster. With 15 returns per day, a full‑time employee position is freed. Yearly salary savings exceed $50,000. Also, error rates drop by 95% compared to manual handling. Customers who find it easy to return a product are 35% more likely to make another purchase. Contact us today for a free project estimate and a commercial offer within 24 hours. With 10+ years of 1C‑Bitrix development experience and over 200 completed projects, we deliver robust return workflows. Request a consultation now.