This document serves as a complete reference guide for individuals seeking to utilize the Pine Labs iOS PoSlib SDK. Its primary focus is to assist in the acceptance of payments, processing of transactions, and the seamless return of payment results to the invoking payment terminal application.
The Billing System can be integrated into the iOS platform in a single way namely Off-Device Integration.
In Off-Device integration approaches, the Merchant Billing application should use the PoSLib to communicate with the PineLabs Payment Application via PoSBridge.
The following sections provide detailed insights into Off-Device Integration processes.
In this approach, the Merchant Billing application, running on iOS devices such as tablets or mobile phones, communicates with the Pine Labs Payment application by integrating the iOS PoSlib. The iOS PoSlib facilitates communication with the pinelabs Payment application via PoSBridge.
The Merchant Billing application needs to integrate PoSlib to communicate with the PoSBridge application through PoSLib APIs. The message exchange between PoSLib and PoSBridge can occur over IP.
The Billing System communicates with PoSBridge application via PoSLib APIs. Message exchange between PoSLib and PoSBridge can happen over IP. The Billing System running on the PineLabs Payment Terminal has the capability to perform transactions via app-to-app communication.
The following sequence diagram describes the transaction flow:
Merchant Billing Application shall be integrated with PoSLib to perform transactions with Payment application
The following features (APIs) are supported by iOS PoSLib:
Supported APIs | Functionality / Description |
---|---|
PosLibServicesImpl | Create an instance of PosLibServicesImpl and initialize it with the PoSlib. This will be the first step towards calling the API. |
scanOnlinePOSDevice | This API will be used to discover/scan for PoS devices in same network (Wi-Fi) |
setConfiguration | This API will be used set the required configuration to PoSLib |
getConfiguration | This API will be used get the configuration settings from PoSLib |
comTest | This API will be used to check for TCPIP connection with PoSBridge |
doTransaction | This API will be used to perform transaction with Payment Application |
This section describes the pre-requisites and steps to integrate POSLib framework with the Merchant Billing Application.
Step 1: Add generated PosLib.xcframework into the Billing Application for debug and release inside Archives -> Binaries -> extracted file -> PosLib.xcframework.
Step 2: Import iOS PoSLib Framework into frameworks folder which is generated in Archives -> Binaries -> PosLib-Bitcode-Debug -> PosLib.xcframework.
Add PosLib.xcframework from framework folder as an embedded content in Billing application project settings (as shown below).
Step 3: Add Local Network Usage Description, Bonjour Services, Bluetooth Always Usage Description and Supported external accessory protocols to info.plist of the Billing Application.
Below section describes the APIs exposed by PoSLib, details of the API and integration sample code snippets.
Note: The sample code snippets provided in this document are currently supported only in Swift. These code snippets might have to be customized if you want to test them on Objective-C.
This API shall be used to Initialize the PoSlib. This shall be the first API to be called.
Signature | var posLibServices: PosLibServicesImpl() |
Description | Once we integrate the PoSLib framework. This is the first step we perform to initialize the PosLibSercies which is done in Splash View Controller |
Parameters | None |
Returns | Creates the object of PosLibServicesImpl class |
Call-backs | None |
Error Condition | None |
Initialize PoSLib using the following code:
Swift
override func viewDidLoad() { super.viewDidLoad() // Create an instance of PosLibServicesImpl posLibServices = PosLibServicesImpl() // Set the text of the "lblVersion" label to display the application version self.lblVersion.text = "Version: \(posLibServices!.getPosLibVersion())" }
This API will discover/Scan the PinLabs payment terminals on the same network where PoSBridge is running on it and list them.
Signature | func scanOnlinePOSDevice(ransactionListener: self) |
---|---|
Description | This API will be used to auto discover/scan for PoS device in same network (Wi-Fi) |
Parameters |
|
Returns | message received |
Call-backs | state update Handler - state |
Error Condition |
|
Swift
@IBAction func scanTCPIPDevices(_ sender: UIButton) { if (networkIP != nil) { // Initiate the scanning process for online POS devices posLibServices!.scanOnlinePOSDevice(transactionListener: self) } else { //Invalid Conditions } }
This class will have the details of the device which will be used during discovery/scan over IP.
Swift
@objc public class ConfigData: NSObject { var cashierID: String = "" var cashierName: String = "" var connectionFallback: Bool = false var connectionPriority: String = "" var connectionTimeout: Int = 0 var connectionRetries: Int = 0 var tcpIP: String = "" var tcpPort: Int var btDeviceName: String = "" var btDeviceSSID: String = "" var networkIpTest: Bool = false; }
This API will set PoS Library configurations related to connectivity, priority settings, and logging options.
Signature | setConfiguration(configData: ConfigData) |
---|---|
Description | Set the required configuration to PosLib |
Parameters | configData - Configuration Data |
Returns | 0 - Success < 0 - Failure |
Call-backs | None |
Error Condition |
|
Swift
func saveConfigurations() { let configData = ConfigData(cashierID: self.settingsItem.cashierID, cashierName: self.settingsItem.cashierName, connectionFallback: self.settingsItem.poslibLogsRequired, connectionPriority: self.settingsItem.connectionPriority, connectionTimeout: self.settingsItem.connectionTimeout, connectionRetries: self.settingsItem.connectionRetries, tcpIP: self.settingsItem.tcpIP, tcpPort: "\(self.settingsItem.tcpPort)", btDeviceName: self.settingsItem.btDeviceName, btDeviceSSID: self.settingsItem.btDeviceSSID) posLibServices!.setConfiguration(configData: configData) }
This API should be used to retrieve PoS Library configurations related to connectivity, priority settings, and logging options.
Signature | getConfiguration() -> ConfigData |
---|---|
Description | Gets the configuration settings from PosLib |
Parameters | None |
Returns | 0 - Success < 0 - Failure |
Call-backs | None |
Error Condition |
|
Swift
@IBAction func testTCPIPConnection(_ sender: UIButton) { if (UserDefaults.standard.bool(forKey: "networkStatus") { let configData = posLibServices!.getConfiguration() } else { //showing alert to enable network to getConfig details and other conditions as well } }
This API will verify connectivity between the merchant billing system and the iOS payment terminal in IP connectivity mode.
Signature | comTest(tcpIp ip: String, tcpPort port: String, transactionListener txnListener: TransactionListener) |
---|---|
Description | This API will be used to check for TCPIP connection |
Parameters |
|
Returns | 0 - Success < 0 - Failure |
Call-backs | None |
Swift
@IBAction func testTCPIPConnection(_ sender: UIButton) { if (networkIP != nil || (UserDefaults.standard.bool(forKey: "networkStatus”))) { posLibServices?.comTest(tcpIp: configData.getTcpIP(), tcpPort: "\(configData.getTcpPort())", transactionListener: self) } else { // Checking Other conditions } }
This API will be used to perform transaction with iOS Payment Application.
Signature | func doTransaction(paymentRequest message: String, transactionType txnType: Int, transactionListener txnListener: TransactionListener) |
Description | This API shall be used for transaction processing with Payment Application |
Parameters |
paymentRequest - Request message body from billing application. transactionType = 6 // payment transaction type |
Returns | None |
Call-backs |
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 |
Swift
@IBAction func processTransactionAction(_ sender: UIButton) { var msgType: Int // take required message type for txn to proceed let txnTypeValue = Constant.transactionValuesList[self.selectedTransaction] let csvString = PosHelper.shared.getCSVStringForTxn((txnTypeValue)!, Constant.TXN_NUM, self.amountTextField.text!) let requestBody = PosHelper.shared.getPaymentPacket(csvString) if (requestBody != "") { posLibServices!.doTransaction(paymentRequest: requestBody, transactionType: msgType, transactionListener: self) } else { /*ERROR CONDITIONS*/ } }
Note : Please refer Transaction type in API's section for more information click here