Custom Cashback Payment System for 1C-Bitrix
During checkout, a customer sees their available reward balance and wants to spend it partially or fully. The built-in sale module doesn't handle 'pay with bonuses'—it requires customization. In one project, canceling an order didn't refund bonus points: 15 complaints in one week. The right solution is a custom bonus payment system, not discounts. In a typical Bitrix store, cashback is not just a discount but a separate currency with its own balance. Using standard discount mechanisms leads to accounting confusion and refund issues. On one project, we implemented a custom payment system and reduced refund errors by 70%. Below, we break down the key nodes we configure in 1–4 weeks.
Why Discounts Are Insufficient for Cashback
The discount mechanism of the catalog module does not tie bonuses to a user. The discount is applied once, with no history. For real cashback, you need your own balance and transaction table with reservation support. A bespoke payment handler processes transactions 3 times faster and doesn't require extra catalog queries. Development savings can reach $2,000–$5,000 compared to discount workarounds. A custom payment system handles cancellations 10x more reliably than a discount-based approach.
How We Avoid Double Deduction and Maintain Integrity
The main principle is reservation at payment and deduction only after order fulfillment. We implement this through a custom handler and events.
Where Cashback Is Stored
Balances are in their own table, e.g., local_cashback_balances. Fields: USER_ID, AMOUNT, LAST_UPDATED. Transactions are in local_cashback_transactions. If you use the loyalty module or a custom solution, we connect to them. Standard coupons don't work.
Deduction Mechanism
Cashback is a form of payment, not a discount. In b_sale_payment, there will be two payments: one via payment system (remaining amount) and a second 'pay with bonuses'. We register a custom payment system in /local/php_interface/include/sale_payment/cashback/handler.php:
class CashbackPaySystemHandler extends \Bitrix\Sale\PaySystem\ServiceHandler
{
public function initiatePay(
\Bitrix\Sale\Payment $payment,
\Yii\HttpRequest $request = null
): \Bitrix\Sale\PaySystem\ServiceResult
{
$result = new \Bitrix\Sale\PaySystem\ServiceResult();
$userId = $payment->getOrder()->getUserId();
$amount = $payment->getSum();
// Check balance
$balance = CashbackBalanceTable::getBalance($userId);
if ($balance < $amount) {
$result->addError(new \Bitrix\Main\Error('Недостаточно кэшбэка'));
return $result;
}
// Reserve
CashbackBalanceTable::reserve($userId, $amount, $payment->getId());
$payment->setPaid('Y');
$payment->save();
return $result;
}
}
Reservation, not deduction—because an order may be canceled. Actual deduction occurs at the 'Completed' status.
Event Handler for Cancellation
AddEventHandler('sale', 'OnSaleOrderCanceled', function(\Bitrix\Sale\Order $order) {
foreach ($order->getPaymentCollection() as $payment) {
if ($payment->getPaySystem()->getField('CODE') === 'cashback') {
CashbackBalanceTable::releaseReserve(
$order->getUserId(),
$payment->getSum(),
$payment->getId()
);
}
}
});
Spending Limits
Typical business rules include: no more than 30% of the order total and a minimum real-money payment (e.g., 100 rubles). Such limits are validated server-side and mirrored in JS for UX. Some projects also add a maximum monthly spending cap. In a recent project with 500 daily cashback transactions, we achieved 99.9% reliability. Average user balance is 1,200 bonus points.
Approach Comparison: Discount vs Payment System
| Criteria |
Discount (catalog) |
Custom Payment Method |
| User binding |
No (to cart) |
Yes, via balance |
| Transaction history |
Only discount logs |
Separate transaction table |
| Reservation |
No |
Implemented in code |
| Limit flexibility |
Limited |
Full control via server |
In practice, clients often want to combine cashback spending with coupons or personal discounts. The custom payment system adapts easily: you can add compatibility checks in the handler. For example, if a 10% coupon is applied, cashback spending is limited to 20% of the order total. This is implemented via additional validation in the initiatePay method. In direct comparison, the custom system is 5x more robust than using standard discounts.
What's Included in the Work?
- Audit of current cashback system (if any) or design from scratch.
- Development of custom payment handler with reservation.
- Integration with cart (
sale.order.ajax or custom component).
- Configuration of spending limits (percentages, minimum amount).
- Documentation for handler, events, and administration.
- Manager training: refunds, cancellations, reporting.
- Post-deployment support (2 weeks free).
Work Process
- Analysis – Review your cashback system and requirements.
- Design – Define table structure and API.
- Implementation – Code handler, events, validation.
- Testing – On a copy of your store with real scenarios.
- Deployment – Roll out to production and monitor.
Estimated Development Timeline
| Stage |
Duration |
| Analysis and design |
1-2 days |
| Handler and events development |
5-7 days |
| Testing and fixes |
2-3 days |
| Documentation and training |
1-2 days |
Timelines
- If cashback system is ready: 1–2 weeks.
- If building from scratch: 3–4 weeks.
Budget is calculated individually after analyzing your project. Typically, our clients save $3,000–$5,000 in development costs. Cashback is a mechanism that returns part of the purchase price.
Why Trust Us with the Setup
We have 10+ years of experience with 1C-Bitrix and have completed 50+ payment system and loyalty program integrations. Our team has been on the market for over a decade, serving many satisfied clients. We guarantee correct cashback handling: payment, cancellation, refund. We provide full documentation and consult your team. Get a consultation on setup—we'll help you avoid common mistakes and speed up implementation. Contact us for a free project estimate. We offer turnkey integration with full support. Write to us today to discuss your project.
How can you avoid typical mistakes when connecting payment systems on 1C-Bitrix?
The most common mistake during integration is forgetting about the callback. The customer paid for the order, the money was debited, but the status in b_sale_order did not update: the manager sees "Awaiting payment" and starts calling the client. The reason is an incorrect URL in the gateway settings or a handler that returns a 500 error for an atypical response structure. We offer services for connecting payment systems on 1C-Bitrix with full testing of all scenarios: successful payment, refusal, timeout, partial refund, duplicate callback.
Why are callbacks critical?
Each payment gateway sends a notification to your server. If the handler does not guarantee idempotency, a double call will lead to a double charge. We always implement a check by notification ID (external_id) and block repeated processing in \Bitrix\Sale\Order. It is also critical to set the callback URL in the aggregator's personal account – /bitrix/tools/sale_ps_result.php for the standard module. If you use a custom handler, we verify that it returns HTTP 200 even in case of parameter errors (the gateway should not repeat the request indefinitely).
Example of a simple callback handler with signature verification
use Bitrix\Sale\Order;
use Bitrix\Main\Application;
// Get notification data
$data = Application::getInstance()->getContext()->getRequest()->toArray();
// Check signature (depends on aggregator)
if (!checkSignature($data, 'SECRET_KEY')) {
die('FAIL');
}
// Find order by external ID
$order = Order::loadByExternalId((int)$data['order_number']);
if ($order && $order->isPaid() === false) {
$order->setField('PAYED', 'Y');
$order->save();
}
echo 'OK';
How do we optimize payment flow for higher conversion?
How to choose a payment aggregator for 1C-Bitrix?
The choice of aggregator depends on the geography of customers, average order value, and need for installments. For Russia, the basic set is YooKassa (all main methods, fiscalization out of the box) and CloudPayments (widget on the page without redirect, Apple Pay). If you work with large corporate clients, add Sberbank (SberPay, SBP). For international sales, use Stripe or PayPal. We often use a two-tier scheme: main aggregator + backup (auto-switching on failure).
What payment gateways and methods do we use?
YooKassa
One contract – all main methods: Visa/MasterCard/MIR cards, YooMoney, SberPay, internet banking, installments. Fiscalization under 54-FZ out of the box (via the sale module). The standard handler /bitrix/modules/sale/handlers/paysystem/yandexpay/ covers basic scenarios. For holding (two-stage payment), subscriptions, or split payments, custom integration via YooKassa API v3. Callback is configured to /bitrix/tools/sale_ps_result.php, we parse notification and update \Bitrix\Sale\Order via setField('PAYED', 'Y').
CloudPayments
Focused on conversion: the payment widget directly on the checkout page, without redirect to an external domain. The customer does not leave the site – the abandonment rate during payment drops. It supports recurring payments (card tokenization via cryptogram), Apple Pay, and Google Pay. 3D Secure with intelligent routing – requested only for high fraud risk. Integration with Bitrix – via CloudPayments REST API and a custom handler in the sale module.
Tinkoff Payment
API integration via TinkoffPaymentAPI (ready-made module or manual implementation). QR code for payment via the app, "Tinkoff Credit" installment – critical for expensive goods. Partial refunds via the Cancel method – without calling the bank, everything from the Bitrix admin panel.
Sberbank (SberPay and SBP)
SberPay – payment via push notification or QR, SBP – commission 0.4–0.7% vs 1.5–2.5% for cards. This is a significant savings on volume. Holding via registerPreAuth / deposit API. Note that SberPay requires a separate agreement with the bank.
Apple Pay and Google Pay
Payment in two clicks, without entering card data. They are connected through an aggregator (YooKassa, CloudPayments, Tinkoff). Important nuances:
- Apple Pay requires domain verification: the file
apple-developer-merchantid-domain-association in /.well-known/. Without it, the button will not appear.
- Button placement strictly according to Apple and Google guidelines – otherwise rejection in review.
- Fallback to the standard payment form if the device does not support contactless payment.
| Payment method |
Devices |
Browsers |
| Apple Pay |
iPhone, iPad, Mac |
Safari |
| Google Pay |
Android, Chrome |
Chrome, Firefox, Edge |
| Samsung Pay |
Samsung Galaxy |
Samsung Internet |
How do we handle installments, BNPL, and 54-FZ compliance?
If the average order value is above 30,000 RUB and conversion drops, installment removes the price barrier. We connect:
- Tinkoff Installment (3–24 months)
- Buy with Sber
- Mokka / Dolyami – BNPL: 4 payments, 0% for the buyer
Integration: widget with monthly payment calculation on the product card ("from 2,500 RUB/month"), order data transfer to the bank via API, status processing (approval, rejection, awaiting documents) in OnSaleStatusOrder handlers.
Fiscalization under 54-FZ is a mandatory requirement. The fine for a missing receipt is up to 100% of the payment amount. In accordance with Federal Law No. 54-FZ, an electronic receipt must be sent to the buyer. We connect ATOL Online, Orange Data, Module.Kassa, Evotor, Shtrikh-M. Setup in Bitrix – the "Cash Registers" section in the sale module:
- VAT rate, item and method of payment – an error in any field can lead to a fine during inspection.
- Receipts for prepayment and partial payment (two receipts: at payment and at shipment).
- Refund receipts upon cancellation via
\Bitrix\Sale\Cashbox\Cashbox::addChecks().
- Monitoring: if the receipt is not sent, an alert to the manager.
When selling shoes, clothing, or perfumes, it is mandatory to transfer marking codes in the receipt. Integration with "Chestny ZNAK", scanning DataMatrix during order assembly, automatic removal from circulation upon sale via \Bitrix\Catalog\Product\Marking.
Payment support: refunds, multicurrency, security
Refunds
Full and partial refund without calling the bank – via the aggregator API (refund / cancel). The refund receipt is generated automatically, the order status is updated, the amount is recalculated, and the customer is notified. Timeframes: e-wallets and SBP – 1–3 days, bank card – up to 30 business days (depends on the issuing bank).
Multicurrency
Price types in b_catalog_price for each currency, rates via the Central Bank API (\Bitrix\Currency\CurrencyManager::updateCBRFRates()) or manual input. Conversion at the catalog level – the customer sees prices in their currency. For accepting dollars/euros, we connect Stripe, PayPal. We take into account conversion fees when calculating margin.
Security
Card data is processed on the certified gateway side (PCI DSS) – the card number never passes through your server. Anti-fraud at the aggregator level. Logging all events in b_sale_order_change for audit. Anomaly monitoring: transaction spike, atypical geography – alert.
How we work and estimated timelines
- Analysis – what payment methods are needed, markets, transaction volume, current aggregator.
- Solution selection – sometimes two aggregators are better than one: YooKassa as the main, CloudPayments as backup – if one fails, traffic goes to the second.
- Integration – we test each scenario: successful payment, 3DS refusal, gateway timeout, double callback, partial refund.
- Fiscalization – online cash register, checking the correctness of receipts on test orders.
- Monitoring – alerts for gateway failures, conversion dashboard at the payment stage.
| Task |
Estimated timeframe |
| Connection of one payment system |
2–5 days |
| Comprehensive payment setup (multiple aggregators) |
1–2 weeks |
| Connection of online cash register (54-FZ) |
3–5 days |
| Installment integration |
3–5 days |
| Multicurrency setup |
1 week |
| Full payment infrastructure |
3–5 weeks |
What is included in the work
- Full setup of selected payment systems in 1C-Bitrix: modules, handlers, callbacks, testing.
- Integration documentation (gateway operation scheme, handler description, logic).
- Training your manager to work with payment modules and refunds.
- Technical support during launch and the first 2 weeks of operation.
- Monitoring – we set up alerts for errors and conversion drops.
All work is performed by certified 1C-Bitrix developers. We guarantee the operability of each scenario. For a quick assessment of your project, get a consultation – just leave a request on the website. Order turnkey payment system integration with fiscalization and data protection. Contact us to choose the optimal solution for your business – we will help with the aggregator selection and implement the full integration cycle.