Risk SDK for iOS

Overview

For client apps, we recommend integrating the native SDK from our risk service providers (Checkout & Forter). This ensures the collection of high-quality device data in complex app environments, improving the accuracy of risk detection. Native integration eliminates the latency and complexity introduced by intermediate forwarding, enhancing the overall payment experience while meeting strict requirements for data reliability, independence, and compliance. This offers merchants a safer, more efficient risk management solution.

Integration steps

1.Add OSLPayRiskSDK.xcframework

  1. Drag the OSLPayRiskSDK.xcframework file into your Xcode project (it is recommended to place it in the Frameworks folder).
  2. In the dialog that appears, check Copy items if needed, and select all targets for the project.

2.Configure Frameworks, Libraries, and Embedded Content

  1. Open your project’s TARGETSsection, locate Frameworks, Libraries, and Embedded Contentand set theOSLPayRiskSDKEmbed option to Embed & Sign。

3.Configure dependencies

OSLPayRiskSDK relies on the following third-party libraries. Ensure that these dependencies are included in your main project's Podfile:

  pod 'Alamofire', '5.10.2'
  pod 'Risk', '3.0.4'
  pod 'ForterSDK', :git => 'https://bitbucket.org/forter-mobile/forter-ios-sdk.git', :tag => '3.0.4'
  pod 'Alamofire', '5.10.2'
  pod 'DeviceKit', '5.7.0'
  pod 'FingerprintJS', '1.6.0'
  pod 'SwiftyRSA', '1.7.0'
  pod 'MMKV', '1.2.11'
  pod 'RxSwift', '6.5.0'
  pod 'SwiftyJSON', '5.0.2'
  pod 'DeviceKit', '5.7.0'

Add the following to the bottom of your Podfile:

post_install do |installer|
  installer.generated_projects.each do |project|
      project.targets.each do |target|
          target.build_configurations.each do |config|
              config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
              config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = true
          end
      end
  end
end

Execute the following command to install the dependencies:

pod install

Usage instructions

1.Import the header file In the files where you need to use the SDK, import the following header file:

import OSLPayRiskSDK

2.Initialize the SDK Before using the SDK, initialization is required:

// Default production environment
OSLPayRiskSDK.setup()
// Enable sandbox mode for debugging; disable sandbox mode when going live
OSLPayRiskSDK.setup(openSandBoxEnv: true)

3.Risk data reporting

@objc public static func collect(complete: ((String) -> Void)? = nil, 
                            onError: (((any Error)?) -> Void)? = nil)

OSLPayRiskSDK.collect { clientInfoToken in
  // Reporting succeeded, retrieve clientInfoToken
} onError: { err in
  // Reporting failed
}

4.Collect device information The collect method automatically gathers the following device information:

Field NameTypeDescriptionData Source
terminalTypestringDevice type; "3" represents iOSBuilt-in SDK
deviceIdstringUnique device fingerprintFingerprintJS SDK
deviceSessionIdstringCheckout device session IDCheckout Risk SDK
forterMobileUIDstringForter device identifierForter SDK
userAgentstringUser agent informationBuilt-in SDK
browserWidthstringScreen widthUIScreen.main.bounds.width
browserHeightstringScreen heightUIScreen.main.bounds.height
lanstringDevice language (e.g., zh-CN)Built-in SDK
browserTimezonestringDevice timezone (e.g., Asia/Shanghai)NSTimeZone.system.identifier
agentOSstringOperating systemUIDevice.current.systemName
appVersionstringApp versionBundle.main.infoDictionary["CFBundleShortVersionString"]
appnamestringApp nameBundle.main.infoDictionary["CFBundleDisplayName"]
osVersionstringOperating system versionUIDevice.current.systemVersion
brandstringDevice brandApple
modelstringDevice modelUIDevice.current.model

Reference files

  1. Risk SDK for Web
  2. Checkout iOS SDK
  3. Fingerprint iOS SDK
  4. Forter's iOS SDK
  5. OSL Pay Risk SDK Demo - iOS Github