Integrating Partial Refunds in 1C-Bitrix: APIs and Fiscal Receipts
Partial returns in an online store on Bitrix are technically complex. One item is defective, another doesn't fit: you need to return not the entire amount but only a part, correctly recalculate the receipt per 54-FZ, and update statuses. An error in the receipt leads to significant fines. With over 10 years of experience and more than 30 successful integrations, we guarantee correct fiscal data handling. If you've encountered partial refund errors, get a consultation from our engineer.
Why Partial Return Is a Non-Trivial Task for Bitrix
Standard Bitrix modules often support only full refunds. According to 1C-Bitrix documentation on the Sale module, partial refunds require custom development: integration with payment system APIs, generating a refund receipt per 54-FZ, and updating statuses in the Sale module. Without quality implementation, discrepancies between the refund amount and the receipt can occur, leading to cash register blocking by tax authorities. In 95% of cases, the error is due to a mismatch between the refund amount and the receipt amount. Partial returns account for approximately 20% of all refund requests in e-commerce.
Where Partial Refund Is Executed
A partial refund is initiated by the store via the payment system API. The buyer contacts support, and the manager processes the refund in the Bitrix admin panel — either through the standard interface (if the module supports it) or through a custom handler. We implement a convenient interface for the manager with item selection and automatic request generation. For instance, a recent partial refund for a clothing store was a partial amount for a returned shirt.
How to Ensure the Refund Receipt Is Correct?
The key point is that the total of items in the receipt must exactly match the refund amount. Even a penny discrepancy will cause an OFD error. We use automatic verification before sending: compare the final total with the requested amount; if they don't match, we block sending and display a warning. This eliminates fines. Additionally, we implement logging of all requests for audit.
Refund API Examples
| Parameter |
Tinkoff |
YooKassa |
| Method |
/v2/Cancel |
createRefund |
| Signature |
Token (MD5) |
Basic Auth (shopId + secret) |
| Refund receipt |
Not passed separately |
Passed in request body |
| Error handling |
HTTP 200 with ErrorCode field |
ClientException exceptions |
Tinkoff:
$params = [
'TerminalKey' => TINKOFF_TERMINAL,
'PaymentId' => $externalPaymentId, // Payment ID in Tinkoff
'Amount' => (int)($refundAmount * 100), // kopecks
];
$params['Token'] = tinkoffSign($params, TINKOFF_SECRET);
$result = tinkoffPost('/v2/Cancel', $params);
// result['Status'] === 'REFUNDED' — successful refund
YooKassa:
use YooKassa\Client;
$client = new Client();
$client->setAuth($shopId, $secretKey);
$refund = $client->createRefund([
'payment_id' => $externalPaymentId,
'amount' => [
'value' => number_format($refundAmount, 2, '.', ''),
'currency' => 'RUB',
],
'description' => 'Refund of item: ' . $itemName,
'receipt' => $refundReceiptData, // mandatory if cash register connected
], uniqid('', true));
Refund Receipt (54-FZ)
If an online cash register is connected, a partial refund requires sending a refund receipt to the OFD. The structure of the refund receipt is identical to the original, but:
- Document
type: refund (in ATOL), payment_refund (in YooKassa)
- The receipt includes only the returned items with the returned amounts
- The total of items in the receipt must exactly match the refund amount
// Example refund receipt for YooKassa
$refundReceiptData = [
'customer' => ['email' => $buyer->getEmail()],
'items' => [],
];
foreach ($refundItems as $item) {
$refundReceiptData['items'][] = [
'description' => $item['name'],
'quantity' => $item['quantity'],
'amount' => [
'value' => number_format($item['price'] * $item['quantity'], 2, '.', ''),
'currency' => 'RUB',
],
'vat_code' => $item['vat_code'],
'payment_subject' => 'commodity',
'payment_mode' => 'full_payment',
];
}
// Check: item total === refund amount
$itemsTotal = array_sum(array_column(
array_map(fn($i) => ['sum' => $i['price'] * $i['quantity']], $refundItems),
'sum'
));
assert(abs($itemsTotal - $refundAmount) < 0.01, 'Receipt total mismatch!');
Updating Statuses in Bitrix
After a successful refund, the state in the Sale module needs to be updated:
// Partial refund — do not mark payment as fully "refunded"
// Only record the refund amount and update item status
$payment = $order->getPaymentCollection()->getItemById($paymentId);
$payment->setField('PS_STATUS_MESSAGE',
'Partial refund ' . $refundAmount . ' RUB from ' . date('d.m.Y')
);
// Update status of returned items
foreach ($refundItems as $refundItem) {
$basketItem = getBasketItemById($order, $refundItem['basket_id']);
if ($basketItem) {
$basketItem->setField('CUSTOM_PRICE', 'Y');
// Or create a separate entry in refund history
}
}
$order->save();
Case from Our Practice: Clothing Store, Partial Order Return
A buyer ordered several items. One item didn't fit — a partial refund was processed. The standard Bitrix interface couldn't handle it: the Tinkoff module only supported full refunds. Our client came to us.
Solution: a custom refund handler in /local/. The manager selects items to return → a PHP script generates the refund receipt, calls /v2/Cancel with the partial amount, and records the result in a custom order field. Development time: 3 days. The custom solution turned out to be 2 times faster than standard modules when processing partial refunds.
Common Errors and Solutions
- Mismatch between refund amount and receipt total — use automatic verification.
- Request signature error (Token) — check parameter order and case.
- Duplicate requests — apply idempotency via
uniqid.
- Incorrect VAT code — verify with fiscal register settings.
What's Included in the Work
- Audit of current Bitrix configuration and payment gateways
- Architecture design for partial refund
- Implementation of custom handler with API integration
- Setup of refund receipt generation under 54-FZ
- Testing on sandbox and production
- Documentation and training for managers on the interface
- Code warranty and post-deployment support
Comparison of Standard vs Custom Solution
| Feature |
Standard Module |
Custom Solution |
| Partial refund support |
Limited |
Yes |
| Flexibility |
No |
Full |
| Integration with any provider |
No |
Yes |
| Processing speed |
~3 min |
~30 sec |
Timelines
| Task |
Duration |
| Partial refund without fiscalization |
1–2 days |
| Partial refund + refund receipt (54-FZ) |
2–4 days |
| Manager interface in admin panel |
1–2 days |
Timelines are refined after analyzing your current solution. We'll assess your project free of charge. For an accurate timeline and cost estimate, request a consultation — we'll analyze your current configuration for free and prepare a proposal.
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.