No momento, esta página não está disponível em português
Point-of-sale icon

Implement callbacks with register_device_request

About this task

In the C Library integration, some callbacks are part of, and passed with, a register_device_request.

This includes:

  • ped_state_change_CB
  • tender_additional_data_CB
  • tender_print_receipt_CB
  • tender_check_signature_CB
  • tender_progress_CB
  • tender_dcc_CB
  • tender_finished_CB
  • tender_referral_CB

This does not apply to callbacks that are not added to the register_device_request structure.  For these callbacks, see Implement callbacks.

We have defined a signature for each callback in the register_device_extern.h file. The signature we provide looks like:

void tender_print_receipt_CB(receipts_strct * , ped_device_info * , void * );

You will need to implement callback functions with the same signature. 


To use these callbacks:

  1. Implement the callback. In the following example we will implement the print_receipt callback.

    void tender_print_receipt_CB(receipts_strct * status_tender, ped_device_info * ped_state, void * echo_struct){
        app_context_t * sPOS = (app_context_t *)echo_struct;
        //TODO: store the receipts somewhere
        //ADYLibraryResult result =
        confirm_print_receipt(sPOS->terminal_id, sPOS->tender_reference, true);
  2. Assign a pointer for print_receipt_callback  to status_tender_print_receipt in the callbacks data structure within the register_device_request

    register_device_request_ptr->callbacks.status_tender_print_receipt   = tender_print_receipt_CB;
  3. When you have populated register_device_request.callbacks with each callback, pass register_device_request as a parameter of the register_device call.

    ADYLibraryResult result = register_device(register_device_request_ptr, register_ped_CB, sPOS);