{"title":"Start gift card transactions","category":"default","creationDate":1776961627,"content":"<h2 id=\"prototype-the-callback\">Prototype the callback<\/h2>\n<p>Prototype the\u00a0<code>create_new_tender_CB<\/code>\u00a0and pass\u00a0this as a\u00a0parameter of the function pointer to the\u00a0<code>create_special_tender<\/code>\u00a0call.\u00a0<\/p>\n<h3 id=\"code-example\">Code example<\/h3>\n<p>The callback function declaration is:<\/p>\n<pre><code class=\"language-cpp\">void create_new_tender_CB(create_tender_response *response, void *echo_struct){\n    app_context_t *sPOS = (app_context_t *)echo_struct;\nif (response-&gt;tender_reference) {\n        safe_strdup(&amp;sPOS-&gt;tender_reference, response-&gt;tender_reference);\n        sPOS-&gt;pending_callback = 0; \/\/mark ok......\n    } else {\n        sPOS-&gt;pending_callback = -1;\n}<\/code><\/pre>\n<h2 id=\"allocate-request-structure\">Allocate request structure<\/h2>\n<p>Use\u00a0<code>create_special_tender_request<\/code>\u00a0to allocate memory for an\u00a0<code>special_tender_request<\/code>\u00a0structure.\u00a0Populate the request by performing\u00a0string duplication and filling heap allocated strings. If you want the data for later use, retain it, or it will be released automatically.<\/p>\n<pre><code class=\"language-cpp\">special_tender_request *request = create_special_tender_request();\n    if (request) {\n        request-&gt;reference = strdup(\"Simple transaction\");\n        request-&gt;merchant_account = strdup(sPOS-&gt;merchant_account);\n        request-&gt;terminal_id = strdup(sPOS-&gt;terminal_id);<\/code><\/pre>\n<h2 id=\"entry-modes\">Entry modes<\/h2>\n<p>The gift card can be presented in three ways:\u00a0<\/p>\n<ol>\n<li>Swipe: the gift card is read using a magnetic stripe reader.<\/li>\n<li>MKE on terminal: the card number is manually entered on the payment terminal. The tender should specify that it expects keyed entry on the terminal, and a card mask should be provided.<\/li>\n<li>MKE on POS app: scan a barcode on the back of the card from the POS app. In this scenario, the card number, card mask, and expiry should be provided in special options.<\/li>\n<\/ol>\n<p>You can specify entry modes by passing special tender options. See\u00a0<a href=\"\/pt\/point-of-sale\/gift-cards-terminal-api\">Gift Cards<\/a>.\u00a0<\/p>\n<h2 id=\"add-and-remove-special-options\">Add and remove special options<\/h2>\n<p>Special options are dictionary key value pairs. This information is passed directly to the PED, which interprets it.<\/p>\n<p>Use\u00a0<code>special_tender_add_option<\/code>\u00a0to set\u00a0 special options, passing the request along with key value pairs. Use\u00a0<code>special_tender_rm_option<\/code>\u00a0to remove the set options.<\/p>\n<pre><code class=\"language-cpp\">special_tender_add_option(request, \"cardNumber\", \"60362821657200117610\");\n        special_tender_add_option(request, \"cardNumber.expiryMonth\", \"12\");\n        special_tender_add_option(request, \"cardNumber.expiryYear\", \"2049\");<\/code><\/pre>\n<h2 id=\"populate-the-create_special_tender_request\">Populate the create_special_tender_request<\/h2>\n<p>Populate the request using string duplication.<\/p>\n<pre><code class=\"language-cpp\">special_tender_request *request = create_special_tender_request();\n    if (request) {\n        request-&gt;reference = strdup(\"Simple transaction\");\n        request-&gt;merchant_account = strdup(sPOS-&gt;merchant_account);\n        request-&gt;terminal_id = strdup(sPOS-&gt;terminal_id);\n        request-&gt;amount_currency = strdup(sPOS-&gt;currency);\n        request-&gt;amount_value = sPOS-&gt;amount;\n        request-&gt;transaction_type = strdup(\"balanceInquiry\");\n        request-&gt;payment_method_type = strdup(\"goldsmithscard\");\n        special_tender_add_option(request, \"cardNumber\", \"60362821657200117610\");\n        special_tender_add_option(request, \"cardNumber.expiryMonth\", \"12\");\n        special_tender_add_option(request, \"cardNumber.expiryYear\", \"2049\");\n        \/* additional data is accessible like below\n            request-&gt;additional_data_obj\n        *\/\n        result = create_special_tender(request, create_new_tender_CB, sPOS);\n    }\n<\/code><\/pre>\n<h2 id=\"call-the-create_special_tender-function\">Call the create_special_tender Function<\/h2>\n<p>Call the\u00a0<code>create_special_tender<\/code>\u00a0function to\u00a0Initiate the sale transaction, which triggers any relevant callbacks,\u00a0and pass in the request that was previously allocated.<\/p>\n<p>The POS waits for the final state and the\u00a0\u00a0<code>status_tender_final<\/code>\u00a0\u00a0callback to report the final result of the transaction, even if a cancel request has been issued. The reason for this is that the transaction might already be in a state in which a cancel is not possible.<\/p>\n<p>The sale transaction includes the merchant account information, as this is used to register PEDs for multiple merchant accounts, and transactions can be performed on more than one of these merchant accounts.<\/p>\n<pre><code class=\"language-cpp\">result = create_special_tender(request, create_new_tender_CB, sPOS);<\/code><\/pre>\n<h2 id=\"parameters\">Parameters<\/h2>\n<table>\n<thead>\n<tr>\n<th>Value<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>request<\/code><\/td>\n<td>Pointer to the <code>special_tender_request<\/code> struct, this struct contains all the input parameters for this call.<\/td>\n<\/tr>\n<tr>\n<td><code>create_new_tender_CB<\/code><\/td>\n<td>Pointer to the callback function in the POS that will be called with the results of the create special 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. It can be used to share a POS data struct between the call to the library and the callback from the library.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"code-example-1\">Code example<\/h3>\n<p>The declaration of the call to start a transaction is as follows:<\/p>\n<pre><code class=\"language-cpp\">result = create_special_tender(request, create_new_tender_CB, sPOS);<\/code><\/pre>\n<h2 id=\"handle-the-callback\">Handle the callback<\/h2>\n<p>Handle the\u00a0<code>create_new_tender_CB<\/code>\u00a0to check if the transaction was accepted by the terminal\u00a0by checking if tender_reference was populated by the library.\u00a0<\/p>\n<pre><code class=\"language-cpp\"> if (response-&gt;tender_reference) {\n  safe_strdup(&amp;sPOS-&gt;tender_reference, response-&gt;tender_reference);\n  sPOS-&gt;pending_callback = 0; \/\/mark ok......\n } else {\n  sPOS-&gt;pending_callback = -1;\n }<\/code><\/pre>\n<p>Check the result by getting information from the\u00a0<code>create_tender_response<\/code>.<\/p>\n<p>The POS needs to wait for the\u00a0<code>create_new_tender_CB<\/code>\u00a0to happen, before it can continue with other\u00a0functions.\u00a0 After the\u00a0<code>create_new_tender_CB<\/code>\u00a0is returned, the system returns a number of other callbacks. Finally, the system returns the\u00a0final\u00a0callback that contains the final transaction result. Another transaction can only be started when the final transaction result is received.<\/p>\n<h3 id=\"parameters-1\">Parameters<\/h3>\n<table>\n<thead>\n<tr>\n<th>Data element<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>create_tender_response<\/code><\/td>\n<td>A unique reference for the transaction that is generated by the PED device. This reference is used for subsequent actions on the transaction. For a list of parameters, see <a href=\"\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration\/structs\/create_tender_response\">create_tender_response<\/a>.<\/td>\n<\/tr>\n<tr>\n<td><code>echo_struct<\/code><\/td>\n<td>Pointer to a user-defined struct. Returned in the callback. It can be used to share a POS data struct between the call to the library and the callback from the library in response to the call.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"sc-notice note\"><div>\n<p>The <code>create_new_tender_CB<\/code> is a callback to the creation of a tender, but does not represent the status or result of the transaction. The result is returned in <code>tender_finished_CB<\/code>.<\/p>\n<\/div><\/div>","url":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration\/extras-c-library\/start-gift-card-transactions-c-library","articleFields":{"id":"31491822","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\/extras-c-library\/start-gift-card-transactions-c-library","title":"Start gift card transactions","content":"Prototype the callback\nPrototype the\u00a0create_new_tender_CB\u00a0and pass\u00a0this as a\u00a0parameter of the function pointer to the\u00a0create_special_tender\u00a0call.\u00a0\nCode example\nThe callback function declaration is:\nvoid create_new_tender_CB(create_tender_response *response, void *echo_struct){\n    app_context_t *sPOS = (app_context_t *)echo_struct;\nif (response-&gt;tender_reference) {\n        safe_strdup(&amp;sPOS-&gt;tender_reference, response-&gt;tender_reference);\n        sPOS-&gt;pending_callback = 0; \/\/mark ok......\n    } else {\n        sPOS-&gt;pending_callback = -1;\n}\nAllocate request structure\nUse\u00a0create_special_tender_request\u00a0to allocate memory for an\u00a0special_tender_request\u00a0structure.\u00a0Populate the request by performing\u00a0string duplication and filling heap allocated strings. If you want the data for later use, retain it, or it will be released automatically.\nspecial_tender_request *request = create_special_tender_request();\n    if (request) {\n        request-&gt;reference = strdup(\"Simple transaction\");\n        request-&gt;merchant_account = strdup(sPOS-&gt;merchant_account);\n        request-&gt;terminal_id = strdup(sPOS-&gt;terminal_id);\nEntry modes\nThe gift card can be presented in three ways:\u00a0\n\nSwipe: the gift card is read using a magnetic stripe reader.\nMKE on terminal: the card number is manually entered on the payment terminal. The tender should specify that it expects keyed entry on the terminal, and a card mask should be provided.\nMKE on POS app: scan a barcode on the back of the card from the POS app. In this scenario, the card number, card mask, and expiry should be provided in special options.\n\nYou can specify entry modes by passing special tender options. See\u00a0Gift Cards.\u00a0\nAdd and remove special options\nSpecial options are dictionary key value pairs. This information is passed directly to the PED, which interprets it.\nUse\u00a0special_tender_add_option\u00a0to set\u00a0 special options, passing the request along with key value pairs. Use\u00a0special_tender_rm_option\u00a0to remove the set options.\nspecial_tender_add_option(request, \"cardNumber\", \"60362821657200117610\");\n        special_tender_add_option(request, \"cardNumber.expiryMonth\", \"12\");\n        special_tender_add_option(request, \"cardNumber.expiryYear\", \"2049\");\nPopulate the create_special_tender_request\nPopulate the request using string duplication.\nspecial_tender_request *request = create_special_tender_request();\n    if (request) {\n        request-&gt;reference = strdup(\"Simple transaction\");\n        request-&gt;merchant_account = strdup(sPOS-&gt;merchant_account);\n        request-&gt;terminal_id = strdup(sPOS-&gt;terminal_id);\n        request-&gt;amount_currency = strdup(sPOS-&gt;currency);\n        request-&gt;amount_value = sPOS-&gt;amount;\n        request-&gt;transaction_type = strdup(\"balanceInquiry\");\n        request-&gt;payment_method_type = strdup(\"goldsmithscard\");\n        special_tender_add_option(request, \"cardNumber\", \"60362821657200117610\");\n        special_tender_add_option(request, \"cardNumber.expiryMonth\", \"12\");\n        special_tender_add_option(request, \"cardNumber.expiryYear\", \"2049\");\n        \/* additional data is accessible like below\n            request-&gt;additional_data_obj\n        *\/\n        result = create_special_tender(request, create_new_tender_CB, sPOS);\n    }\n\nCall the create_special_tender Function\nCall the\u00a0create_special_tender\u00a0function to\u00a0Initiate the sale transaction, which triggers any relevant callbacks,\u00a0and pass in the request that was previously allocated.\nThe POS waits for the final state and the\u00a0\u00a0status_tender_final\u00a0\u00a0callback to report the final result of the transaction, even if a cancel request has been issued. The reason for this is that the transaction might already be in a state in which a cancel is not possible.\nThe sale transaction includes the merchant account information, as this is used to register PEDs for multiple merchant accounts, and transactions can be performed on more than one of these merchant accounts.\nresult = create_special_tender(request, create_new_tender_CB, sPOS);\nParameters\n\n\n\nValue\nDescription\n\n\n\n\nrequest\nPointer to the special_tender_request struct, this struct contains all the input parameters for this call.\n\n\ncreate_new_tender_CB\nPointer to the callback function in the POS that will be called with the results of the create special tender call\n\n\necho_struct\nPointer to a POS defined struct. Returned in the callback. It can be used to share a POS data struct between the call to the library and the callback from the library.\n\n\n\nCode example\nThe declaration of the call to start a transaction is as follows:\nresult = create_special_tender(request, create_new_tender_CB, sPOS);\nHandle the callback\nHandle the\u00a0create_new_tender_CB\u00a0to check if the transaction was accepted by the terminal\u00a0by checking if tender_reference was populated by the library.\u00a0\n if (response-&gt;tender_reference) {\n  safe_strdup(&amp;sPOS-&gt;tender_reference, response-&gt;tender_reference);\n  sPOS-&gt;pending_callback = 0; \/\/mark ok......\n } else {\n  sPOS-&gt;pending_callback = -1;\n }\nCheck the result by getting information from the\u00a0create_tender_response.\nThe POS needs to wait for the\u00a0create_new_tender_CB\u00a0to happen, before it can continue with other\u00a0functions.\u00a0 After the\u00a0create_new_tender_CB\u00a0is returned, the system returns a number of other callbacks. Finally, the system returns the\u00a0final\u00a0callback that contains the final transaction result. Another transaction can only be started when the final transaction result is received.\nParameters\n\n\n\nData element\nDescription\n\n\n\n\ncreate_tender_response\nA unique reference for the transaction that is generated by the PED device. This reference is used for subsequent actions on the transaction. For a list of parameters, see create_tender_response.\n\n\necho_struct\nPointer to a user-defined struct. Returned in the callback. It can be used to share a POS data struct between the call to the library and the callback from the library in response to the call.\n\n\n\n\nThe create_new_tender_CB is a callback to the creation of a tender, but does not represent the status or result of the transaction. The result is returned in tender_finished_CB.\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":"Extras","lvl6":"Start gift card transactions"},"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\/extras-c-library","lvl6":"\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/c-library-integration\/extras-c-library\/start-gift-card-transactions-c-library"},"levels":7,"category":"In-person payments","category_color":"green","tags":["Start","transactions"]}}
