Views: 2696
Last Modified: 31.05.2022

In previous article Standard online cash register doesn't suit you? Use the product API and write your own custom handler.

Learn more...
you have found out how to write your own cash register handler. In this article, you will find details on the algorithm used for printing receipts via payment system:

  1. Creating a payment

    Receipt data is prepared when creating a payment. Usually the following data:

    • shopping cart contents;
    • tax system;
    • VAT;
    • receipt type.

    This data is sent jointly with query for creating a payment.

    At this stage, system doesn't create a receipt, because buyer hasn't executed payment yet.

  2. Payment

    After the buyer has executed a payment, payment gate sends a corresponding notification.

    When processing the notification, system changes payment status to Paid.

  3. Receipt

    When payment status is changed, collecting receipt data begins:

    • system determines receipt type to be printed (matches with type, passed when creating a payment);
    • calls the method buildCheckQuery that prepares receipt data;
    • selects a suitable cash register for printing;
    • calls the method printImmediately. Because receipt data is already available in the payment gate, its not passed again;
    • receipt in status Printed is added to the system.

  4. Receipt status

    After the receipt is added to the system, you can get data on this receipt status via the agent \Bitrix\Sale\Cashbox\Manager::updateChecksStatus(), or a manager can manually request the status from interface.

    Note: When first receipt was a "full payment" receipt, receipt handling is complete at this stage. When receipt type is different ("advance payment" or "prepayment") you need to print a second closing receipt when shipping an order.

  5. Printing a closing receipt

    At the moment of order shipment, the system begins to collect data for second receipt:

    • system determines receipt type to be printed (in this case it's "full payment");
    • calls the method buildCheckQuery, that prepares receipt data;
    • selects a suitable cash register for printing;
    • calls the method printImmediately, and now receipt data is sent to payment provider;
    • receipt in status Printed is added to the system.

  6. Finalizing ('closing') receipt status

    After the receipt is added to the system, you can get status data for this receipt via agent \Bitrix\Sale\Cashbox\Manager::updateChecksStatus(), or a manager can manually request the status from interface.

Related links:





Courses developed by Bitrix24