{"title":"Handle the Print Receipt callback","category":"default","creationDate":1776961627,"content":"<h2 id=\"requirements\">Requirements<\/h2>\n<p>Adyen provides certified receipts that are as short as possible while still meeting scheme requirements. For custom receipts, take care to include all data elements required by certification. Any issues that arise from not including these required data elements are at your own liability.\u00a0<\/p>\n<p>Card schemes have very specific requirements on what should be included on a receipt. These requirements differ per scheme and country\/region, and can change. Receipts generated by Adyen have been certified as compliant by the card schemes that we support.<\/p>\n<p>Card schemes will occasionally visit live stores to verify that receipts being generated are fully-compliant.<\/p>\n<div class=\"notices red\">\n<p>To prevent non-compliance and avoidable chargebacks, we strongly recommend using the Adyen-generated receipts without alterations. If you override this receipt data, or validate values against a hard-coded list, it is your responsibility to ensure that scheme requirements are met at all times.<\/p>\n<\/div>\n<h2 id=\"implement-the-print-receipt-callback\">Implement the print receipt callback<\/h2>\n<p>Implement the\u00a0<code>tender_print_receipt_CB,<\/code>\u00a0assign to the function pointer\u00a0<code>status_tender_print_receipt<\/code>\u00a0and invoke this by passing the <code>ReceiptHandler<\/code> tender option.\u00a0\u00a0For more information on how to do this, see\u00a0<a href=\"\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration\/calls-and-callbacks-c-library\/implement-callbacks-with-register_device_request\">Implement callbacks with register_device_request<\/a>.<\/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    app_context_t * sPOS = (app_context_t *)echo_struct;\n    \/\/TODO: store the receipts somewhere\n    \/\/ADYLibraryResult result =\n    confirm_print_receipt(sPOS-&gt;terminal_id, sPOS-&gt;tender_reference, 1);\n}<\/code><\/pre>\n<h2 id=\"invoke-the-print-receipt-callback\">Invoke the print receipt callback<\/h2>\n<p>Specify\u00a0<code>ReceiptHandler<\/code>\u00a0as a tender option to invoke the print receipt callback and print on the POS. If the\u00a0<code>ReceiptHandler<\/code>\u00a0tender option is not specified and the PED does not have a printer, the transaction fails in violation with certification requirements.<\/p>\n<p>Receipts might need to be printed multiple times. For example, when an approved receipt is printed to allow the shopper to sign. If the merchant does not approve the signature, after checking it with the signature on the back of the card, a cancel\u00a0receipt needs to be printed. So, each invocation of the print receipt callback generates a new receipt.\u00a0<\/p>\n<h2 id=\"handle-the-print-receipt-callback\">Handle the print receipt callback<\/h2>\n<p>The <code>tender_print_receipt_CB<\/code> is returned\u00a0when a receipt on the PED needs to be printed. Receipt printing is a part of scheme certification. The receipt is passed to the POS when the PED does not include a printer, or where receipts must be archived or emailed. In this case, the POS must confirm that the receipt was received and printed. Create this function and assign to the function pointer <code>status_tender_print_receipt<\/code>.<\/p>\n<h3 id=\"parameters\">Parameters<\/h3>\n<table>\n<thead>\n<tr>\n<th>Field<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>receipts_strct<\/code><\/td>\n<td>Pointer to the <code>receipts_strct<\/code>\u00a0 struct. The\u00a0<code>receipts_strct<\/code>\u00a0contains the actual receipts in <a href=\"\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration\/structs\/receipt-c-library\">receipt - C library<\/a> structs. The\u00a0<code>receipt_line<\/code>\u00a0struct contains data elements for each line of the receipt. \u00a0For more details, see\u00a0<code>receipt_line<\/code>. The\u00a0<code>MerchantReceipt<\/code>\u00a0also contains a key\/value pair in the\u00a0<code>additional_data_struct<\/code>\u00a0struct. \u00a0The key is\u00a0<code>signatureOnReceipt<\/code>\u00a0and the value is\u00a0<span translate=\"no\"><strong>true<\/strong><\/span>. This allows\u00a0the shopper to sign the receipt.<\/td>\n<\/tr>\n<tr>\n<td><code>ped_device_info<\/code><\/td>\n<td>Pointer to the <code>ped_device_info<\/code> struct in the POS. Called with the results of the create tender call.<\/td>\n<\/tr>\n<tr>\n<td><code>echo_struct<\/code><\/td>\n<td>Pointer to a POS defined struct. Returned in the callback. Can be used to share a POS data struct between the call to the library and the associated callback from the library<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 id=\"confirm-print-receipt-function\">Confirm Print Receipt Function<\/h2>\n<p>Respond to the print receipt callback using the <code>confirm_print_receipt<\/code> function<\/p>\n<table style=\"width:100%;\"><colgroup><col style=\"width: 12%\"><col style=\"width: 87%\"><\/colgroup><thead><tr class=\"header\"><th><p>Name<\/p><\/th><th><p>Description<\/p><\/th><\/tr><\/thead><tbody><tr><td>\n<p><code>confirm_print_receipt<\/code><\/p>\n<\/td><td>\n<p>Response to the print receipt callback. Informs the Library that the app has completed printing. The transaction continues after the library receives confirmation.\u00a0<\/p>\n<\/td><\/tr><\/tbody><\/table>\n<h3 id=\"parameters-1\">Parameters<\/h3>\n<table>\n<thead>\n<tr>\n<th>Field<\/th>\n<th>Type<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>terminal_id<\/code><\/td>\n<td>char<\/td>\n<td>Terminal id of the PED.<\/td>\n<\/tr>\n<tr>\n<td><code>tender_reference<\/code><\/td>\n<td>char<\/td>\n<td>Tender reference of the transaction.<\/td>\n<\/tr>\n<tr>\n<td><code>confirmation<\/code><\/td>\n<td>ADYAttendantAction<\/td>\n<td>Confirmation (true\/false).<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"code-example\">Code example<\/h3>\n<pre><code class=\"language-cpp\">confirm_print_receipt(char * terminal_id, char * tender_reference, boolean confirmation);<\/code><\/pre>","url":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration\/key-steps-c-library\/process-a-basic-transaction-c-library\/handle-the-print-receipt-callback-c-library","articleFields":{"id":"24217515","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\/key-steps-c-library\/process-a-basic-transaction-c-library\/handle-the-print-receipt-callback-c-library","title":"Handle the Print Receipt callback","content":"Requirements\nAdyen provides certified receipts that are as short as possible while still meeting scheme requirements. For custom receipts, take care to include all data elements required by certification. Any issues that arise from not including these required data elements are at your own liability.\u00a0\nCard schemes have very specific requirements on what should be included on a receipt. These requirements differ per scheme and country\/region, and can change. Receipts generated by Adyen have been certified as compliant by the card schemes that we support.\nCard schemes will occasionally visit live stores to verify that receipts being generated are fully-compliant.\n\nTo prevent non-compliance and avoidable chargebacks, we strongly recommend using the Adyen-generated receipts without alterations. If you override this receipt data, or validate values against a hard-coded list, it is your responsibility to ensure that scheme requirements are met at all times.\n\nImplement the print receipt callback\nImplement the\u00a0tender_print_receipt_CB,\u00a0assign to the function pointer\u00a0status_tender_print_receipt\u00a0and invoke this by passing the ReceiptHandler tender option.\u00a0\u00a0For more information on how to do this, see\u00a0Implement callbacks with register_device_request.\nvoid tender_print_receipt_CB(receipts_strct * status_tender, ped_device_info * ped_state, void * echo_struct){\n    app_context_t * sPOS = (app_context_t *)echo_struct;\n    \/\/TODO: store the receipts somewhere\n    \/\/ADYLibraryResult result =\n    confirm_print_receipt(sPOS-&gt;terminal_id, sPOS-&gt;tender_reference, 1);\n}\nInvoke the print receipt callback\nSpecify\u00a0ReceiptHandler\u00a0as a tender option to invoke the print receipt callback and print on the POS. If the\u00a0ReceiptHandler\u00a0tender option is not specified and the PED does not have a printer, the transaction fails in violation with certification requirements.\nReceipts might need to be printed multiple times. For example, when an approved receipt is printed to allow the shopper to sign. If the merchant does not approve the signature, after checking it with the signature on the back of the card, a cancel\u00a0receipt needs to be printed. So, each invocation of the print receipt callback generates a new receipt.\u00a0\nHandle the print receipt callback\nThe tender_print_receipt_CB is returned\u00a0when a receipt on the PED needs to be printed. Receipt printing is a part of scheme certification. The receipt is passed to the POS when the PED does not include a printer, or where receipts must be archived or emailed. In this case, the POS must confirm that the receipt was received and printed. Create this function and assign to the function pointer status_tender_print_receipt.\nParameters\n\n\n\nField\nDescription\n\n\n\n\nreceipts_strct\nPointer to the receipts_strct\u00a0 struct. The\u00a0receipts_strct\u00a0contains the actual receipts in receipt - C library structs. The\u00a0receipt_line\u00a0struct contains data elements for each line of the receipt. \u00a0For more details, see\u00a0receipt_line. The\u00a0MerchantReceipt\u00a0also contains a key\/value pair in the\u00a0additional_data_struct\u00a0struct. \u00a0The key is\u00a0signatureOnReceipt\u00a0and the value is\u00a0true. This allows\u00a0the shopper to sign the receipt.\n\n\nped_device_info\nPointer to the ped_device_info struct in the POS. Called with the results of the create tender call.\n\n\necho_struct\nPointer to a POS defined struct. Returned in the callback. Can be used to share a POS data struct between the call to the library and the associated callback from the library\n\n\n\nConfirm Print Receipt Function\nRespond to the print receipt callback using the confirm_print_receipt function\nNameDescription\nconfirm_print_receipt\n\nResponse to the print receipt callback. Informs the Library that the app has completed printing. The transaction continues after the library receives confirmation.\u00a0\n\nParameters\n\n\n\nField\nType\nDescription\n\n\n\n\nterminal_id\nchar\nTerminal id of the PED.\n\n\ntender_reference\nchar\nTender reference of the transaction.\n\n\nconfirmation\nADYAttendantAction\nConfirmation (true\/false).\n\n\n\nCode example\nconfirm_print_receipt(char * terminal_id, char * tender_reference, boolean confirmation);","type":"page","locale":"pt","boost":13,"hierarchy":{"lvl0":"Home","lvl1":"Terminais","lvl2":"Deprecation of classic libraries","lvl3":"Library integrations","lvl4":"C library integration","lvl5":"Key steps","lvl6":"Process a basic transaction","lvl7":"Handle the Print Receipt callback"},"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\/key-steps-c-library","lvl6":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration\/key-steps-c-library\/process-a-basic-transaction-c-library","lvl7":"\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration\/key-steps-c-library\/process-a-basic-transaction-c-library\/handle-the-print-receipt-callback-c-library"},"levels":8,"category":"In-person payments","category_color":"green","tags":["Handle","Print","Receipt","callback"]}}
