No momento, esta página não está disponível em português
Point-of-sale icon

Initialize the library using a network proxy

Before the library can be used, you must initialize it with the init_library function.

The call and the callback are asynchronous to prevent the call from blocking the calling thread.

Implement the callback

Implement the initialization_CB and pass this as a parameter of the init_library call. For more information on how to do this, see Implement callbacks.

Code example

void initialization_CB(void *result, void *echo_struct){app_context_t * POS = (app_context_t *)echo_struct;
printf("library is initialized");
}

Parameters

NameDescription

result

Returns the result of initializing the library. The result of initialization is always zero.

echo_struct

A pointer to a user-defined struct that is echoed back in the callback. Use this to share a POS data struct between the call to the library and the callback from the library.

Allocate request structure

Use init_library_allocate to allocate memory for an init_library_request structure. Populate the init_library_request by performing string duplication to fill heap-allocated strings.  The library automatically frees this memory.

The backend_use_proxy parameter is used to pass the proxy for communication to the plataforma de pagamentos da Adyen.plataforma de pagamentos da Adyen.

Call the init_library function

Call the init_library function with the provided parameters to initialize the library.

Parameters

NameTypeRequiredDescription

initReq

Struct: init_library_request

-white_check_mark-

A pointer to the init_library_request struct, this struct contains all the input parameters for this call. Allocate this request with init_library_allocate.

The backend_use_proxy parameter is used to pass the proxy for communication to the plataforma de pagamentos da Adyen and merchant backend.plataforma de pagamentos da Adyen and merchant backend.

initialization_CB

Function

-white_check_mark-

A pointer to the callback function in the POS that the system returns with the results of the initialization call.

echo_struct

Struct: echo_struct

-white_check_mark-

A pointer to a POS-defined struct that is echoed back in the callback. Use this to share a POS data struct between the call to the library and the callback from the library.

Get the function call result

ADYLibraryResult is used to store the result of the function call, the immediate response to the call. This is an enum that indicates if the system received the request. Should be ADYEN_OK, if this is not the case, something has gone wrong. In this case, check the input to the call and if it cannot be resolved, log the result and contact Support Team

This is not the final result of the call. The library returns the final result in response to the library initialization call.

Handle the callback

The POS needs to wait for the initialization callback before continuing with other functions, like boarding the POS systems and PED devices, and performing transactions.

Parameters

NameDescription

result

Returns the result of initializing the library. The result of initialization is always zero.

echo_struct

A pointer to a user-defined struct that is echoed back in the callback. Use this to share a POS data struct between the call to the library and the callback from the library.

Code example

typedef struct {
  char *user_data;
} app_context_t;

// result is always null for initialization callback
void initialization_CB(void *result, void *echo_struct) {
app_context_t * POS = (app_context_t *)echo_struct;
printf("library is initialized");
}

main()
{
  app_context_t POS;
    init_library_request *initReq = init_library_allocate();
    initReq->pos_name = strdup("Adyen");
    initReq->app_name = strdup("Adyen");
//Define the proxy here
//Add a username to the end and a port number
//Supported protocols are: https, socks4a and socks5h
    initReq->backend_use_proxy = "socks5h://my.awesome.proxy.url:3208";
    .
    .
    .
    ADYLibraryResult result = init_library(initReq, initialization_CB, &POS);
}

For more information on formatting a proxy URL, including specific ports and user credentials, see the CURLOPT_PROXY documentation.