# Configure the processing terminal

Configure the Tap to Pay on iPhone terminal by initializing it locally, setting the operating mode, and loading your settings from our gateway.

**Prerequisites:** [Authentication](/api/authentication) · [Set up the SDK](/guides/payments/tap-to-pay-on-iphone/set-up-the-sdk)

Before your app can run a sale, it needs the merchant's payment settings. To get the payment settings, initialize `WTPSTerminal` in your app, and then send your terminal ID to our gateway.

<a id="integration-steps"></a>
## Integration steps

1. Initialize `WTPSTerminal`.
2. Load the settings from our gateway.

<a id="step-1-initialize-wtpsterminal"></a>
## Step 1. Initialize WTPSTerminal

1. Add the following code to your app delegate or to wherever your app runs its launch code:
   
   **`Swift`**
   
   ```swift
   let terminal = WTPSTerminal<CoreTerminalConnector>.singleton() as! WTPSTerminal<CoreTerminalConnector>
   terminal.initialize()
   terminal.mode = TEST // TEST or LIVE
   terminal.setLogLevel(LEVEL_INFO)
   ```
   
   **`Objective-C`**
   
   ```objectivec
   [[WTPSTerminal singleton] initialize];
   [(WTPSTerminal *)[WTPSTerminal singleton] setMode:TEST]; // TEST or LIVE
   [[WTPSTerminal singleton] setLogLevel:LEVEL_INFO];
   ```
2. Set the operating mode to one of the following values:

| **Value** | **Description** |
| --- | --- |
| `TEST` | Sends requests to our test environment. Use `TEST` while you develop your integration. |
| `LIVE` | Sends requests to our production environment. Use `LIVE` when you're ready to run live transactions. |

3. Set the log level to one of the following values:

| **Value** | **Description** |
| --- | --- |
| `LEVEL_FULL` | Records all messages, including raw data. Available only in `TEST` mode. |
| `LEVEL_INFO` | Records informational messages. |
| `LEVEL_ERROR` | Records only errors. |
| `LEVEL_NONE` | Records nothing. |

4. (Optional) To receive the SDK's log output in your own code, register a `CoreAPILogsListener`:
   
   **`Swift`**
   
   ```swift
   terminal.registerLogListener(self)
   
   func onLogMessage(_ message: String!, with logLevel: LogLevel) {
       print("[SDK \(logLevel.rawValue)] \(message ?? "")")
   }
   ```
   
   **`Objective-C`**
   
   ```objectivec
   [[WTPSTerminal singleton] registerLogListener:self];
   
   - (void)onLogMessage:(NSString *)message withLogLevel:(LogLevel)logLevel {
       NSLog(@"[SDK %d] %@", (int)logLevel, message);
   }
   ```
   
   **Note:** To stop receiving log messages, send `nil` to `registerLogListener`.

<a id="step-2-load-the-settings-from-our-gateway"></a>
## Step 2. Load the settings from our gateway

**Important:** Make sure that you register your settings listener before you call `initWithConfiguration:`. If you register your settings listener afterward, you miss the `onSettingsRetrieved:` callback that indicates the SDK has your settings.

1. Add the following code to register your settings listener and to send your terminal ID to our gateway:
   
   **`Swift`**
   
   ```swift
   terminal.register(self as CoreAPISettingsListener)
   terminal.initWithConfiguration("YOUR_TERMINAL_ID")
   ```
   
   **`Objective-C`**
   
   ```objectivec
   [[WTPSTerminal singleton] registerCoreAPISettingsListener:self];
   [[WTPSTerminal singleton] initWithConfiguration:@"YOUR_TERMINAL_ID"];
   ```
2. Replace `YOUR_TERMINAL_ID` with your terminal ID. We provided you with your terminal ID when you boarded with us.
3. Add the following code to handle the `onSettingsRetrieved:` and `onError:withDescription:` callbacks:
   
   **`Swift`**
   
   ```swift
   func onSettingsRetrieved(_ settings: CoreSettings!) {
       // Settings loaded from the gateway. You can now initialize the device.
       terminal.initDevice(APPLETTP, with: DCT_INTERNAL, withDeviceData: [:])
   }
   
   func onError(_ error: CoreError, withDescription message: String!) {
       // Could not load settings. Check your terminal ID and connectivity.
   }
   ```
   
   **`Objective-C`**
   
   ```objectivec
   - (void)onSettingsRetrieved:(CoreSettings *)settings {
       // Settings loaded from the gateway. You can now initialize the device.
       [[WTPSTerminal singleton] initDevice:APPLETTP
                         withConnectionType:DCT_INTERNAL
                             withDeviceData:nil];
   }
   
   - (void)onError:(CoreError)error withDescription:(NSString *)message {
       // Could not load settings. Check your terminal ID and connectivity.
   }
   ```
   
   The `onSettingsRetrieved:` callback indicates that the SDK has your payment processing settings. After the SDK has your settings, you can initialize the device to run a sale.

<a id="next-step"></a>
## Next step

After you configure the processing terminal, go to [Run a sale](/guides/payments/tap-to-pay-on-iphone/run-a-sale).
