---
title: MPI Extensibility
slug: M1eS-mpi-extensibility
docTags: 
createdAt: 2025-05-20T12:13:23.603Z
---

We have exposed the underlying `MiuraSDK` (which the `ToroSDK` depends on) to allow consuming apps to interact with Miura devices.

For example, if you wanted to show a custom gratuity menu before a transaction, you could show the menu before calling `toro.startTransaction()` and add the tip amount in the `TransactionMetadata` object. See more about gratuities [here](docId\:vpDTDNo1D9gxRsa-cCywp).

```swift
import MiuraSDK
import SwiftUI
import ToroSDK

enum MiuraDevice {

    static func showTipMenu(
        toro: ToroClient,
        completion: @escaping (Result<Int, ToroError>) -> Void
    ) {
        let miura = MiuraManager.sharedInstance()

        let tipOptions = [
            (text: "1. 5%", percentage: 5),
            (text: "2. 10%", percentage: 10),
            (text: "3. 15%", percentage: 15),
            (text: "4. 20%", percentage: 20),
        ]

        let menuItems = tipOptions.map { $0.text }

        toro.openSession { _ in
            miura.getMenuOption(
                "My Wonderful Tip Menu!",
                showStatusBar: false,
                enlargeHeader: true,
                enlargeFooter: false,
                menuItems: menuItems
            ) { result, value in
                switch result {
                case .cancelled:
                    completion(.failure(ToroError.customerCancelled))
                case .selected:
                    guard let selectedValue = value,
                        let index = menuItems.firstIndex(of: selectedValue)
                    else {
                        completion(
                            .failure(
                                ToroError.unknownError("Invalid tip selection"))
                        )
                        return
                    }
                    let tipPercentage = tipOptions[index].percentage
                    completion(.success(tipPercentage))
                case .timeout:
                    completion(.failure(ToroError.transactionTimeout))
                case .error:
                    completion(
                        .failure(
                            ToroError.deviceError(
                                "Device returned error response when getting tip"
                            )))
                @unknown default:
                    completion(
                        .failure(ToroError.unknownError("Unknown menu result")))
                }

                toro.closeSession()
            }
        }
    }
}
```

:::hint{type="warning"}
Note that we recommend using the `ToroSDK` methods to open and close sessions with the selected device. You could use the `MiuraSDK` directly to do this, but managing the session via `ToroSDK` means that the SDK maintains visibility over the device connection state. While there isn't a strict technical requirement for this approach currently, it provides better integration with the SDK's internal state management and ensures compatibility with future SDK updates that may rely on this session tracking.
:::

