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_CBtender_additional_data_CBtender_print_receipt_CBtender_check_signature_CBtender_progress_CBtender_dcc_CBtender_finished_CBtender_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_receiptcallback.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_callbacktostatus_tender_print_receiptin thecallbacksdata structure within theregister_device_requestregister_device_request_ptr->callbacks.status_tender_print_receipt = tender_print_receipt_CB; -
When you have populated
register_device_request.callbackswith each callback, passregister_device_requestas a parameter of theregister_devicecall.ADYLibraryResult result = register_device(register_device_request_ptr, register_ped_CB, sPOS);