Functionalities

  • WebKit WebView handler, to display the Tamara checkout page on your application.
  • Tamara "Learn More" view, to display a short and crisp description about Tamara.

iOS SDK Integration Workflow

iOS App Tamara SDK Backend Tamara Create order Return checkout_url Return checkout_url Call create checkout session API

Installation

Download the SDK
GitHub - Tamara iOS SDK

Setup

1. Init checkout data

Using the Create Checkout Session API

  • You create a checkout session request to transmit the details of purchase, such as the amount, currency, customer information, and unique order reference ID.
  • You need to provide specific URLs for the checkout flow, such as the success and failure URLs, which should be exactly the same as what your backend would send to our API, so that the WebView in the SDK can detect whether the checkout has been successful or has failed.
let merchantUrl = TamaraMerchantURL(  
    success: "tamara://checkout/success",  
    failure: "tamara://checkout/failure",  
    cancel: "tamara://checkout/cancel",  
    notification: "tamara://checkout/notification"  
)
  • Tamara uses this information to return a unique order ID and a checkout URL for completing the transaction. Then init the model for checkout view. Params are the checkoutUrl you received from the backend, and merchantUrl you created above.
  • You need to init the model for checkout view. The required params are the checkoutUrl that you received from Tamara, and the merchantUrlthat you created above.
let viewModel = TamaraSDKCheckoutViewModel(url: checkoutURL, merchantURL: merchantUrl)

๐Ÿ“˜

Please refer to the documentation for Create order using iOS Client, in case you want to create an order from an iOS client, not passing through your backend.

2. Create WebView and handle callback (success/failure)

1. In SwiftUI

SDKViewController(url: appState.viewModel.url,  
    merchantUrl: appState.viewModel.merchantURL,  
    delegate: SDKViewController.Delegate (  
    success: {  
    //Handle Success  
    appState.orderSuccessed = true  
    appState.currentPage = .Success  
}, failure: {  
    //Handle Failed  
    appState.orderSuccessed = false  
    appState.currentPage = .Success  
}, cancel: {  
    //Handle Cancel  
    appState.currentPage = .Info  
}, notification: {  
    //Handle Notification  
})  
)

2. In UIKit

private var tamaraSDK: TamaraSDKCheckout!  
self.tamaraSDK = TamaraSDKCheckout(url: item.checkoutUrl, merchantURL: merchantUrl, webView: nil)  
self.tamaraSDK.delegate = self  
self.present(self.tamaraSDK, animated: true, completion: nil)

Delegate Handle

//Delegate handle action  
extension UIKitSDKViewController: TamaraCheckoutDelegate {  
    func onSuccessfull() {  
    sdkView.dismiss(animated: true) {  
            //success handle  
        }  
    }
		func onFailured() {
		    tamaraSDK.dismiss(animated: true) {
		        //error handle
		    }
		}
		
		func onCancel() {
		    tamaraSDK.dismiss(animated: true) {
		        //cancel handle
		    }
		}
		
		func onNotification() {
		    tamaraSDK.dismiss(animated: true) {
		        //notification handle
		    }
		}
}

3. Add "About Tamara" modal view

To help customers understand what Tamara is and how it works, we also provide the modal view, to be displayed as required in your application.

let vc = TamaraLearnMorePopup()  
self.present(vc, animated: true, completion: nil)