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.
Steps
To use these callbacks:
-
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); }
-
Assign a pointer for
print_receipt_callback
tostatus_tender_print_receipt
in thecallbacks
data structure within theregister_device_request
register_device_request_ptr->callbacks.status_tender_print_receipt = tender_print_receipt_CB;
-
When you have populated
register_device_request.callbacks
with each callback, passregister_device_request
as a parameter of theregister_device
call.ADYLibraryResult result = register_device(register_device_request_ptr, register_ped_CB, sPOS);