This page provides instructions for integrating Kustom Checkout into an iOS application.
This guide assumes Kustom Checkout has already been set up and is available at a specified API endpoint. For detailed setup, refer to the general Kustom Checkout Integration guide.
In Xcode, navigate to File → Swift Packages → Add Package Dependency and enter the repository URL: https://github.com/Kustom-Checkout/kustom-mobile-sdk-spm
In Version, Select Up to Next Major and take the default option. Then choose KustomMobileSDK in the Package Product column.
If you’re using Cocoapods, you can add the SDK by adding the dependency to your Podfile:
pod "KustomMobileSDK"Followed by performing:
pod installYou should then be able to import the KustomMobileSDK module in your workspace.
The Checkout View in iOS is called KustomCheckoutView.
Create the KustomCheckoutView instance in your view controller. Initialize the view using the returnURL and eventHandler parameters.
var checkoutView: KustomCheckoutView?
override func viewDidLoad() {
super.viewDidLoad()
checkoutView = KustomCheckoutView(returnURL: URL(`app-schema://`Â), eventHandler: KustomEventHandler)
}Initialize the KustomCheckoutView with the Checkout HTML snippet fetched from your server at YOUR-URL.
checkoutView?.setSnippet(snippet)The SDK notifies you of events and errors via a handler object. Implement the KustomEventHandler protocol.
// In case the handler needs to be updated to another reference
checkoutView?.eventHandler = handlerObject // must implement the KustomEventHandler protocolThe KustomEventHandler protocol exposes methods for handling various events:
func kustomComponent(_ kustomComponent: KustomComponent, dispatchedEvent event: KustomProductEvent) {
// A few examples of dispatched events shown later in the docs
}and
func kustomComponent(_ kustomComponent: KustomComponent, encounteredError error: KustomMobileSDKError) {
// Errors related to the sdk
}The sizingDelegate is used to handle resizing of views within the KustomCheckoutView. Implement the KustomSizingDelegate protocol.
checkoutView?.sizingDelegate = listenerObject // must implement the KustomSizingDelegate protocolThe suspend() and resume() actions control user interaction with the KustomCheckoutView.
checkoutView?.suspend()checkoutView?.resume()checkoutView?.checkoutOptions.merchantHandlesEPM = true(Set before starting Checkout)
The SDK handles external payment method events.
checkoutView?.checkoutOptions.merchantHandlesValidationErrors = true(Set before starting Checkout)
Third-party applications might require returning to your app. The SDK uses the provided returnURL to manage this process.
Note: Bank ID authentication for payments might require manual user return to the app after bank authentication.