This document serves as a complete reference guide for individuals seeking to utilize the Pine Labs Windows PoSLib library and PoS Controller for integration with the billing system. Its primary focus is to assist in the acceptance of payments, processing of transactions, and the seamless return of payment results to the invoking application.
The billing system can be integrated Windows platform in two different ways:
In both type of integration, the Merchant Billing application communicates with the Pine Labs Android Payment application through PoSBridge. Therefore, the merchant should ensure that PoSBridge is running on the Android payment terminal before initiating any transactions from the billing application.
The following sections provide detailed insights into both direct integration with PoSLib and Integration with PoS Controller.
In this approach, the merchant billing application, running on Windows OS, communicates with the Pine Labs payment application by integrating the java/dotNet PoSLib. PoSLib facilitates communication with the Pine Labs Android payment application via PoSBridge.
The merchant billing application needs to integrate PoSLib to communicate with the PoS Bridge through PoSLib APIs. The message exchange between PoSLib and PoS Bridge can occur over IP and COM (USB/Serial).
Note*The following sequence diagram describes the transaction flow:
The merchant billing application should be integrated with the respective PoSLib to perform transactions with the Android payment application.
The following features (APIs) are supported by Windows PoSLib:
Supported APIs | Functionality / Description |
---|---|
PoSLibInitialize | This API will be Initialize by the PoS library. This will be the first API to be called. |
scanOnlinePoSDevice | This API will be used to auto discover/scan for PoS device on the same network (Wi-Fi). |
scanCOMDevice | This API will be used to scan COM devices connected to the system. |
setConfiguration | This API will be used to set the required configuration in the PoSlib. |
getConfiguration | This API will be used to get the configuration settings from the PoSlib. |
testTCP | This API will be used to check for the TCP/IP connection. |
testCOM | This API will be used to check the COM connection. |
doTransaction | This API will be used to perform transactions with the Payment Application. |
The following section describes the APIs exposed by PoSLib, details of the API, and integration sample code snippets.
Same API specification for both Dotnet and java.
This API will auto-discover the Android payments terminals on the same network where PoSBridge is running on it and list them.
Signature | public void scanOnlinePOSDevice(ScanDeviceListener scanDeviceListener, Context context ); |
---|---|
Parameters | scanDeviceListener – Device listener |
Returns | None |
Call-backs |
OnSucces (List< DeviceDetails > list)
OnSucces (List< DeviceDetails > list) -List of Devices discovered OnFailure (String errorMsg, int errorCode) -Error Message -Error Code |
Error Condition |
• Response timeout • Device disconnected • Parsing error • Network down |
Notes | In response devicedetails isCom set to false and comPortNumber,comslno and comDevId will be set to null for scanOnlinePoSDevice API call return |
Java
public class Device { private String deviceIp; private String devicePort; private String devId; private String slNo; private boolean isCom; private String comPortNumber; private String comDevId; private String comslno; } ScanDeviceListener scanDeviceListener = new ScanDeviceListener() { @Override public void onSuccess(List
list) { // Retrieve the device list here } @Override public void onFailure(String errorMsg, int errorCode) { // Handle error here } }; PosLib.getInstance().scanOnlinePOSDevice(scanDeviceListener);
DotNet
public class ScanLisnter : IScanDeviceListener { public void onFailure(string errorMsg, int errorCode) { Console.WriteLine("Error Message"); } public void onSuccess(List
list) { if (list != null) { serialdevice = list; } } } ScanLisnter deviceslisnter = new ScanLisnter(); ConnectionService obj = new ConnectionService(); obj.scanOnlinePOSDevice(deviceslisnter);
This API will be used to auto-discover PoS devices through COM.
Language | JAVA | DOTNET |
Signature | Void scanSerialDevice( ScanDeviceListiner scanDeviceListiner) | Void scanSerialDevice( IScanDeviceListener scanDeviceListiner) |
Parameters | scanDeviceListener – Device listener | scanDeviceListener – Device listener |
Returns | None | None |
Call-backs |
OnSucces( List< DeviceDetails > list ) - List of Devices discovered OnFailure(String errorMsg, int errorCode) - Error Message - Error Code |
OnSucces( List< DeviceDetails > list ) - List of Devices discovered OnFailure(String errorMsg, int errorCode) - Error Message - Error Code |
Error Condition |
• Response timeout • Device disconnected • Parsing error |
• Response timeout • Device disconnected • Parsing error |
Notes | In response devicedetails isCom set to false and devicePort,devId and slNo will be set to null for scanComDevice API call return | In response devicedetails isCom set to false and devicePort,devId and slNo will be set to null for scanComDevice API call return |
Java
public class Device { private String deviceIp; private String devicePort; private String devId; private String slNo; private boolean isCom; private String comPortNumber; private String comDevId; private String comslno; } ScanDeviceListener scanDeviceListener = new ScanDeviceListener() { @Override public void onSuccess(List
list) { // Retrieve the device list here } @Override public void onFailure(String errorMsg, int errorCode) { // Handle error here } }; PosLib.getInstance().scanSerialDevice(scanDeviceListener);
DotNet
public class ScanLisnter : IScanDeviceListener { public void onFailure(string errorMsg, int errorCode) { Console.WriteLine("Error Message"); } public void onSuccess(List
list) { if (list != null) { serialdevice = list; } } } ScanLisnter deviceslisnter = new ScanLisnter(); ConnectionService obj = new ConnectionService(); obj.ScanSerialDevice(deviceslisnter);
This API should be used to set PoS Library configurations related to connectivity, priority settings, and logging options.
Language | JAVA | DOTNET |
Signature | int setConfiguration(ConfigData configData) | Void setConfiguration(ConfigData configData) |
Parameters | configData - Configuration Data | configData - Configuration Data |
Returns | 0 - Success -1 - Failure |
0 - Success -1 - Failure |
Call-backs | None | None |
Error Condition |
• Invalid IP • Invalid port • IP or Port not configured • PoS Lib not initialized |
• Invalid IP • Invalid port • IP or Port not configured • PoS Lib not initialized |
Java
public class ConfigData { private String tcpIP; private String tcpPort; private String devId; private String slNo; private String comPortNumber; private String comslno; private String comDevId; private int retryCount; private int connectionTimeOut; private boolean isConnectivityFallBackAllowed; private int priority1;// 1=TCPIP , 2=COM private int priority2;// 1=TCPIP , 2=COM private String logPath; private boolean isLogsEnabled; private int logLevel; private int dayToRetainLogs; private String cashierId; private String cashierName; } ConfigData configData = new ConfigData(); configData.setComPortNumber(""); configData.setConnectionTimeOut(30); configData.setConnectivityFallBackAllowed(false); configData.setPriority1(1); configData.setPriority2(2); configData.setTcpIP(""); configData.setTcpPort(""); configData.setRetryCount(2); configData.setDayToRetainLogs(2); configData.setLogPath("433a"); configData.setLogsEnabled(false); configData.setLogLevel(1); configData.setDevId(""); configData.setSlNo(""); configData.setComslno(""); configData.setCashierId(""); configData.setCashierName(""); configData.setComDevId(" "); PosLib.getInstance().setConfiguration(configData);
DotNet
public class ConfigData { public ConfigData() { tcpIp = string.Empty; connectionMode = string.Empty; CashierID = string.Empty; CashierName = string.Empty; comfullName = string.Empty; comserialNumber = string.Empty; tcpIpaddress = string.Empty; retry = string.Empty; connectionTimeOut = string.Empty; retainDay=string.Empty; tcpIpPort = string.Empty; logtype = string.Empty; tcpIpDeviceId = string.Empty; tcpIpSerialNumber = string.Empty; comDeviceId = string.Empty; LogPath = string.Empty; loglevel = string.Empty; } public int commPortNumber { get; set; } public string tcpIp { get; set; } public int tcpPort { get; set; } public string connectionMode { get; set; } public string[] communicationPriorityList { get; set; } = Array.Empty
(); public bool isConnectivityFallBackAllowed { get; set; } public string CashierID { get; set; } public string CashierName { get; set; } public string retry { get; set; } public string connectionTimeOut { get; set; } public string comfullName { get; set; } public string comserialNumber { get; set; } public string tcpIpaddress { get; set; } public string tcpIpPort { get; set; } public string tcpIpDeviceId { get; set; } public string tcpIpSerialNumber { get; set; } public string comDeviceId { get; set; } public string LogPath { get; set; } public string loglevel { get; set; } public bool isAppidle { get; set; } public string retainDay { get; set; } public string logtype { get; set; } } ConnectionService _con=new ConnectionService(); ConfigData configdata=new ConfigData configdata.tcpIp = tcp; configdata.tcpPort =tcpPort; _con.setConfiguration(configdata);
This API should be used to retrieve PoS Library configurations related to connectivity, priority settings, and logging options.
Language | JAVA | DOTNET |
Signature | int getConfiguration(ConfigData configData) | ConfigData getConfigData() |
Parameters | configData - Configuration Data | configData - Configuration Data |
Returns | 0 - Success -1 - Failure |
ConfigData |
Call-backs | None | None |
Error Condition |
• Invalid IP • Invalid port • IP or Port not configured • PoS Lib not initialized |
• Invalid IP • Invalid port • IP or Port not configured • PoS Lib not initialized |
Java
public class ConfigData { private String tcpIP; private String tcpPort; private String devId; private String slNo; private String comPortNumber; private String comslno; private String comDevId; private int retryCount; private int connectionTimeOut; private boolean isConnectivityFallBackAllowed; private int priority1;// 1=TCPIP , 2=COM private int priority2;// 1=TCPIP , 2=COM private String logPath; private boolean isLogsEnabled; private int logLevel; private int dayToRetainLogs; private String cashierId; private String cashierName; } ConfigData configData = new ConfigData(); int result = PosLib.getInstance().getConfiguration(configData);
DotNet
public class ConfigData { public ConfigData() { tcpIp = string.Empty; connectionMode = string.Empty; CashierID = string.Empty; CashierName = string.Empty; comfullName = string.Empty; comserialNumber = string.Empty; tcpIpaddress = string.Empty; retry = string.Empty; connectionTimeOut = string.Empty; retainDay=string.Empty; tcpIpPort = string.Empty; logtype = string.Empty; tcpIpDeviceId = string.Empty; tcpIpSerialNumber = string.Empty; comDeviceId = string.Empty; LogPath = string.Empty; loglevel = string.Empty; } public int commPortNumber { get; set; } public string tcpIp { get; set; } public int tcpPort { get; set; } public string connectionMode { get; set; } public string[] communicationPriorityList { get; set; } = Array.Empty
(); public bool isConnectivityFallBackAllowed { get; set; } public string CashierID { get; set; } public string CashierName { get; set; } public string retry { get; set; } public string connectionTimeOut { get; set; } public string comfullName { get; set; } public string comserialNumber { get; set; } public string tcpIpaddress { get; set; } public string tcpIpPort { get; set; } public string tcpIpDeviceId { get; set; } public string tcpIpSerialNumber { get; set; } public string comDeviceId { get; set; } public string LogPath { get; set; } public string loglevel { get; set; } public bool isAppidle { get; set; } public string retainDay { get; set; } public string logtype { get; set; } } ConnectionService _con=new ConnectionService(); ConfigData configdata=new ConfigData configdata = _con.GetConfigData()!;
This API will verify connectivity between the merchant billing system and the Android payment terminal in IP connectivity mode.
Language | JAVA | DOTNET |
Signature | boolean testTCP(String IP, String port) | boolean testTCP(string IP, int PORT, IConnectionListener onlinelistner) |
Parameters | IP - Payment terminal IP Port - PoS Bridge port |
IP - Payment terminal IP Port - PoS Bridge port |
Returns | true - Success false - Failure |
true - Success false - Failure |
Call-backs | None | None |
Java
boolean result = PosLib.getInstance().testTcp(ip, port);
DotNet
boolean isOnlineDevice = obj.testTCP(tcpip.Text, int.Parse(tcpport.Text), comListener);
This API will verify connectivity between the merchant billing system and the Android payment terminal in COM connectivity mode.
Language | JAVA | DOTNET |
Signature | boolean testSerialCom(String portName) | boolean testSerialCom(int comPort,IConnectionListener icomlistener) |
Parameters | portName – port number | portName – port number |
Returns | true - Success false - Failure |
true - Success false - Failure |
Call-backs | None | None |
Java
boolean result = PosLib.getInstance().testSerialCom(comPort);
DotNet
isOnlineDevice = obj.testSerialCom(int.Parse(intvalue), comListener);
Language | JAVA | DOTNET |
Signature | public void checkComStatus(ComEventListener comEventListener); | public void checkComStatus(); |
---|---|---|
Parameters |
comEventListener – Com Event listener | None |
Returns | None | 100 (COM connected) 200 (COM disconnected) |
Call-backs |
1000 (TCPIP connected) 1001 (TCPIP disconnected) 1003 (TCPIP error) 3000 (Payment App Down when tcp/ip check) 2000 (COM connected) 2001 (COM disconnected) 2003 (COM error) 3001 (Payment App Down when com check) |
100 (COM connected) 200 (COM disconnected) |
Java
ComEventListener comEventListener = new ComEventListener() { @Override public void onEvent(int eventId) { switch (eventId) { case 1000: // TCP Connected and Payment app is UP // Status: Active break; case 1001: // TCP Disconnected // Status: Inactive break; case 1003: // TCP error // Status: Inactive break; case 3000: // TCP Connected and Payment app is down // Status: Inactive break; case 2000: // com Connected and Payment app is UP // Status: Active break; case 2001: // com Disconnected // Status: Inactive break; case 2003: // com error // Status: Inactive break; case 3001: // com Connected Payment app is down // Status: Inative break; default: // Unknown Event ID break; } } }; PosLibManager.getInstance().checkComStatus(comEventListener);
DotNet
public string checkComStatus(){ Log.Debug("Entering checkComStatus() method"); if (configdata.isAppidle) { if (testSerialCom(configdata.commPortNumber, comListener) && comListener.successcodemsg== PosLibConstant.COMERRORCODESUCESS) { Log.Information("in comEventListener on onEvent : " + comListener.successcodemsg); Log.Information("in comEventListener COM : Connected "); CheckPaymentHealthCheckRequest comhealthcheckrequest = new CheckPaymentHealthCheckRequest(); string requestbody = comhealthcheckrequest.CheckCompHealthRequest(); bool status = CheckBothConnection(configdata.commPortNumber, requestbody); if (status) { return PosLibConstant.COMHEALTHACTIVE; } else { return PosLibConstant.COMHEALTHINACTIVE; } } else { Log.Information("in comEventListener on onEvent : " + comListener.errorcodemsg); Log.Information("in comEventListener COM : DisConnected "); return PosLibConstant.COMHEALTHINACTIVE; } } else { return PosLibConstant.COMHEALTHINACTIVE; } } ConnectionService obj = new ConnectionService(); string checkstatus = obj.checkComStatus();
Signature | public String checkTcpComStatus(); |
---|---|
Parameters | None |
Returns | String |
Call-backs |
400 (TCPIP connected) 300 (TCPIP disconnected) |
DotNet
public string checkTcpComStatus() { if (string.IsNullOrWhiteSpace(configdata.tcpIpPort) || string.IsNullOrWhiteSpace(configdata.tcpIp)) { return PosLibConstant.TCPIPHEALTHINACTIVE; } if (!testTCP(configdata.tcpIp, configdata.tcpPort, comListener)) { LogInformation("TCPIP : Disconnected", comListener.errorcodemsg); return PosLibConstant.TCPIPHEALTHINACTIVE; } LogInformation("TCPIP : Connected", comListener.successcodemsg); if (string.IsNullOrWhiteSpace(configdata.tcpIp) || !configdata.isAppidle || string.IsNullOrWhiteSpace(configdata.tcpIpPort)) { return PosLibConstant.TCPIPHEALTHINACTIVE; } CheckPaymentHealthCheckRequest healthCheckRequest = new CheckPaymentHealthCheckRequest(); string requestBody = healthCheckRequest.CheckTcpIpHealthRequest(); bool isTerminalReachable = IsHostReachable(configdata.tcpIpaddress, int.Parse(configdata.tcpIpPort), requestBody); return isTerminalReachable ? PosLibConstant.TCPIPHEALTHACTIVE : PosLibConstant.TCPIPHEALTHINACTIVE; } ConnectionService obj = new ConnectionService(); string checkstatus = obj.checkTcpComStatus();
This API will be used to perform transactions with the Android Payment Application.
Language | JAVA | DOTNET |
Signature | void doTransaction(String paymentRequest, int transactionType, TransactionListener transactionListener) | void doTransaction(String paymentRequest, int transactionType, TransactionListener transactionListener) |
Parameters |
paymentRequest - Request message body from billing application.
Refer APIs for details of the request payload for each transactions
transactionType = 6 // payment transaction type |
paymentRequest - Request message body from billing application. Refer APIs for details of the request payload for each transactions transactionType = 6 // payment transaction type |
Returns | None | None |
Call-backs |
OnSuccess(String paymentResponse) - paymentResponse data for all the supported transaction types OnFailure(String errorMsg, int errorCode) - Error Message - Error Code |
OnSuccess(String paymentResponse) - paymentResponse data for all the supported transaction types OnFailure(String errorMsg, int errorCode) - Error Message - Error Code |
Error Condition |
• Response timeout • Parsing error • Network down • Comm disconnected |
• Response timeout • Parsing error • Network down • Comm disconnected |
Java
String transactionRequest = null; //Required only for TxnType 6 (Payment Transaction) transactionRequest = "4001,TX12345678,10000,,,,,,"; //sale transaction request transactionRequest = "5101,TX12345678,10000,,,,,,"; //Bank EMI transaction request transactionRequest = "5002,TX12345678,10000,,,,,,"; //Brand EMI transaction request transactionRequest = "5120,TX12345678,10000,,,,,,"; //UPI transaction request int TxnType; //payment transaction type TxnType = 6; //Payment transaction TxnType = 9; //get last transaction TransactionListener transactionListener = new TransactionListener() { @Override public void onSuccess(String paymentResponse) { // success //Convert the payment response from CSV hex string format to byte array format and parse the CSV response. } @Override public void onNext(String action) { // listner for onNext action } @Override public void onFailure(String errorMsg, int errorCode) { // failure //Handle error message and error code here } }; PosLib.getInstance().doTransaction(transactionRequest, transactionListener);
DotNet
public class TransactionDrive : ITransactionListener { public void OnFailure(string errorMsg, int errorCode) { MessageBox.Show(errorMsg, errorCode.ToString()); } public void OnNext(string action) { throw new NotImplementedException(); } public void OnSuccess(string paymentResponse) { resp = paymentResponse; } } TransactionService trxobj = new TransactionService(); trxobj.DoTransaction(afterreplace, int.Parse(transactionType), transactionDrive);
In this approach, the Merchant Billing application running on Windows OS, communicates with the Pine Labs payment application by integrating the PoS Controller. The Pos Controller facilitates communication with the Pine Labs Android payment application via the PoSBridge.
PoS Controller is software that offers a user-friendly interface for integrators. It allows them to scan and set up various communication modes (IP and COM), manage logging, and configure other communication settings.
Step 1:
Ensure that your computer meets the minimum system requirements for the software.
Windows 7, 10, and 11
Step 2: Download the PoS Controller software installation package from here.
Step 3: Double-click the downloaded PoS Controller installer file to begin the installation process.
Step 4: Review and accept the software's licence agreement, and complete the installation process by clicking the "Next" button.
Step 5: Once the installation is complete, click the "Finish" button to complete the installation setup.
Step 6: After installation, PoS Controller software will be opened, and a Boot Up Splash screen followed by the Login screen will be displayed. Enter appropriate details in the cashier ID and cashier name fields.
Step 7: Click on the "Save" button to save the cashier's details.
Step 8: Click on the "Setting" button on the home screen to navigate to setting screen.
Step 9: On the Settings screen, configure the settings for fields 2 to 9 as needed.
Step 10:
Click on the "Scan for Devices" button to scan for all the available online and COM/Serial devices.
Note: Online devices are those where the PoSBridge is currently operational and connected to the same network as the billing system. COM/Serial devices are those where the PoSBridge is currently operational and connected to the same billing system via COM/Serial cable.
Step 11: Once the devices are scanned, the PoS Controller will list all the available devices (both com/serial and online) in the "Available Devices" panel.
Step 12:
Under the "Available Devices" panel, all the available devices are listed with the respective device details (Device ID, Mode, Serial No). User has to select the device based on the details by clicking the select button.
Note:
Step 13: After selecting the devices under the available devices, the selected devices will be displayed under the respective TCP/IP and COM panes.
Step 14: The user can use the "Connect" button to check the connectivity status of TCP/IP or COM.
Step 15:
Click on the "Save Settings" button to save all the configured options.
Note: If the user does not save the configuration, then all the configured values will not be saved in Pos Controller.
PoSLib provides the following features for connectivity retention and configuration:
PoSLib supports logging options to capture transaction exchanges between billing application and PoSLib.
For Setup and installtion instructions for Android components, please refer to the Terminal Setup section.