{"title":"Implement callbacks with register_device_request","category":"default","creationDate":1776961627,"content":"<h2 id=\"about-this-task\">About this task<\/h2>\n<p>In the C Library integration, some callbacks are part of, and passed with, a <code>register_device_request<\/code>.<\/p>\n<p>This includes:<\/p>\n<ul>\n<li><code>ped_state_change_CB<\/code><\/li>\n<li><code>tender_additional_data_CB<\/code><\/li>\n<li><code>tender_print_receipt_CB<\/code><\/li>\n<li><code>tender_check_signature_CB<\/code><\/li>\n<li><code>tender_progress_CB<\/code><\/li>\n<li><code>tender_dcc_CB<\/code><\/li>\n<li><code>tender_finished_CB<\/code><\/li>\n<li><code>tender_referral_CB<\/code><\/li>\n<\/ul>\n<div class=\"sc-notice note\"><div>\n<p>This does not apply to callbacks that are not added to the\u00a0<code>register_device_request<\/code>\u00a0structure. \u00a0For these callbacks, see <a href=\"\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration\/calls-and-callbacks-c-library\/implement-callbacks\">Implement callbacks<\/a>.<\/p>\n<\/div><\/div>\n<p>We have defined a signature for each callback in the <span translate=\"no\"><strong>register_device_extern.h<\/strong><\/span> file. The signature we provide looks like:<\/p>\n<pre><code class=\"language-cpp\">void tender_print_receipt_CB(receipts_strct * , ped_device_info * , void * );<\/code><\/pre>\n<p>You will need to implement callback functions with the same signature.\u00a0<\/p>\n<h2 id=\"steps\">Steps<\/h2>\n<p>To use these callbacks:<\/p>\n<ol>\n<li>\n<p>Implement the callback. In the following example we will implement the <code>print_receipt<\/code> callback.<\/p>\n<pre><code class=\"language-cpp\">void tender_print_receipt_CB(receipts_strct * status_tender, ped_device_info * ped_state, void * echo_struct){\n\n    app_context_t * sPOS = (app_context_t *)echo_struct;\n\n    \/\/TODO: store the receipts somewhere\n\n    \/\/ADYLibraryResult result =\n\n    confirm_print_receipt(sPOS-&gt;terminal_id, sPOS-&gt;tender_reference, true);\n\n}<\/code><\/pre>\n<\/li>\n<li>\n<p>Assign a pointer for <code>print_receipt_callback<\/code>\u00a0 to\u00a0<code>status_tender_print_receipt<\/code>\u00a0in the\u00a0<code>callbacks<\/code>\u00a0data structure within the\u00a0<code>register_device_request<\/code><\/p>\n<pre><code class=\"language-cpp\">register_device_request_ptr-&gt;callbacks.status_tender_print_receipt   = tender_print_receipt_CB;<\/code><\/pre>\n<\/li>\n<li>\n<p>When you have populated <code>register_device_request.callbacks<\/code> with each callback, pass <code>register_device_request<\/code> as a parameter of the\u00a0<code>register_device<\/code>\u00a0call.<\/p>\n<pre><code class=\"language-cpp\">ADYLibraryResult result = register_device(register_device_request_ptr, register_ped_CB, sPOS);<\/code><\/pre>\n<\/li>\n<\/ol>","url":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration\/calls-and-callbacks-c-library\/implement-callbacks-with-register_device_request","articleFields":{"id":"31492995","type":"page","_expandable":{"operations":""},"status":"current"},"algolia":{"url":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration\/calls-and-callbacks-c-library\/implement-callbacks-with-register_device_request","title":"Implement callbacks with register_device_request","content":"About this task\nIn the C Library integration, some callbacks are part of, and passed with, a register_device_request.\nThis includes:\n\nped_state_change_CB\ntender_additional_data_CB\ntender_print_receipt_CB\ntender_check_signature_CB\ntender_progress_CB\ntender_dcc_CB\ntender_finished_CB\ntender_referral_CB\n\n\nThis does not apply to callbacks that are not added to the\u00a0register_device_request\u00a0structure. \u00a0For these callbacks, see Implement callbacks.\n\nWe have defined a signature for each callback in the register_device_extern.h file. The signature we provide looks like:\nvoid tender_print_receipt_CB(receipts_strct * , ped_device_info * , void * );\nYou will need to implement callback functions with the same signature.\u00a0\nSteps\nTo use these callbacks:\n\n\nImplement the callback. In the following example we will implement the print_receipt callback.\nvoid tender_print_receipt_CB(receipts_strct * status_tender, ped_device_info * ped_state, void * echo_struct){\n\n    app_context_t * sPOS = (app_context_t *)echo_struct;\n\n    \/\/TODO: store the receipts somewhere\n\n    \/\/ADYLibraryResult result =\n\n    confirm_print_receipt(sPOS-&gt;terminal_id, sPOS-&gt;tender_reference, true);\n\n}\n\n\nAssign a pointer for print_receipt_callback\u00a0 to\u00a0status_tender_print_receipt\u00a0in the\u00a0callbacks\u00a0data structure within the\u00a0register_device_request\nregister_device_request_ptr-&gt;callbacks.status_tender_print_receipt   = tender_print_receipt_CB;\n\n\nWhen you have populated register_device_request.callbacks with each callback, pass register_device_request as a parameter of the\u00a0register_device\u00a0call.\nADYLibraryResult result = register_device(register_device_request_ptr, register_ped_CB, sPOS);\n\n","type":"page","locale":"pt","boost":14,"hierarchy":{"lvl0":"Home","lvl1":"Terminais","lvl2":"Deprecation of classic libraries","lvl3":"Library integrations","lvl4":"C library integration","lvl5":"Calls and callbacks","lvl6":"Implement callbacks with register_device_request"},"hierarchy_url":{"lvl0":"https:\/\/docs.adyen.com\/pt","lvl1":"https:\/\/docs.adyen.com\/pt\/point-of-sale","lvl2":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation","lvl3":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations","lvl4":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration","lvl5":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration\/calls-and-callbacks-c-library","lvl6":"\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration\/calls-and-callbacks-c-library\/implement-callbacks-with-register_device_request"},"levels":7,"category":"In-person payments","category_color":"green","tags":["Implement","callbacks","register_device_request"]}}
