Prerequisites: Authentication · 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.
Integration steps
Initialize
WTPSTerminal.Load the settings from our gateway.
Step 1. Initialize WTPSTerminal
Add the following code to your app delegate or to wherever your app runs its launch code:
Swiftswift let terminal = WTPSTerminal<CoreTerminalConnector>.singleton() as! WTPSTerminal<CoreTerminalConnector> terminal.initialize() terminal.mode = TEST // TEST or LIVE terminal.setLogLevel(LEVEL_INFO)Objective-Cobjectivec [[WTPSTerminal singleton] initialize]; [(WTPSTerminal *)[WTPSTerminal singleton] setMode:TEST]; // TEST or LIVE [[WTPSTerminal singleton] setLogLevel:LEVEL_INFO];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. |
- 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. |
(Optional) To receive the SDK's log output in your own code, register a
CoreAPILogsListener:Swiftswift terminal.registerLogListener(self) func onLogMessage(_ message: String!, with logLevel: LogLevel) { print("[SDK \(logLevel.rawValue)] \(message ?? "")") }Objective-Cobjectivec [[WTPSTerminal singleton] registerLogListener:self]; - (void)onLogMessage:(NSString *)message withLogLevel:(LogLevel)logLevel { NSLog(@"[SDK %d] %@", (int)logLevel, message); }Note: To stop receiving log messages, send
niltoregisterLogListener.
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.
Add the following code to register your settings listener and to send your terminal ID to our gateway:
Swiftswift terminal.register(self as CoreAPISettingsListener) terminal.initWithConfiguration("YOUR_TERMINAL_ID")Objective-Cobjectivec [[WTPSTerminal singleton] registerCoreAPISettingsListener:self]; [[WTPSTerminal singleton] initWithConfiguration:@"YOUR_TERMINAL_ID"];Replace
YOUR_TERMINAL_IDwith your terminal ID. We provided you with your terminal ID when you boarded with us.Add the following code to handle the
onSettingsRetrieved:andonError:withDescription:callbacks:Swiftswift 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-Cobjectivec - (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.
Next step
After you configure the processing terminal, go to Run a sale.