/tilia-ios-sdk

Tilia iOS SDK

Primary LanguageSwiftMIT LicenseMIT

Tilia iOS SDK

The Tilia iOS SDK makes it easy to add payments natively within mobile apps.

This SDK is meant to be used in concert with your own api server which communicates with Tilia APIs to retrieve authorized user access tokens and any additional data required by the SDK flow you are looking to use.
The repository includes an interactive demo application which can guide you through what data is expected for each flow as well as how to customize the look of the SDK UI.

For detailed information on how to integrate with Tilia and this SDK, please refer to our documentation here.

Installation

Using CocoaPods, add the following to your Podfile:

pod 'TiliaSDK'

Usage

To interact with Tilia SDK use TLManager. SDK supports customization for environment, timeout iterval for requests, colors for dark/light theme.

Configuration

Set token

TLManager.shared.setToken("USER_PASSWORD_TOKEN")

Set timeout interval, in seconds

TLManager.shared.setTimeoutInterval(10)

Set environment

TLManager.shared.setEnvironment(.staging)

Theme customization

TLManager.shared.setBackgroundColor(forLightMode: UIColor(), andDarkMode: UIColor())
TLManager.shared.setPrimaryColor(forLightMode: UIColor(), andDarkMode: UIColor())
TLManager.shared.setSuccessBackgroundColor(forLightMode: UIColor(), andDarkMode: UIColor())
TLManager.shared.setFailureBackgroundColor(forLightMode: UIColor(), andDarkMode: UIColor())

Flows

Terms of Service

let yourViewControllerForPresenting = UIViewController()
TLManager.shared.setToken("USER_PASSWORD_TOKEN")
TLManager.shared.presentTosIsRequiredViewController(on: yourViewControllerForPresenting,
                                                    animated: true,
                                                    onComplete: { onComplete in print(onComplete.description) },
                                                    onError: { onError in print(onError.description) })

Checkout

let yourViewControllerForPresenting = UIViewController()
TLManager.shared.setToken("AUTHORIZED_USER_PASSWORD_TOKEN")
TLManager.shared.presentCheckoutViewController(on: yourViewControllerForPresenting,
                                               withInvoiceId: "AUTHORIZED_INVOICE_ID",
                                               animated: true,
                                               onUpdate: { onUpdate in print(onUpdate.description) },
                                               onComplete: { onComplete in print(onComplete.description) },
                                               onError: { onError in print(onError.description) })

Helper methods

getTosRequiredForUser

TLManager.shared.setToken("USER_PASSWORD_TOKEN")
TLManager.shared.getTosRequiredForUser { result in print(result) }

getUserBalanceByCurrencyCode

TLManager.shared.setToken("USER_PASSWORD_TOKEN")
TLManager.shared.getUserBalanceByCurrencyCode("USD") { result in print(result) }