.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
| Code | Transaction Type |
|---|---|
| 0 | Purchase |
| 1 | Purchase with Naqd/Cashback |
| 2 | Refund |
| 3 | Authorization |
| 4 | Purchase Advice (Full) |
| 5 | Purchase Advice (Partial) |
| 6 | Auth Extension |
| 7 | Auth Void |
| 9 | Cash Advance |
| 10 | Reconciliation |
| 11 | Reversal |
| 15 | Bill Payment |
| 17 | Register |
| 18 | Start Session |
| 19 | End Session |
| 23 | Duplicate / Previous Txn |
| 24 | Check Status |
| 25 | Health Check |
Updated 4 days ago