It's easy and quick to build a great payment experience using Ottu Checkouts which is iOS SDK. In order to collect your user's payment information, we provide powerful and customizable UI screens.

For optimal security, call REST APIs from server-side implementations, not client-side applications such as mobile apps or web browsers.

Simplified security: Keeping PCI compliance is as easy as collecting credit card numbers with our simplified security. Instead of passing through your server, Ottu receives the sensitive data directly.

Apple Pay: Integrate seamlessly with Apple Pay.

Native UI: Native UI to collect payment details.

Localized: Both English & Arabic localizations are supported.

Apple's in-app purchase APIs should be utilized for selling digital product or services which are used within your app such like (game hints & level promotions, upgrading subscription plans, unlock enhancement features).

Ottu SDK could be used for other purposes.

Collecting data by Ottu SDK is just for enhancement of our services and product, this data is never being sold, rented or used for advertising. Of course, data confidentially is highly appreciated.

Xcode 13.0 or later is required, which is compatible with apps targeting iOS 12 or above.

Initially, a session token should be created by Ottu public API, then SDK could be initialized. See Rest API

For "apiKey" API Public key sohuld be used.

Ottu is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Ottu'

The Swift Package Manager is used for automating the distribution of Swift code, and it is integrated into the swift compiler. When Swift package set up, It is easy to add Alamofire as a dependency, just like adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "")

By downloading the project and keeping the source folder in your project, you can integrate Ottu into your project manually if you prefer not to use any of the above dependency managers.

Swift 5.1, 5.0, 4.2, 4.0

In ViewController.swift, import Ottu framework and initialize Ottu SDK.

import Ottu

class ViewController: UIViewController,OttuDelegate {

    var responseDict : [String:Any]?
    var message = ""
    override func viewDidLoad() {
        //Intiate the SDK accordingly after getting session id from the public API documentation.
        //session_id - It is generated when payment was created. See API documentation
        //merchant_id - Merchant domain. See API documentation.
        //apiKey - API Public key should be used. See API documentation.
        //lang - You can use it to change the language. We support two languages english and arabic. You can use "en" for english and "ar" for arabic.        
        let session_id = "ENTER_YOUR_SESSION_ID"
        _ = Ottu.init(session_id, merchant_id: "MERCHANT_ID", apiKey: "API_KEY" ,lang: "ENTER_LANGUAGE_ID_en_or_ar", viewController: self, delegate: self)
    //The error callback is invoked when problems occur during a payment.
    //Reason will be defined in the response attribute. 
    func errorCallback(message: String, response: [String : Any]?) {
        responseDict = response
        self.message = "Error"

    //Called when a customer cancels the payment.
    func cancelCallback(message: String, response: [String : Any]?) {
        responseDict = response
        self.message = "Cancel"
    //Called when the payment completed successfully.
    func successCallback(message: String, response: [String : Any]?) {
        responseDict = response
        self.message = "Success"
    //It is a helper function that has to return a promise object, to create the redirect_url.
    //This allows the merchant to redirect the user to the cart page and wait for a while before creating the redirect_url. 
    //In case the customer changes items in the cart, the due amount will be updated accordingly, then the merchant will wait for a while until the customer does not return, then the function returns a promise object, the cart will be frozen and marked as submitted, and the redirect_url will be generated.
    func beforeRedirect() {
    //After successCallback or cancelCallback or errorCallback you can show alert to the user accordingly.
    func dismissed() {
        DispatchQueue.main.asyncAfter(deadline: .now()+1) {
            let alert = UIAlertController(title: self.message.capitalized, message: "\(String(describing: self.responseDict))", preferredStyle: .alert)
            alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
            self.present(alert, animated: true, completion: nil)

Please follow below steps to integrate Apple Pay button in storyboard.

Apply the configuration shown in the following figure.

Now create an action for the button and initialize the SDK with session_id.

let session_id = "ENTER_YOUR_SESSION_ID"
_ = Ottu.init(session_id, merchant_id: "MERCHANT_ID", apiKey: "API_KEY" ,lang: "ENTER_LANGUAGE_ID_en_or_ar",formsOfPayment: ["applePay"], viewController: self, delegate: self)
  • You need to pass formsOfPayment as ["applePay"]. If it is not passed then normal flow will start working.

  • To inetgrate apple pay you need to enable Apple Pay in capabilites in your project.

Last updated