# Models

## PsBluetoothDevice (BBPOS Only)

PropertyTypeDescription
Serial NumberNSStringSerial number of BBPOS device.
ManufacturerNSStringManufacturer of device.
ModelNSStringModel of device.

## PsDeviceInfo

PropertyTypeDescription
Device DescriptionNSStringDescription of device.
Serial NumberNSStringSerial number of BBPOS device.
Firmware VersionNSStringDevice Firmware version.
Configuration VersionNSStringDescription config version.
Battery PercentageNSStringBattery percentage of device.
Battery LevelNSStringBattery level of device.

## PsSaleRequest

PropertyTypeDescription
AmountNSDecimalNumberRequired. Min=0.01 Max=2000000.00 Amount to charge of currency. Must be a positive number.
Duplicate CheckNSStringOptional. Default:"enabled" Valid values: "enabled", "disabled". Indicates the duplicate check mode.
CurrencyNSStringOptional. Default:"usd". Type of currency to be collected. Only USD supported at this time (default).
External IdNSStringOptional. <= 50 characters. Unique identifier for the payment in merchant or partner's system.
Card Sale DescriptionNSStringOptional. <= 5000 characters. Text field reserved for partner/merchant use.
CaptureNSString**IDYNAMO ONLY** Optional. Possible values: "completed_sale" "auth_until_capture" "tip_adjustment". 'completed_sale' (default) will authorize and capture the sale at the specified amount. 'auth_until_capture' requires the capture endpoint for the payment to be added to a settlement batch. 'tip_adjustment' allows for the tip_adjustment endpoint to be called up until just prior to the batch close time.
Allow Partial ApprovalsBOOLOptional. Default:FALSE. If true, allows partial approvals. Most useful for gift cards with limited funds.

## PsSaleResponse

PropertyTypeDescription
Transaction IdNSStringUnique Id of transaction.
Acquirer MessageNSStringHost error message returned on failure or decline. Do not base application logic on this message as it may change without notice.
Authorization CodeNSStringAcquirer authorization code.
Approved AmountNSDecimalNumberAmount approved on a partial approval
Batch IdNSNumberSettlement batch id (card only).
CardPsCardDataCard response
OutcomePsSaleOutcomeSale outcome
EmvPsEmvResponseEMV response data if present

## PsSaleOutcome

PropertyTypeDescription
ResultNSStringResult of transaction request. Valid values: "success", "failed", "declined"
CodeNSString4-digit PaySimple result code. The code will not change, so it's safe to create code logic reacting to a specific failure code. Code 1000 indicates success.
Outcome DescriptionNSStringDescription of decline, failure or success. This is in human-readable format, so it is a good practice to display this text to the user in your interface. Don't base logic in your code on this text, as it may change from time to time.

## PsCardData

PropertyTypeDescription
Card BrandNSStringCard brand type. Valid values: "unknown", "visa", "mastercard", "amex", "discover"
Last 4NSStringLast 4 digits of card number.
Expiration MonthNSNumberMonth of card expiration.
Expiration YearNSNumberYear of card expiration in 4 digit format.

## PsEmvResponseData

PropertyTypeDescription
Application IdentifierNSStringApplication Identifier.
Application Preferred NameNSStringApplication Preferred Name.
Application LabelNSStringApplication Label.
CryptogramNSStringCryptogram value.
Host Response CodeNSStringHost Response Code.
Host Response MessageNSStringHost Response Message.

EMV Receipt Requirements

**THE FOLLOWING ARE REQUIRED FOR EMV RECEIPTS** Application Identifier (AID) of the application used. Application Preferred Name (if available and supported) or Application Label Cryptogram type/value Host Response Code/Host Response Message (e.g. 00/AP, etc) Host Response Message

# Methods

## Initialize SDK - Class Method

Initializes the SDK and returns TRUE if initialization occurred without error. This method should only need to be called once while the app is running.


PropertyTypeDescription
devicePsSDKDeviceTypeRequired. Uniquely identifies device type. Possible values: IDYNAMO or BBPOS
environmentNSStringRequired. Environment to use. Possible values: "SBX" for sandbox or "PROD" for production
errorNSErrorRequired. NSError reference to use in case of initialization failure

Example Implementation:



## Re-Initialize SDK - Class Method

Sets the shared instance to nil to allow the SDK to reinitialized with a different device type or environment. You must first disconnect the current device associated with the shared instance.



Disconnect current device first

The code sample below includes disconnecting the current device first which must be done before resetting the SDK.

Example Implementation:



## SharedInstance - Class Method

Returns a shared instance of the PsSDK service.



Example Implementation:



## IsInitialized - Class Method

Returns BOOL to indicate if the SDK has been initialized and a shared instance exists.



Example Implementation:



## Scan for Bluetooth enabled devices (BBPOS only) - Instance Method

**Optional for BBPOS device.** Will scan for all powered on BBPOS devices within range of the iOS device. Executes completion handler once scan is complete (2 - 5 seconds). Allows for connecting to a specific BBPOS device when multiple devices are present. Can associate returned serial numbers with devices and send a specific serial number to connect to in ConnectDeviceWithClientToken. Requires a client token in order to initiate the scan for devices that are enabled for your client/merchant key.


PropertyTypeDescription
clientTokenNSStringRequired. PaySimple Client token that is needed to connect to the BBPOS device
completionHandlerCode BlockRequired. Upon execution passes back a an NSArray of PsBluetoothDevice Also takes **NSError** reference to pass back error information in case of connection failure

Example Implementation:



## ConnectDeviceWithClientToken - Instance Method

**Required for BBPOS device.** Connects to the card reader device. Not required for iDynamo or Rambler implementation. Executes completion handler once connected. Getting a new client token prior to calling this method is strongly recommended to avoid token validation/expiration issues.


PropertyTypeDescription
clientTokenNSStringRequired. PaySimple Client token that is needed to connect to the BBPOS device
serialNumberNSStringOptional. Serial number of device to connect to (eg. @"CHB204839000034"). Can be null or empty string. Will connect to previously connected BBPOS
completionHandlerCode BlockRequired. Upon execution passes back a **BOOL** to indicate if device successfully connected. Returns device info of connected device. Also takes **NSError** reference to pass back error information in case of connection failure

Example Implementation:



## ConnectDeviceWithHandler - Instance Method

Connects to the card reader device. Optional for iDynamo since MakeSale will make the connection for you. Executes completion handler once connected.


PropertyTypeDescription
completionHandlerCode BlockRequired. Upon execution passes back a **BOOL** to indicate if device successfully connected. Returns device info of connected device. Also takes **NSError** reference to pass back error information in case of connection failure

Example Implementation:



## DisconnectDeviceWithHandler - Instance Method

Disconnects the device. Not explicitly needed in most situations but can be used to disconnect the device after a sale is made if you need to do some disconnect based logic in your app or to prevent any further swipe data being read.


PropertyTypeDescription
handlerCode BlockRequired. Upon execution passes back a **BOOL** to indicate if device successfully disconnected. Also takes **NSError** reference to pass back error information in case of disconnection failure

Example Implementation:



## IsDeviceConnected - Instance Method

Returns BOOL to indicate if the device is connected or not.



Example Implementation:



## GetDeviceName - Instance Method

Returns **NSString** of the attached device name. Returns nil if no device is connected. Possible values: "iDynamo", "BBPOS"



Example Implementation:



## GetDeviceBatteryPercentage - Instance Method

Returns **NSString** of the attached device battery percentage. Returns nil if no device is connected. Possible values: "99", "50" etc



Example Implementation:



## MakeSaleWithClientToken - Instance Method

Makes a sale using a PaySimple [Client token](🔗), a **PsSaleRequest** object and a completion handler. Getting a new [Client token](🔗) prior to calling this method is strongly recommended to avoid token validation/expiration issues. For iDynamo this method will automatically attempt to connect to the iDynamo device so explicit separate connection logic is not needed. If no connection can be made to the iDynamo device and error will be returned to allow for retry logic in your implementation.


PropertyTypeDescription
clientTokenNSStringRequired. PaySimple Client token that is needed to make a sale
completionHandlerCode BlockRequired. Upon execution passes back a **PsSaleResponse** object containing relevant sale result data. Also takes **NSError** reference to pass back error information in case of error in the sale flow

Example Implementation:



## StopCurrentBbposFlow - Instance Method

Call this method to stop the current BBPOS sale flow if it has already been started. For example you have prompted the customer to insert, swipe or chip read card. This is stop the sale flow connection with the BBPOS device and reset it to an idle state.



Example Implementation:



# Delegates

## deviceConnectionDidChange - Optional delegate

Delegate fires when the connection status if the device changes.


PropertyTypeDescription
deviceTypeNSStringValid values: "iDynamo", "BBPOS"
isConnectedBoolIndicates if the device is connected or not

Example Implementation:



## onBbposDisplayText - Optional delegate

Delegate fires when the BBPOS device has text to display to the user such as prompts. Examples include "Insert, Swipe or Tap Card", "Remove Card", "Thank you" etc.


PropertyTypeDescription
displayTextNSString"Insert, Swipe or Tap Card", "Remove Card", "Thank you" etc.

Example Implementation:



## onBbposRemoveCard - Optional delegate

Delegate fires when the BBPOS device detects that the card has been removed. Should stop current BBPOS sale flow if this delegate fires.



Example Implementation:



## onBbposDeviceInitializationProgress - Optional delegate

Delegate fires when the BBPOS device pairs with the phone or tablet. Will repeatedly fire until device pairs. First time device pairs to BBPOS, BBPOS must be at least 50% charged.



Example Implementation:



## onBbposBatteryLow - Optional delegate

Delegate fires when the BBPOS device battery level is low



Example Implementation:



## onBbposDidDisconnect - Optional delegate

Delegate fires when the BBPOS device disconnects



Example Implementation:



## onBbposDidError - Optional delegate

Delegate fires when the BBPOS device returns an error that is device related and not sale related.



Example Implementation: