Skip to main content

iOS SDK

Initialization

To integrate the iOS SDK into your application, you'll usually initialize it within the AppDelegate. This is done once, ideally at the app's launch:

import Gini_iOS_SDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

// Initialize the SDK
Gini_iOS_SDK.initialize()

return true
}
}

Configuration

After you initialize it, the SDK needs to be configured before is rendered on the screen. The reason for this, is that you need to have the bearer token as explained on the recipe:

let config = Gini_iOS_SDK.Config()
config.bearerToken = "BearerToken" // Obtained in the authentication step
config.environment = .production // This is for testing purposes only

Gini_iOS_SDK.configure(with: config)

Displaying and Using the Request To Pay Button

First, make sure you have the SDK imported at the top of your Swift file:

import Gini_iOS_SDK

You can now add the button programmatically or via the Interface Builder (Storyboard/XIB)

let rtpButton = RTPButton(frame: CGRect(x: 100, y: 100, width: 200, height: 50))
view.addSubview(rtpButton)

Merchants must set up the code that the button must run once the customer clicks on the button in order to start the payment. It's needed to communicate with the Merchant's server in order to initiate the payment via an Api to Api call due to security reasons, as explained on the mobile recipe. For this, you can grab your button from your Activity or Fragment, and set the listener's code as follows:

rtpButton.setOnClickListener = {
// It's needed to call merchant's API in order
// to initiate the backend to backend RTP payment

// Once the paymentRequestId is returned, the
// payment can be initiated via our SDK method
// as follows
rtpButton.initPayment(paymentRequestId);
// Your clients bank application will be opened via deeplink
}