---
title: Configuration
slug: configuration
docTags: 
createdAt: 2025-05-12T08:51:28.390Z
---

# Toro Config

The Toro SDK can be configured using the `ToroConfig` class.&#x20;

```swift
public struct ToroConfig {
    /// The mode in which to capture payments.
    /// - `automatic` (default): The payment will be captured automatically when sent for authorisation.
    /// - `manual`: The payment will need to be captured later manually.
    public var captureMode: CaptureMode

    /// Whether to collect geolocation data for transactions.
    /// - `false` (default): Geolocation data will not be collected.
    /// - `true`: Geolocation data will be collected.
    public var collectGeolocation: Bool

    /// Whether to enable gratuity for transactions.
    /// - `false` (default): Gratuity will not be enabled.
    /// - `true`: Gratuity will be enabled.
    public var gratuityEnabled: Bool

    /// The options for gratuity percentages.
    /// - `[0, 10, 15, 20]` (default): The options will be 0%, 10%, 15%, and 20%.
    public var gratuityPercentages: [Int]

    /// The mode in which to capture signatures.
    /// - `device` (default): The signature will be captured on the Miura device (e.g. PED).
    /// If the device does not support signature capture a ToroException.DeviceNotSupported will be thrown.
    /// - `app`: The signature will always be captured in the app.
    public var signatureMode: SignatureMode

    /// The mode in which to connect to the Miura device.
    /// - `bluetooth` (default): The Miura device will be connected using Bluetooth.
    public var connectionMode: ConnectionMode
    
    /// Whether to allow partial approvals for transactions.
    /// - `false` (default): During authorisation, the gateway will be informed that the POI does not support partial approvals.
    /// - `true`: The gateway will be informed the POI does support partial approvals. External factors such as acquirer support and merchant configuration may override this.
    public var allowPartialApprovals: Bool
    
    /// Maximum time to wait for a response from the Toro gateway, 30 seconds by default.
    public var gatewayTimeoutSeconds: Int

    /// Use this to override strings used in messages displayed on the device
    /// and in the SignatureActivity
    public var strings: ToroStrings
    
    /// Details of the merchant performing the transaction.
    public var merchant: MerchantConfig
    
    /// The passphrase used to generate/verify MACs of ISO20022 messages exchanged with the gateway.
    public var passphrase: String?
    
    /// The policy for verifying and generating security trailers.
    public var securityTrailerPolicy: SecurityTrailerPolicy
    
    /// Whether to preserve the session after a transaction ends.
    /// When false (default), the session is automatically closed when onComplete, onCancel, or onError is called.
    /// When true, the session remains open and must be manually closed using closeSession().
    public var preserveSessionOnTransactionEnd: Bool
  }
```

The `ToroConfig` can also be updated during runtime using the `setConfig` method:

```swift
try toro.setConfig(ToroConfig(...))
```

:::hint{type="warning"}
The config cannot be updated when a transaction is in progress. Doing so will result in an `ToroError` being thrown.
:::

# String customisation

The SDK allows integrators to customise all user facing text through the `strings` property in `ToroConfig`. This includes messages displayed directly on the PED, as well is in the built-in `SignatureActivity`.

```swift
let config = ToroConfig(
    strings: ToroStrings(
        // Messages presented on PED
        processingMagSwipeTransaction: "Kártya feldolgozása...",
        enterSignaturePOS: "Adja meg aláírását a POS terminálon",
        uploadingConfigFiles: "Konfigurációs fájlok feltöltése...",
        // Other PED messages here...
        
        // SignatureView
        signatureHeading: "Aláírás szükséges",
        signatureClear: "Törlés",
        signatureCancel: "Mégsem"
        // Other strings here...
    )
)
```

:::hint{type="info"}
This allows integrators to support different languages for their application. All strings have default English values if not specified otherwise.
:::

:::hint{type="warning"}
Note that some messages displayed on the PED are determined by the configuration files stored directly on them, such as PIN entry messages. To amend these you will need to consult the Miura documentation, one such configuration file is `MPI-Dynamic.cfg`.
:::

# Logging

The `ToroClient` automatically selects an appropriate logger based on your build variant:

- Debug builds use `DebugLogger` by default, which logs helpful messages using the Android Log class.
- Release builds use `MutedLogger` by default, which disables logging entirely to prevent sensitive information leaks.

You can override this default behavior by implementing the `ToroLogging` protocol and passing your own logger to the `ToroClient` constructor:

```swift
import ToroSDK

class CustomLogger: ToroLogging {
    func debug(_ message: String, file: String, function: String, line: Int) {
        saveLogMessage("debug", message)
    }
    
    func info(_ message: String) {
        saveLogMessage("info", message)
    }
    
    func warn(_ message: String) {
        saveLogMessage("warn", message)
    }
    
    func error(_ message: String, error: (any Error)?) {
        saveLogMessage("error", message)
    }
}

ToroClient(logger: CustomLogger())
```

This way you can retain logs for monitoring and debugging purposes in production, which is highly recommended.

:::hint{type="danger"}
Please be cautious with logging in production as it can potentially leak sensitive information.
:::



