This section walks through the steps involved in setting up Android terminal applications, such as the Android Sample Billing App and Android PosBridge Application.
The POS Bridge Application can be configured to operate as a Payment Terminal simulator. In this mode, POS Bridge processes payment transactions without connecting to a processor. This setup is useful for integrations that don't require a physical payment terminal.POS Bridge with simulator option enabled can run on any Android mobile device.
POS Bridge Application can be configured to work as Payment Terminal simulator. In this mode, POS Bridge processes the Payment transactions without connecting to processor. This mode can be used for Integrations without the need of Physical Payment terminal as POS Bridge in this mode runs on any Android Mobile
"Simulator Setup" shall have two sections Simulator and Test values. Simulator shall have steps to configure the POS Bridge in demo mode and test values section does not need any changes
POS Bridge in Simulator/Demo mode supports below listed error scenarios which can be tested using the specific transaction amounts listed below
Amount | Transaction Result |
---|---|
401.00 | Successful EMV Contact transaction |
402.00 | Successful EMV Contactless transaction |
403.00 | Successful Magstripe transaction |
404.00 | Declined Contactless transaction |
405.00 | Declined EMV Contact transaction |
406.00 | Declined Magstripe transaction |
407.00 | Declined Sale transaction |
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 POS Bridge application through POS Lib APIs. The message exchange between POS Lib and POS Bridge 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 POS lib. 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 POS lib. 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