Java SDKs

Java ECR Integration

JNI wrapper for Java SE desktop environments, similar to the Android SDK.

Prerequisites

  • JDK 8 or later
  • Windows 10 (native library dependency)
  • ECR native library (.dll) in java.library.path

Transaction Example

import java.net.Socket;
import java.io.*;

public class EcrClient {
    public static native int pack(String reqData, int txnType, String signature, byte[] buffer);
    public static native int parse(byte[] response, byte[] fields);

    public static void main(String[] args) throws Exception {
        Socket socket = new Socket("192.168.0.102", 8888);
        
        byte[] buffer = new byte[4096];
        pack(requestData, 17, signature, buffer);
        socket.getOutputStream().write(buffer);
        
        byte[] resp = new byte[4096];
        socket.getInputStream().read(resp);
        
        byte[] fields = new byte[8192];
        parse(resp, fields);
        System.out.println("Result: " + new String(fields));
        
        socket.close();
    }
}

Transaction Flow

Socket Connect → Register (17) → Start Session (18) → pack() + send() → recv() + parse()

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