.Net SDKs

.NET Library

Uses P/Invoke to call the native ECR.dll for packing and parsing terminal messages.

Prerequisites

  • .NET Framework 4.7.2+ or .NET 6+
  • Windows 10 or later
  • ECR.dll in output directory

InteroperableService

using System.Runtime.InteropServices;

public class InteroperableService
{
    [DllImport("ECR.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern int pack(
        string inputReqData,
        int transactionType,
        string szSignature,
        byte[] szEcrBuffer
    );

    [DllImport("ECR.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern int parse(
        byte[] respData,
        byte[] szRespFields
    );
}

TCP/IP Connection

var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Connect("192.168.0.102", 8888);

byte[] buffer = new byte[4096];
InteroperableService.pack(requestData, 0, signature, buffer);
socket.Send(buffer);

byte[] response = new byte[4096];
socket.Receive(response);

byte[] fields = new byte[8192];
InteroperableService.parse(response, fields);
string result = Encoding.UTF8.GetString(fields);

Transaction Flow

Socket / SerialPort → pack() via P/Invoke → Send to Terminal → Receive Response → parse() via P/Invoke

Transaction Type Codes

CodeTransaction Type
0Purchase
1Purchase with Naqd/Cashback
2Refund
3Authorization
4Purchase Advice (Full)
5Purchase Advice (Partial)
6Auth Extension
7Auth Void
9Cash Advance
10Reconciliation
11Reversal
15Bill Payment
17Register
18Start Session
19End Session
23Duplicate / Previous Txn
24Check Status
25Health Check