# iOS SDK

## Overview

Sola iOS SDK is a mobile SDK targeted towards Swift mobile application developers; it allows developers to process transactions with the Sola [Transactions API](/api/transaction.md).

{% hint style="info" %}
*Due to the necessity of the API key in this integration method, we strongly recommend reserving these features for integrations to be used solely on merchant-owned devices.*
{% endhint %}

## Getting started

To start, download the SDK framework file:

* [Swift download](https://cdn.cardknox.com/sdk-ios/versions.html)

Integrate the framework file into your XCode project by referring to the [technical documentation](https://docs.cardknox.com/sdk/ios-sdk).

## Choose your integration path

The SDK offers developers a couple of ways to process transactions:

* In scope function
* Out of scope function
* Custom UI set of functions
* Payment Engine set of functions

### Out of scope

Use the out of scope function when the user needs to provide their credit card information. This function displays the SDK user interface, effectively giving the control over to the SDK to acquire the sensitive credit card data from the user. The user provides the sensitive information either via a form or via a credit card device, and then the SDK processes the transaction with the gateway.

### In scope

Use the in scope function when there is no need for the SDK to interact with the user through a user interface. The developer should either pass in a card number + an expiration date, or provide a tokenized card data via the xToken parameter to this function to quickly process the transaction and retrieve back the results.

### Custom UI

Custom-UI integration consists of a set of functions to control the card reader device via the SDK. Currently supported card reader device is a Bluetooth VP3300 card reader. This integration path is useful when the developer has an existing UI and wishes to use a card reader device to obtain users' card sensitive information and then process the transaction with the gateway. The SDK offers a set of functions to control the card reader device. The SDK takes care of processing with the gateway and notifying the Developer’s application with the processing results.

The SDK offers the following functions: “start scanning for devices”, “stop scanning for devices”, “connect to device”, “disconnect from device”, “start transaction”, “stop transaction”.

#### Payment Engine <a href="#payment-engine" id="payment-engine"></a>

The Payment Engine feature inside the SDK enables you to create transactions with a card reader over IP. The Payment Engine supports different card readers from Pax, Verifone, and Ingenico brands. See a full list of supported devices in the table below. The feature doesn't contain any UI. The developer provides device and transaction parameters to Payment Engine functions. The SDK takes care of communicating with the card reader and processing with the gateway. Finally, the SDK returns the device and transaction status and states.

| **Brand**                                  | **Model**            | **Suffix**                                | **Parameter value** |
| ------------------------------------------ | -------------------- | ----------------------------------------- | ------------------- |
| <p> </p><p> </p><p> </p><p> </p><p>Pax</p> | SP30                 | <p> </p><p> </p><p> </p><p> </p><p>.3</p> | Pax\_SP30.3         |
| S300                                       | Pax\_S300.3          |                                           |                     |
| S920                                       | Pax\_S920.3          |                                           |                     |
| A35                                        | Pax\_A35.3           |                                           |                     |
| A60                                        | Pax\_A60.3           |                                           |                     |
| A77                                        | Pax\_A773            |                                           |                     |
| A80                                        | Pax\_A80.3           |                                           |                     |
| A920                                       | Pax\_A920.3          |                                           |                     |
| PX5                                        | Pax\_PX5.3           |                                           |                     |
| PX7                                        | Pax\_PX7.3           |                                           |                     |
| D210                                       | Pax\_D210.3          |                                           |                     |
| D220                                       | Pax\_D22.3           |                                           |                     |
| Aries6                                     | Pax\_Aries6.3        |                                           |                     |
| Aries8                                     | Pax\_Aries8.3        |                                           |                     |
| <p> </p><p> </p><p> </p><p>Verifone</p>    | MX915                | <p> </p><p> </p><p> </p><p>.4</p>         | Verifone\_MX915.4   |
| MX925                                      | Verifone\_MX925.4    |                                           |                     |
| P200                                       | Verifone\_P200.4     |                                           |                     |
| P400                                       | Verifone\_P400.4     |                                           |                     |
| M400                                       | Verifone\_M400.4     |                                           |                     |
| E285                                       | Verifone\_E2854      |                                           |                     |
| <p> </p><p>Ingenico</p>                    | ICT250               | <p> </p><p>.2</p>                         | Ingenico\_ICT250.2  |
| Desk500                                    | Ingenico\_Desk5000.2 |                                           |                     |
| Move500                                    | Ingenico\_Move5000.2 |                                           |                     |

## Transaction workflows

Click here to view the transaction workflows online.

Download our sample application:

* [Swift with SwiftUI app](https://cdn.cardknox.com/sdk-ios/versions.html)

### Basic parameters

| **Name**      | **Required** | **Description**       | **Sample data**   |
| ------------- | ------------ | --------------------- | ----------------- |
| xKey          | Yes          | Sola account key      | SolaSupport\_Test |
| xVersion      | Yes          | Gateway version       | 4.5.9             |
| xSoftwareName | Yes          | Name of your software | My app            |

### Basic parameter functions

Prior to any processing, the Sola SDK needs to be configured with user’s metadata and the account key. These functions can be called anywhere in the application any number of times to change the metadata and/or current account key.

| **Function**     | **Description**                                                                                                                                                                                       |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| setxSoftwareName | Specifies the name of your software (xSoftwareName), version number of your software (xSoftwareVersion) and the gateway version (xVersion)                                                            |
|                  | **Sample data (Swift)**                                                                                                                                                                               |
|                  | <p>CardknoxSDK.setxSoftwareName("Your app name",<br>xSoftwareVersion: "Your app version, such as 1.0.0",<br>xVersion: "4.5.9");</p>                                                                   |
|                  | **Sample data (Objective C)**                                                                                                                                                                         |
|                  | <p>\[CardknoxSDK setxSoftwareName:@"Your app name"<br>xSoftwareVersion:@"Your app version, such as 1.0.0"<br>xVersion:@"4.5.9"];</p>                                                                  |
| setPrincipalKey  | <p>Accepts the xKey.</p><p>xKey is a Sola account key.</p><p>All transactions being processed after calling this function will be associated to the account that was passed in into the function.</p> |
|                  | **Sample data (Swift)**                                                                                                                                                                               |
|                  | CardknoxSDK.setPrincipalKey("Your xKey value")                                                                                                                                                        |
|                  | **Sample data (Objective C)**                                                                                                                                                                         |
|                  | \[CardknoxSDK setPrincipalKey:@"Your xKey value"];                                                                                                                                                    |

### Transaction required parameters

Each integration path has a “process” function that accepts a “transaction parameters” object. Developers specify required values for transaction processing through that object. Same object can be used to specify optional parameters to associate with a transaction; such as invoice numbers, billing address, etc.

| **Name** | **Description**       | **Sample data** |
| -------- | --------------------- | --------------- |
| xCommand | Sola transaction type | cc:sale         |

### Transaction optional parameters

Optional transaction parameters further complement the transaction processing. All the parameters are being sent to the Gateway during processing.

| **Name**                 | **Description**                                                                                                                                                                                                                                                                                                                                               | **Sample data**                                                                                                            |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| VP3300TransactionTimeout | <p>Start transaction timeout, in seconds.<br></p><p>Once the transaction with the VP3300 reader is started; the SDK times out if the card is not provided in the time frame specified by this timeout value.<br></p><p>This parameter is only applicable for SDK integrations that use a VP3300 card reader; such as CustomUI or OutOfScope integrations.</p> | Refer to the Custom UI flow or Out Of Scope flow for samples.                                                              |
| xCardNum                 | Card number                                                                                                                                                                                                                                                                                                                                                   | 4444333322221111                                                                                                           |
| xExpDate                 | <p>Card expiration date.</p><p>Expected format is MMYY where MM is a month, and YY are last 2 year digits</p>                                                                                                                                                                                                                                                 | <p>“1126” for (November 2026)</p><p>“0122” for “January 2022”</p>                                                          |
| xToken                   | <p>From <a href="/pages/g1gMqjuhO4qESS2Yro3k">Transaction API:</a></p><p>The Sola token that references a previously used payment method. When using a token, <code>xCardNum</code> <code>xExp</code> and <code>xMagstripe</code> should not be used.</p>                                                                                                     | 61h72mmh68phn9q233634ph3g54p1499m69qhp4816pn528h84                                                                         |
| xRefNum                  | Used to reference a previous transaction when doing a follow-up transaction, typically a refund, void, or capture.                                                                                                                                                                                                                                            | 12345678                                                                                                                   |
| xInvoice                 | The merchant’s invoice number for the transaction. xInvoice is recommended when available for improved duplicate handling.                                                                                                                                                                                                                                    | The merchant’s invoice number for the transaction. xInvoice is recommended when available for improved duplicate handling. |
| xPoNum                   | The merchant’s purchase order number for the transaction.                                                                                                                                                                                                                                                                                                     | 123485                                                                                                                     |
| xDescription             | This is a description                                                                                                                                                                                                                                                                                                                                         | This is a description                                                                                                      |
| xName                    | The cardholder’s name.                                                                                                                                                                                                                                                                                                                                        | John Doe                                                                                                                   |
| xBillFirstName           | The customer’s first name for their billing profile.                                                                                                                                                                                                                                                                                                          | John                                                                                                                       |
| xBillLastName            | The customer’s last/family name for their billing profile.                                                                                                                                                                                                                                                                                                    | Doe                                                                                                                        |
| xBillCompany             | The customer’s company name for their billing profile.                                                                                                                                                                                                                                                                                                        | Acme                                                                                                                       |
| xBillStreet              | The customer’s street address for their billing profile.                                                                                                                                                                                                                                                                                                      | 123 Any Street                                                                                                             |
| xBillStreet2             | The customer’s second street address for their billing profile.                                                                                                                                                                                                                                                                                               | 123 Any Street                                                                                                             |
| xBillCity                | The customer’s city for their billing profile.                                                                                                                                                                                                                                                                                                                | Anytown                                                                                                                    |
| xBillState               | The customer’s state for their billing profile.                                                                                                                                                                                                                                                                                                               | NY                                                                                                                         |
| xBillZip                 | The customer’s zip code for their billing profile.                                                                                                                                                                                                                                                                                                            | 12345                                                                                                                      |
| xBillCountry             | The customer’s phone number for their billing profile.                                                                                                                                                                                                                                                                                                        | USA                                                                                                                        |
| xBillPhone               | The customer’s phone number for their billing profile.                                                                                                                                                                                                                                                                                                        | 8005551212                                                                                                                 |
| xShipFirstName           | The customer’s last/family name for their shipping profile.                                                                                                                                                                                                                                                                                                   | John                                                                                                                       |
| xShipLastName            | The customer’s last/family name for their shipping profile.                                                                                                                                                                                                                                                                                                   | Doe                                                                                                                        |
| xShipCompany             | The customer’s company name for their shipping profile.                                                                                                                                                                                                                                                                                                       | Acme                                                                                                                       |
| xShipStreet              | The customer’s street address for their shipping profile.                                                                                                                                                                                                                                                                                                     | 123 Any Street                                                                                                             |
| xShipStreet2             | The customer’s second street address for their shipping profile.                                                                                                                                                                                                                                                                                              | 123 Any Street                                                                                                             |
| xShipCity                | The customer’s city for their shipping profile.                                                                                                                                                                                                                                                                                                               | Anytown                                                                                                                    |
| xShipState               | The customer’s state for their shipping profile.                                                                                                                                                                                                                                                                                                              | NY                                                                                                                         |
| xShipZip                 | The customer’s zip code for their shipping profile.                                                                                                                                                                                                                                                                                                           | 12345                                                                                                                      |
| xShipCountry             | The customer’s country for their shipping profile.                                                                                                                                                                                                                                                                                                            | USA                                                                                                                        |
| xShipPhone               | The customer’s phone number for their shipping profile.                                                                                                                                                                                                                                                                                                       | 1113333444                                                                                                                 |
| xCustom01                | Custom field 1. Use this for any additional data                                                                                                                                                                                                                                                                                                              |                                                                                                                            |
| xCustom02                | Custom field 2. Use this for any additional data                                                                                                                                                                                                                                                                                                              |                                                                                                                            |
| xCustom03                | Custom field 3. Use this for any additional data                                                                                                                                                                                                                                                                                                              |                                                                                                                            |
| xAuthCode                | xAuthCode is a verification number provided by the issuing bank to be used with the cc:postauth command.                                                                                                                                                                                                                                                      |                                                                                                                            |
| xAllowDuplicate          | By default, Sola rejects duplicate transactions within 10 minutes of the original transaction. This command overrides that safeguard. True/False allowed.                                                                                                                                                                                                     | False                                                                                                                      |
| xCustReceipt             | True/False value indicating if the email address specified in xEmail should receive a receipt containing the transaction details.                                                                                                                                                                                                                             | False                                                                                                                      |
| xEmail                   | The customer’s email address.                                                                                                                                                                                                                                                                                                                                 | <test@example.com>                                                                                                         |

### Retrieving results with callbacks

The SDK can notify the application about various events during processing, such as about different card reader events during out of scope processing, or perhaps about a completed bluetooth device scan during custom UI processing.

Developers opt in to receive callbacks by subscribing to the NSNotificationCenter using one of its' methods, using a predefined value from the SDK for the “name” parameter.

The SDK uses the same “name” value to report results & various information back to subscribers.

Available callback types and integrations where they are applicable in are as follows:

| **Callback type**        | **Description**                                                                                                                                                                                                                                                                                                                                            | **Available in integration**        |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| Transaction result       | The SDK processes a payment with the Gateway and delivers an object containing all processed transaction details.                                                                                                                                                                                                                                          | <p>Out of scope</p><p>Custom UI</p> |
| Card reader event        | The SDK keeps informing the subscribers about various events taking place between the application and the card reader device; such as “connected”, “disconnected”, “transaction started”, “on bluetooth disabled error”, etc.                                                                                                                              | <p>Out of scope</p><p>Custom UI</p> |
| Scanned bluetooth device | <p>Trigger a bluetooth device scanning process with the “start scanning” function.</p><p>During the scanning process, the SDK keeps informing subscribers with objects that encapsulate all the information about each newly discovered Bluetooth device.</p><p>The SDK expects one of the objects as an argument in the “connect to device” function.</p> | Custom UI                           |
| Scan completed           | <p>Trigger a bluetooth device scanning process with the “start scanning” function.</p><p>Stop the process with a “stop scanning” function.</p><p>Once the scanning process is stopped, the SDK reports back a list of all scanned bluetooth devices.</p><p>The SDK expects one of the objects as an argument in the “connect to device” function.</p>      | Custom UI                           |
| Device status            | <p>The SDK is sending information to subscribers about the device initialization process and the actions that the device expects from the user of the card scanner.<br><br>For example, waiting for the insert or swipe of a credit card.</p>                                                                                                              | Payment Engine                      |
| Transaction status       | The transaction status sends information about the card scanning process.                                                                                                                                                                                                                                                                                  | Payment Engine                      |

### Callback subscriptions & result handling

Based on your integration path choice, choose an available callback type for that integration path and subscribe with the NSNotificationCenter to receive appropriate information back from the SDK.

#### Transaction result callback subscription

This callback delivers a “transaction processed response” object to the subscriber.

For Swift applications using Swift UI, subscription can be made in a View as follows:

```swift
import SwiftUI

struct ProcessOutOfScopeView: View 
{
  // Define a Publisher
  let transactionPublisher =
  NotificationCenter.default.publisher(for: NSNotification.Name(CardknoxSDK.transactionResultSubscription_NSNotificationCenterName()))

  var body: some View
  {
    VStack{}
    // Subscribe the Publisher with the NotificationCenter
    .onReceive(transactionPublisher, perform: transactionNotification)
  }
  
  // Define a function that accepts a Notification.
  // This method will be invoked when the SDK sends transaction processing results
  func transactionNotification(notif: Notification) {
  
    // Use the SDK's "response" object utility method to transform a Notification into a "response" object
    let response = PaymentTransactionResponse.unwrap(notif) as! PaymentTransactionResponse
  
    if response.isSuccess()
    {
        // Transaction successfully processed
        let errorMessage = response.errorMessage()!
        let refNum = response.xRefNum()!
        // ... other properties ...
    } else {
        // Transaction processing resulted in an error message which can be extracted from this property:
        let errorMessage = response.errorMessage()!
        let errorCode = response.xErrorCode()!
        let error = response.xError()!
    }
  }
}
```

#### Card reader event callback subscription

This callback delivers information about various events happening between the application & the card reader.

For example, while out-of-scope processing the SDK can report back error events related to bluetooth device pairing, such as “bluetooth not turned on” to indicate that the mobile device wanted to use the bluetooth service to find a near card reader device but the service is unavailable, or an error such as “waiting for device bluetooth response” to indicate that the mobile device found an eligible bluetooth card reader device, and is expecting the card reader to respond back with bluetooth data. This could mean that the bluetooth button on the card reader needs to be pressed.

After an established bluetooth pair, the SDK reports back events related to obtaining the card data via the card reader. For example, a “connected” event means that the mobile device & the card reader are connected and a card data transaction can start. A “transaction started” event means that the SDK initiated a card data transaction with the card reader and the physical card can be tapped onto the card reader.

For Swift applications using Swift UI, subscription can be made in a View as follows:

{% code lineNumbers="true" %}

```swift
import SwiftUI

struct ProcessOutOfScopeView: View 
{
  // Define a Publisher
  let cardReaderEventPublisher =
  NotificationCenter.default.publisher(for: NSNotification.Name(CardknoxSDK.cardreaderEventSubscription_NSNotificationCenterName()))
  
  var body: some View
  {
    VStack{}
    // Subscribe the Publisher with the NotificationCenter
    .onReceive(cardReaderEventPublisher, perform: cardReaderEventNotification)
  }
  
  // Define a function that accepts a Notification.
  // This method will be invoked when the SDK sends card reader events
  func cardReaderEventNotification(aNotification: Notification){
    // Use the SDK's "response" object utility method to transform a Notification into a "response" object
    let callback = CardknoxCardReaderCallback.unwrap(aNotification) as! CardknoxCardReaderCallback
    
    // Read the event code
    let code : Int32 = callback.code();
    // Read the event name
    let name: String = callback.name()!;
    
    NSLog(String(format: "Card reader - %@", name));
    
    // Match the non-error code
    if(code == CardknoxCardReaderCallbackType.connected())
    {
        NSLog("Connected!");
    }
    
    // Match the error code & get the message
    if(code == CardknoxCardReaderCallbackType.error())
    {
        let errorMessage : String = callback.message()!;
        NSLog(String(format: "Card reader - %@", errorMessage));
    }
  }
}
```

{% endcode %}

#### Card reader events <a href="#card-reader-events" id="card-reader-events"></a>

When a card reader event happens, the SDK delivers an object, of a type named similarly to “CardknoxCardReaderCallback”, back into the app.

The object encapsulates two things:

* an event integer code
* an event name; such as “connected”, “disconnected”, etc.

Event integer codes are enumerated in a type named similarly to "CardknoxCardReaderCallbackType".

Developer can match the received integer code value with the enumeration of interest to pinpoint a wanted event.

| **Event name**                        | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| connecting                            | <p>The Sola SDK calls into the card reader SDK to connect with the reader, in scenarios such as:</p><ul><li>“connect to device” method in the “custom ui” integration</li><li>when it presents its own UI in “process out of scope” integration</li></ul><p>The card reader SDK starts searching for nearby IDTech card readers & notifies the Sola SDK with a “connecting” event.</p><p>The Sola SDK raises a “connecting” callback which notifies the app.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| waitingForDeviceResponse              | <p>This event is raised whenever the Sola SDK scans for nearby card readers. Awake readers are usually auto connected straight away.</p><p>Asleep or not, this event is always raised from the SDK to indicate that some action is required on the device.</p><p>This event is raised in the “custom ui” integration when:</p><ul><li>a Developer calls the “start scanning” method and the underlying bluetooth adapter starts scanning</li><li>or when a Developer calls the “connect to device” method. Sola SDK will call the card reader SDk to “connect” and raise this event</li></ul><p>This event is raised in the “process out of scope” integration when:</p><ul><li>the Sola SDK presents its user interface; automatically starting a bluetooth scan for a nearby card reader, expecting a response back</li></ul>                                                                                                                          |
| connected                             | <p>Raised when the app & the card reader establish a bluetooth connection.</p><p>Bluetooth connection is established when the Sola SDK scans for card readers, and card readers respond back with some bluetooth payload.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| disconnected                          | <p>Card reader SDK sends this event to the Sola SDK whenever a bluetooth card reader goes to sleep.</p><p>This event is never raised explicitly by the Sola SDK.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| transactionStarting                   | <p>Informational event.</p><p>Sola SDK raises this event before it places a call to the underlying card reader SDK in order to start a transaction with the card reader.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| transactionStarted                    | <p>Sola SDK attempts a “start transaction” call with the card reader SDK.</p><p>Card reader SDK successfully starts the transaction and notifies the Sola SDK with this event.</p><p>Sola SDK calls back with this event to the app.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| transaction start error timeout       | <p>Sola SDK attempts a “start transaction” call with the card reader SDK.</p><p>The card reader never receives a card in a specified timeout frame window (about 10 seconds) and the transaction times out.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| transaction start device disconnected | Sola SDK wants to start the transaction with a disconnected device.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| transactionCancelled                  | <p>Generally, this is raised whenever an error occurs at any point between starting a transaction with the reader and obtaining the card data.</p><p>See the “error” event for error examples.</p><p>The Sola SDK in cases of these errors preventively calls the “cancel any pending transactions” internally to clean up.</p><p>Specifically, this event is raised in the “custom ui” integration when:</p><ul><li>a “cancel transaction” method is called & the card reader SDK cancels all pending transactions between the app & the card reader</li></ul><p>Furthermore, this event is raised in the “process out of scope” integration when:</p><ul><li>the Sola SDK’s user interface is closed; either via a pull down gesture or via a “close” UI element; to clean things up</li><li>the charge amount gets modified via UI and becomes invalid, effectively invalidating any pending transactions between the app & the card reader</li></ul> |
| scanStop                              | <p>Indicates that the Sola SDK stopped its own bluetooth scanning.</p><p>Raised in the “custom ui” integration when:</p><ul><li>a Developer explicitly calls the “stop scanning” method</li><li>when the “start scanning” method was called with a timeout value and the timeout expired or was cancelled / interrupted</li><li>in the “disconnect from current device” call if the “connect to device” method was called beforehand but there is no connected device to disconnect from</li></ul><p>Raised in the “process out of scope” integration when:</p><ul><li>the SDK shows its' UI and automatically starts scanning for nearby readers. User can explicitly stop the scanning process</li></ul>                                                                                                                                                                                                                                               |
| scanStart                             | <p>Indicates that the Sola SDK started a bluetooth scanning process.</p><p>Raised in the “custom ui” integration when:</p><ul><li>the “start scanning” method was called, with or without a timeout value</li></ul><p>Raised in the “process out of scope” integration when:</p><ul><li>the SDK shows its' UI and automatically starts scanning for nearby readers</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| error                                 | <p>This is raised whenever an error occurs at any point between starting a transaction with the reader and obtaining the card data.</p><p>Things that might go wrong (not a complete list) are:</p><ul><li>transaction with the card reader failed to start</li><li>EMV card readings are corrupted</li><li>transaction started but the card was not tapped / swiped / inserted in time</li></ul><p>An descriptive error message is always accompanying this event.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

#### Scanned bluetooth device callback subscription

One of the Custom UI integration functions is a “start scanning” function. The function keeps scanning for nearby bluetooth devices until it is manually stopped with the “stop scanning” function or if it times out.

During the scanning process, for every scanned device the SDK sends a “scanned device” object that contains all the necessary metadata about the scanned device, such as the devices' display name or its internal name.

For Swift applications using Swift UI, subscription can be made in a View as follows:

{% code lineNumbers="true" %}

```swift
import SwiftUI

struct CustomUIView: View 
{
  // Track a scanned device
  @State private var scannedDevice : CardknoxSDKCustomUIScannedDevice!;
  
  // Define a Publisher
  let customUIscannedDeviceSubscription =
  NotificationCenter.default.publisher(for: NSNotification.Name(CardknoxSDKCustomUI.customUI_scannedDevice_Subscription_NSNotificationCenterName()))
  
  var body: some View
  {
    VStack{}
    // Subscribe the Publisher with the NotificationCenter
    .onReceive(customUIscannedDeviceSubscription, perform: customUIscannedDeviceSubscription)
}
  
  // Define a function that accepts a Notification.
  // This method will be invoked when the SDK sends scanned device information
  func customUIscannedDeviceSubscription(aNotification: Notification){
      // Use the SDK's "response" object utility method to transform a Notification into a "response" object
      scannedDevice = CardknoxSDKCustomUIScannedDevice.from(aNotification) as! CardknoxSDKCustomUIScannedDevice;
      let name = scannedDevice.name();
      let displayName = scannedDevice.displayName();
      let uuid = scannedDevice.uuid();
  }
}
```

{% endcode %}

#### Scan completed callback subscription

One of the Custom UI integration functions is a “start scanning” function. The function keeps scanning for nearby bluetooth devices until it is manually stopped with the “stop scanning” function or if it times out.

Once the scanning process ends, the SDK sends a list of scanned device objects to all subscribers. Any object in the retrieved list can be used as an argument to the “connect to device” method.

For Swift applications using Swift UI, subscription can be made in a View as follows:

{% code lineNumbers="true" %}

```swift
import SwiftUI

struct CustomUIView: View 
{
  // Track a scanned device
  @State private var scannedDevice : CardknoxSDKCustomUIScannedDevice!;
  
  // Define a Publisher
  let customUIscanCompletedSubscription =
  NotificationCenter.default.publisher(for: NSNotification.Name(CardknoxSDKCustomUI.customUI_scanCompleted_Subscription_NSNotificationCenterName()))
  
  var body: some View
  {
    VStack{}
    // Subscribe the Publisher with the NotificationCenter
    .onReceive(customUIscanCompletedSubscription, perform: customUIscanCompletedNotification(aNotification:))
  }
  
  // Define a function that accepts a Notification.
  // This method will be invoked when the SDK stops the scanning process and sends back all scanned devices
  func customUIscanCompletedNotification(aNotification: Notification){
      let scanCompleted = CardknoxSDKCustomUIScanCompleted.from(aNotification) as! CardknoxSDKCustomUIScanCompleted;
      let devices : Array<Any> = scanCompleted.scannedDevices();
      
      // Example to get a first scanned VP3300 device.
      // All VP3300 devices have their internal name start with IDTECH prefix
      if(devices != nil && devices.count > 0)
      {
          for dev in devices{
              let typedDevice = dev as! CardknoxSDKCustomUIScannedDevice
              let name = typedDevice.name()!;
              
              if name.hasPrefix("IDTECH")
              {
                  // Save the reference & use it with the "connect to device" method
                  scannedDevice = typedDevice;
                  break;
              }
          }
      }
  }
}
```

{% endcode %}

#### Device status callback subscription <a href="#device-status-callback-subscription" id="device-status-callback-subscription"></a>

This callback provides information about the status of the card reader. It sends information about the initialization process of the device, the connection process of the card reader, and the mobile device. It also sends notifications about the actions expected by the user of the credit card.

For Swift applications using Swift UI, subscription can be made in a View as follows:

```swift
import SwiftUI

struct PaymentEngineView: View 
{
    // Define a Publisher
    let deviceStatusSubscription =
      NotificationCenter.default.publisher(for:
      NSNotification.Name(CardknoxPaymentEngineSDK.deviceStatus_NSNotification_Name()))
    
    var body: some View
    {
      VStack{}
      // Subscribe the Publisher with the NotificationCenter
      .onReceive(deviceStatusSubscription, perform: deviceStatusNotification(aNotification:))
    }
    
    // Define a function that accepts a Notification.
    // This method will be invoked when the SDK sends information about card reader status   
    func deviceStatusNotification(aNotification: Notification)
    {
        // Use the SDK's "response" object utility method to transform a Notification into a "response" object
        let status = CardknoxPaymentEngineSDK.unwrapDeviceStatus(with: aNotification) as String;
    }
}
```

#### Transaction status callback subscription <a href="#transaction-status-callback-subscription" id="transaction-status-callback-subscription"></a>

The transaction status callback sends information about the card scanning process. This callback starts triggering when the user inserts or swipes the credit card and ends with the result of card scanning.

For Swift applications using Swift UI, subscription can be made in a View as follows:

```swift
import SwiftUI

struct PaymentEngineView: View 
{
    // Define a Publisher
    let transactionStatusSubscription =
    NotificationCenter.default.publisher(for:
    NSNotification.Name(CardknoxPaymentEngineSDK.transactionStatus_NSNotification_Name()))
    
    var body: some View
    {
      VStack{}
      // Subscribe the Publisher with the NotificationCenter
      .onReceive(transactionStatusSubscription, perform: transactionStatusNotification(aNotification:))
    }
    
      // Define a function that accepts a Notification.
    // This method will be invoked when the SDK sends information about card scanning
    func transactionStatusNotification(aNotification: Notification){
        // Use the SDK's "response" object utility method to transform a Notification into a "response" object
        let status = CardknoxPaymentEngineSDK.unwrapTransactionStatus(with: aNotification) as String;
        let line = "transaction status: " + status;
        addLineToOutput(line: line)
    }
}
```

### Out of scope integration

Out of scope processing feature allows the developer to show the Cardknox user interface for payment processing.

To show the user interface, create a request object that is capable of showing a user interface:

```swift
// Create the parameters object
let prms : TransactionParameters = TransactionParameters.init()
prms.xAmount = 1.23;
prms.xInvoice = "1234";
prms.xCommand = "cc:sale";
// ... other fields.

// Create the request object
let request = CardknoxSDK.create().getOutOfScope().createRequest(withParameters: prms) as! PaymentTransactionRequestUI
```

```swift
// Create the parameters object
TransactionParameters *prms = [[TransactionParameters alloc] init];
prms.xAmount = 1.23;
prms.xInvoice = @"1234";
prms.xCommand = @"cc:sale";
// ... other fields.

// Create the request object
PaymentTransactionRequestUI * request = [cardknoxUI createRequestWithParameters:prms];
```

Check if the request object is in a valid state. If it is, call the method to show the UI. Otherwise, inspect the validation errors to see what is incorrect in the request object:

```swift
let request = CardknoxSDK.create().getOutOfScope().createRequest(withParameters: prms) as! PaymentTransactionRequestUI

if(request.isValid){
  request.process()
}
else{
  let errors = request.validationErrors;
}
```

```swift
PaymentTransactionRequestUI * request = [cardknoxUI createRequestWithParameters:prms];

if([request IsValid]){
  [request process];
}
else{
  NSArray* errors = request.ValidationErrors;
}
```

#### Available user interfaces

The SDK’s user interface consists of two fullscreen parts - a manual entry screen and a card reader screen. Manual entry screen is also abbreviated as a “keyed” screen. The card reader screen is also abbreviated as a “swipe” screen.

Showing the SDK user interface via a Request object will either show one of the screens, or both. Which screen will be visible depends on the global SDK configuration state prior to showing the SDK user interface via a Request object.

Note that if the SDK is configured to allow access to both processing screens, one of them will be shown by default and both of them will have some kind of a visual way to navigate to the other one.

The following table shows available functions to control which screen will be visible & accessible:

| **Function**               | **Description**                                                                            |
| -------------------------- | ------------------------------------------------------------------------------------------ |
| EnableKeyedEntry           | Globally configures the SDK to show the keyed screen that allows manual input interaction. |
|                            | **Sample data**                                                                            |
|                            | CardknoxSDKUI.setEnableKeyedEntry(true);                                                   |
| EnableDeviceInsertSwipeTap | Globally configures the SDK to show the swipe screen that allows card reader interaction.  |
|                            | **Sample data**                                                                            |
|                            | CardknoxSDKUI.setEnableDeviceInsertSwipeTap(true);                                         |

The following mapping represents which screens will be available when the SDK shows its user interface:

| **EnableDeviceInsertSwipeTap** | **EnableKeyedEntry** | **Keyed screen available** | **Swipe screen available** |
| ------------------------------ | -------------------- | -------------------------- | -------------------------- |
| false                          | false                | Yes                        | No                         |
| true                           | false                | No                         | Yes                        |
| false                          | true                 | Yes                        | No                         |
| true                           | true                 | Yes                        | Yes                        |

<figure><img src="/files/UjZacSfI7F9tObaGSTE2" alt=""><figcaption><p>Example of a <strong>keyed</strong> user interface. Keyed screen has a top right corner icon to navigate to the <strong>swipe</strong> screen.</p></figcaption></figure>

<figure><img src="/files/CXWBq29lRtuFktcQfG8s" alt=""><figcaption><p>Example of a <strong>swipe</strong> user interface. The <strong>swipe</strong> screen contains a button on the bottom that navigates the user to the <strong>keyed</strong> user interface.</p></figcaption></figure>

The following mapping represents available Sola Transaction API commands on each user interface:

| **Keyed**                        | **Swipe**                                                                                                                                                                                                                                                                             |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Any Sola Transaction API command | <p>Any of the following credit card commands:</p><ul><li>cc:save</li><li>cc:credit</li><li>cc:authonly</li><li>cc:sale</li></ul><p>Reference: <a href="https://docs.solapayments.com/api/transaction/credit-card"><https://docs.solapayments.com/api/transaction/credit-card></a></p> |

**Pre processing options**

Developer using the Out Of Scope integration to process using the VP3300 card reader can specify a per-request transaction timeout value. The SDK will start a transaction with the VP3300 reader, and timeout in the specified time frame if the card is not tapped, swiped or inserted in that same time frame.

| **Function/property**    | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| VP3300TransactionTimeout | Start transaction value, in seconds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|                          | **Sample data (Swift)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|                          | <p><strong>let</strong> ui = CardknoxSDKUI.create();</p><p><strong>let</strong> parameters : TransactionParameters = TransactionParameters.init()</p><p>parameters.vp3300TransactionTimeout = 13;</p><p><strong>let</strong> req = cardknoxSDKUI?.createRequest(withParameters: parameters) <strong>as</strong>! PaymentTransactionRequestUI</p><p>// Enable swipe screen in the Cardknox UI</p><p>CardknoxSDKUI.setEnableDeviceInsertSwipeTap(<strong>true</strong>)</p><p>// Show Cardknox UI</p><p>req.process();</p> |

#### Post processing options

After the out-of-scope function finishes with transaction processing, the SDK displays a popup containing a handful of information about the transaction.

SDK can be configured to auto close the user interface immediately after the transaction processing has completed; regardless if the transaction was approved or not.

| **Function**                     | **Description**                                                                                                                   |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| CloseSDKOnUIProcessedTransaction | <p>Globally configures the SDK to auto close the user interface after processing a transaction.</p><p>Default value is false.</p> |
|                                  | **Sample data (Swift)**                                                                                                           |
|                                  | CardknoxSDKUI.setCloseOnProcessedTransaction(true);                                                                               |

![Example of a success popup](/files/KHNWT02j3SOQvvfKO22y)

![Example of an error popup](/files/YAicwboSyehHeHQgs86p)

### In scope integration

In scope processing feature allows the developer to quickly process a payment and retrieve the response object.

To process directly, create a request object:

{% tabs %}
{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
// Create the parameters object
let prms : TransactionParameters = TransactionParameters.init()
prms.xAmount = 1.23;
prms.xInvoice = "1234";
prms.xCommand = "cc:sale";
// ... other fields.

// Create the request object
let request = cardknoxDirect.createRequest(withParameters: prms) as! PaymentTransactionRequestDirect;
```

{% endcode %}
{% endtab %}
{% endtabs %}

```swift
// Create the parameters object
TransactionParameters *prms = [[TransactionParameters alloc] init];
prms.xAmount = 1.23;
prms.xInvoice = @"1234";
prms.xCommand = @"cc:sale";
// ... other fields.

// Create the request object
PaymentTransactionRequestDirect* request = [cardknoxDirect createRequestWithParameters:prms];
```

Check if the request object is in a valid state. If it is, call the method to process directly. Otherwise, inspect the validation errors to see what is incorrect in the request object:

{% tabs %}
{% tab title="Swift" %}

```swift
let request = cardknoxDirect.createRequest(withParameters: prms) as! PaymentTransactionRequestDirect;

if(request.isValid){
    let response : PaymentTransactionResponse = request.process() as! PaymentTransactionResponse;
    let isSuccess = response.isSuccess();
    let errorMessage = response.errorMessage();
    let errorCode = response.xErrorCode();
    let refNum = response.xRefNum();
}
else{
    let errors = request.validationErrors;
}
```

{% endtab %}
{% endtabs %}

```swift
PaymentTransactionRequestDirect* request = [cardknoxDirect createRequestWithParameters:prms];

if([request IsValid]){
    PaymentTransactionResponse * response = [request process];
    bool isSuccess = response.isSuccess;
    NSString * errorMessage = response.errorMessage;
    NSString * errorCode = response.xErrorCode;
    NSString * refNum = response.xRefNum;
}
else{
    NSArray* errors = request.ValidationErrors;
}
```

#### Available commands <a href="#available-commands" id="available-commands"></a>

* Check (ACH) commands
  * Reference: [Check (ACH)](https://docs.solapayments.com/api/transaction/check-ach)
* Credit Card commands
  * Reference: [Credit Card](https://docs.solapayments.com/api/transaction/credit-card)
* EBT Food Stamp commands
  * Reference: [EBT Food Stamp](https://docs.solapayments.com/api/transaction/ebt#ebt-food-stamp)
* EBT Cash Benefits
  * Reference: [EBT Cash Benefits](https://docs.solapayments.com/api/transaction/ebt#ebt-cash-benefits)
* EBT Wic
  * Reference: [EBT Wic](https://docs.solapayments.com/api/transaction/ebt#ebt-wic-ewic)
* Gift Card commands
  * Reference: [Gift Card](https://docs.solapayments.com/api/transaction/gift-card)

### Custom UI integration

Custom UI integration is similar to the “out of scope” integration in a way that the exact same methods that the “out of scope” is using under the hood for controlling the card reader, are exposed via the SDK for the Developer to use.

The Developer provides the user interface and orchestrates the entire flow for obtaining the card data via the card reader by calling appropriate Custom UI functions at specific times.

| **Function**                | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| StartScanning               | <p>Starts the “scan for nearby bluetooth devices” process.</p><p>If the timeout value is 0 or a negative number, the scanning never times out.<br><br>A card reader event similar to “waiting for device response” will be raised once the scanning starts. This usually means that the user needs to press the physical button in order for the card reader device to be visible to nearby scanners.</p>                                                                                                                                                                           |
|                             | **Sample data**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|                             | customUI.startScanning(withTimeout: 0);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| StopScanning                | <p>Attempts to stop the bluetooth device scanning process.</p><p>Raises a “stop scan” card reader event.</p><p>Doesn’t do anything if scanning is not in progress.</p><p>If the method stops the scanning process, the SDK reports all scanned devices via a callback.</p>                                                                                                                                                                                                                                                                                                          |
|                             | **Sample data**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|                             | customUI.stopScanning();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ConnectWithName             | <p>Accepts a device name.</p><p>Configures the SDK to be ready to establish a Bluetooth connection with the nearby VP3300 device with a name equal to the provided name.</p><p>After the call:</p><ul><li>The card reader & the app are not connected immediately but rather the SDK notifies the developer about various card reader events taking place after this method is called; such as “connecting” and “waiting for device response”</li><li>If the VP3300 devices’ bluetooth is not asleep when this method is called, the card reader auto connects to the app</li></ul> |
|                             | **Sample data**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|                             | <p>let scannedDevice : String = nil;</p><p><br>customUI.connect(toDevice: scannedDevice);</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ConnectwithUUID             | <p>Accepts an UUID in a string format.<br></p><p>Configures the SDK to be ready to establish a Bluetooth connection with the nearby VP3300 device with the internal identifier equal to the provided UUID value.<br></p><p>Note that on iOS, the CoreBluetooth framework generated internal identifiers are not unique across time.</p>                                                                                                                                                                                                                                             |
|                             | **Sample data**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|                             | <p>let uuid = "d1554880-56ac-11ed-9b6a-0242ac120002";</p><p><br>customUI.connect(withUUID: uuid);</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| DisconnectFromCurrentDevice | <p>Attempts to break the connection between the application & the card reader.<br></p><p>If the card reader is not connected to the app, a card reader event similar to “disconnected already” is raised.<br></p><p>Otherwise, the SDK attempts to disconnect the card reader. If successful, the “disconnected” card reader event is raised.</p>                                                                                                                                                                                                                                   |
|                             | **Sample data**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|                             | customUI.disconnectFromCurrentDevice();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| StartTransaction            | <p>Starts a transaction between an already connected application & the card reader.</p><p><br>Once the transaction starts, the card reader is ready to accept cards, either via swipe, tap or insert.<br><br>This method can timeout. Default value is 10 seconds. Developers can override this value via the “parameters” object.</p>                                                                                                                                                                                                                                              |
|                             | **Sample data**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|                             | <p><strong>let</strong> prms : TransactionParameters = TransactionParameters.init()</p><p>prms.xAmount = 1.23;</p><p>prms.xInvoice = "1234";</p><p>prms.xCommand = "cc:sale";</p><p>prms.vp3300TransactionTimeout = 13;</p><p>customUI.startTransaction(withArgs: prms);</p>                                                                                                                                                                                                                                                                                                        |
| CancelTransaction           | <p>Attempts to cancel an already started transaction between the application & the card reader.</p><p>If no transactions are started when this function is called, the function does not do anything.</p>                                                                                                                                                                                                                                                                                                                                                                           |
|                             | **Sample data**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|                             | customUI.cancelTransaction();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

#### Available commands <a href="#available-commands.1" id="available-commands.1"></a>

Any of the following credit card commands are available for Custom UI:

* cc:save
* cc:credit
* cc:authonly
* cc:sale

Reference: [Transaction API](https://docs.solapayments.com/api/transaction/credit-card)

#### Custom UI flow

First, create a “custom ui” object to get access to all the Custom UI functions. Afterwards, subscribe to all the relevant callbacks for this integration path:

* transaction result callback - to receive the “response” object after the SDK has processed a transaction
* card reader event callback - to be notified about various events that take place between the application & the card reader
* scanned bluetooth device callback - to be notified about every new scanned bluetooth device during the “scan for devices” process
* scan completed callback - to be notified about all the scanned devices once the “scan for devices” process ends

Next step is to establish a connection between the app and the card reader device. Use one of the “connect” methods on the “custom ui” to initiate a connection; such as “connect with name” or “connect with UUID”.

Device name or the UUID can be obtained with the “scan for devices” flow. Initiate the “start scanning” function call, with or without a timeout.

![Start scanning flow](/files/yUB9VliAmuskSe71TKXx)

The scanning process stops with a call to the “stop scanning” function or when the “start scanning” function times out.

![Stop scanning flow](/files/Ziif9deUUWgH641FIzPd)

After establishing a connection with the card reader by calling one of the “connect” methods and receiving a “connected” card reader event via the NSNotificationCenter subscription, call the “start transaction” function to make the card reader ready for a card.

The SDK will report a “transaction starting” card reader event via a callback followed by the “transaction started” event if the transaction with the card reader was successfully started, otherwise an “error” card reader event is reported back. At this point the card can be tapped, swiped or inserted into the card reader. The SDK will read the card information, process a transaction & deliver the results to the application via a callback.

If no card is tapped, swiped or inserted after the transaction started - a “timeout” card reader is reported back. The default timeout value is about 10 seconds. The developer can override this value via the “transaction parameters” object.

### Payment engine integration <a href="#payment-engine-integration" id="payment-engine-integration"></a>

The Payment Engine won't show any UI. The developer provides the user interface and uses three payment engine functions to create transactions with a card reader over IP. Data that is required to create a transaction is passed by developers as parameters to those SDK functions. The messages and results of creating a transaction with the Payments engine are obtained by the developer from transaction result callback, device status callback, and transaction status.

| Device\_Initialize            | <p>This function makes sure that the mobile device can communicate with the card reader and saves data that is needed for connecting to the card reader.</p><p>The initialization process can take about 2 minutes. But it is sufficient to execute it once per card reader and IP address.</p>                                                                                                                                                                                                                                                                                   |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                               | **Sample data**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|                               | <p>let settings : CardknoxPaymentEngineSDKSettings</p><p>CardknoxPaymentEngineSDKSettings.init();</p><p>settings.device\_Name = "Verifone\_P400.4";</p><p>settings.device\_IP\_Address = “127.21.2.7”;</p><p>settings.device\_IP\_Port = “9006”;</p><p>settings. device\_Timeout = 120 \* 1000; // seconds</p><p>CardknoxSDK.create().getPaymentEngine().device\_Initialize(withSettings: settings)</p>                                                                                                                                                                           |
| ProcessOutOfScopeWithSettings | <p>Attempts to create a transaction with a card reader over IP. </p><p>This function will perform the initialization process if initialization has not been performed for the specific card reader.</p>                                                                                                                                                                                                                                                                                                                                                                           |
|                               | **Sample data**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|                               | <p>let settings : CardknoxPaymentEngineSDKSettings</p><p>CardknoxPaymentEngineSDKSettings.init();</p><p>settings.device\_Name = "Verifone\_P400.4";</p><p>settings.device\_IP\_Address = “127.21.2.7”;</p><p>settings.device\_IP\_Port = “9006”;</p><p>settings. device\_Timeout = 120 \* 1000; // seconds</p><p>let request : CardknoxPaymentEngineSDKRequest = CardknoxPaymentEngineSDKRequest.init();<br>request.xAmount = 1.23<br>request.xCommand = "cc:sale";</p><p>CardknoxSDK.create().getPaymentEngine().processOutOfScope(withSettings: settings, request: request)</p> |
| Device\_CancelTransaction     | <p>Attempts to cancel an already started transaction between the application & the card reader.</p><p>If no transactions are started when this function is called, the function does not do anything.</p>                                                                                                                                                                                                                                                                                                                                                                         |
|                               | **Sample data**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|                               | CardknoxSDK.create().getPaymentEngine().device\_CancelTransaction();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

### Versioning

Developers can call the “get version” API to obtain the SDK Semantic Versioning ([SemVer source](https://semver.org/))

| **Function** | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| getVersion   | <p>Reads the SDK version</p><p>Returns a “cardknox sdk version” object</p><ul><li>access to the Semantic Versioning “string” value</li><li>access to all individual parts: major, minor, patch, build</li></ul>                                                                                                                                                                                                                                                                                   |
|              | **Sample data (Swift)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
|              | <p><strong>let</strong> ver = CardknoxSDK.getVersion() <strong>as</strong>! CardknoxSDKVersion</p><p>// Read the version in format "major.minor.patch.build"</p><p><strong>let</strong> semanticVersion = ver.description();</p><p>// Access individual parts as well</p><p><strong>let</strong> major : Int32 = ver.major;</p><p><strong>let</strong> minor : Int32 = ver.minor;</p><p><strong>let</strong> patch : Int32 = ver.patch;</p><p><strong>let</strong> build : Int32 = ver.build;</p> |
|              | **Sample data (Objective C)**                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|              | <p>CardknoxSDKVersion \*ver = \[CardknoxSDK getVersion];</p><p>// Read the version in format "major.minor.patch.build"</p><p>NSString \*semanticVersion = \[ver description];</p><p>// Access individual parts as well</p><p><strong>int</strong> major = \[ver major];</p><p><strong>int</strong> minor = \[ver minor];</p><p><strong>int</strong> patch = \[ver patch];</p><p><strong>int</strong> build = \[ver build];</p>                                                                    |

### Logging

SDK verbose logging can be enabled or disabled with a function call:

| **Function**  | **Description**                                                          |
| ------------- | ------------------------------------------------------------------------ |
| EnableLogging | <p>Accepts a boolean.</p><p>Enables or disabled the verbose logging.</p> |
|               | **Sample data (Swift)**                                                  |
|               | CardknoxSDK.enableLogging(**false**);                                    |
|               | **Sample data (Objective C)**                                            |
|               | \[CardknoxSDK enableLogging:**true**];                                   |

### FAQ

1. As a Sola SDK user, I want to process without an internet connection. What will happen?
   * The SDK will return a PaymentTransactionResponse object with a special xErrorCode value -1
2. As a Sola SDK user, I’ve encountered errors during transaction processing. What response can I expect?
   * The PaymentTransactionRequest object will encapsulate all relevant information in respective fields; for example the xErrorCode property will return a code from the Sola Transaction API documentation, the xErrorMessage and xError properties can be used for a descriptive error message while the xRefNum gives back a unique ref num to follow up with the customer support


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.solapayments.com/sdk/ios-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
