Project in C

At the end of the page, you will find two files:

  1. c-marketpay-pos-api-c-v20-documentation.zip

    Documentation on C integration

  2. ecrdrv-core-v20.1.zip

    1. in example: ECR simulator, including source code, to have code examples for ECR integration

    2. library

Building application

The ECR driver is library consists of one library file. This is marketpay-driver-cpp.dll on Windows or libmarketpay-driver-cpp.so on Linux.

Step 1: Obtain the ECR Driver Library

Make sure you have the ECR Driver library available. This might involve downloading it from a vendor's website or obtaining it through other means. Ensure that you have both the header files (.h  files) and the library file (.so or .a file) necessary for building your application.

Step 2: Open a Terminal

Open a terminal on your system. This is where you will execute the commands to build and run your application.

Step 3: Navigate to Your Project Directory

Use the cd command to navigate to the directory where your C source code file (main.c) is located.

bashCopy code

cd/path/to/your/project

Step 4: Compile Your Application

Use the gcc command to compile your C source code along with the ECR Driver library.

gcc main.c -I /path/to/header/directory -L /path/to/library/directory -l marketpay-driver-cpp -o your_executable_name

-I: Specifies the directory to search for header files.

-L: Specifies the directory to search for library files.

-l: Specifies the name of the library to link against.

-o: Specifies the name of the output executable.

Replace your_executable_name with the desired name for your executable.

Step 5: Set LD_LIBRARY_PATH

Before running your application, you need to set the LD_LIBRARY_PATH environmental variable to include the directory where the ECR Driver library is located.

export LD_LIBRARY_PATH=/path/to/library/directory:${LD_LIBRARY_PATH}

Step 6: Run Your Application

Now, you can run your compiled executable.

./your_executable_name

Replace your_executable_name with the actual name you provided in Step 4.

Memory Management for Strings

The responsibility for managing C-string memory lies with the caller. When an application invokes a driver's function and prepares input data by allocating memory for C-strings, the application becomes the caller. In such cases, the application is accountable for freeing the string memory once the driver's function returns control.

Conversely, if the driver calls the application's function (callback) and provides data to the application as callback parameters, the driver assumes the role of the caller and is responsible for freeing its own data.

In scenarios where strings serve as both input and output data simultaneously (e.g., EcrDrv_MutableDualTransactionParams.merchantOption in the EcrDrv_ITransactionHandler.onDualProcessing() callback), the caller must handle the responsibility of freeing this data. However, if the other party intends to modify such a string, the previous string should be freed first before allocating memory for the new string.

c-marketpay-pos-api-c-v20-documentation
3.27 MB
ecrdrv-core-v20.1
6.07 MB
ecrdrv-simulator-v20.1.0.0-dotnet-4.8-x86
1.06 MB