Getting Started on iOS
Introduction
The Software Development Kit for iOS is a dynamic framework with a simple set of tools that allow you to easily communicate with the Paysafe Wallet API. The SDK is written in Swift.
Requirements
- iOS 14.3
- Swift 5.7
Installation
Manually
PaysafeWallet SDK can ce integrated into your project manually.
- Download latest version of PaysafeWallet, TMXProfiling and TMXProfilingConnections
- Extract downloaded zip files and copy PaysafeWallet.xcframework, TMXProfiling.xcframework and TMXProfilingConnections.xcframework to your project directory.
- Open your Xcode project and drag copied xcframeworks inside.
- Select your application project in the Project Navigator (blue project icon), then select your app's target under Targets section.
- Open General panel, scroll to Frameworks, Libraries & Embedded Content and expand it.
- Make sure all three frameworks are added there, if not add them with the
+
button and selectEmbed & Sign
in Embed column
Swift Package Manager (SPM)
PaysafeWallet SDK can ce integrated using Swift Package Manager, by creating local package definition that references binary artifacts.
- Create directory named PaysafeWallet in your project
- Create
Package.swift
file in that directory with following content
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "PaysafeWallet",
platforms: [
.iOS(.v14)
],
products: [
.library(name: "PaysafeWallet",
targets: ["PaysafeWallet", "TMXProfiling", "TMXProfilingConnections"]),
],
targets: [
.binaryTarget(name: "PaysafeWallet",
url: "https://repository.paysafe.com/ios/com/paysafe/paysafe-wallet-saas-ios/0.6.3/paysafe-wallet-saas-ios-0.6.3.zip",
checksum: "0f15ae5e7dee9713737cc679af7e4df1f375784a59c1afdf0128bd649e19c715"),
.binaryTarget(name: "TMXProfiling",
url: "https://repository.paysafe.com/ios/com/lexisnexisrisk/threatmetrix/tmxprofiling-ios/7.2.40/tmxprofiling-ios-7.2.40.zip",
checksum: "1391d02ddf845c4db4346c7283dfedd5c89392588a14a4207a251b48d5f44916"),
.binaryTarget(name: "TMXProfilingConnections",
url: "https://repository.paysafe.com/ios/com/lexisnexisrisk/threatmetrix/tmxprofiling-connections-ios/7.2.40/tmxprofiling-connections-ios-7.2.40.zip",
checksum: "859360b71108c8f11ba043e93406df6010b2a8ff75240fec7354ed2050e3bafd")
]
)
- Open your Xcode project
- Select File > Add Packages... > Add Local... and select PaysafeWallet directory you have already created
- PaysafeWallet will appear under Packages group in Xcode
- Select your application project in the Project Navigator (blue project icon), then select your app's target under Targets section.
- Open General panel, scroll to Frameworks, Libraries & Embedded Content and expand it.
- Click on
+
button and pick PaysafeWallet under PaysafeWallet package
Note! When updating to new version of PaysafeWallet, make sure checksum is updated. Checksum can be calculated by executing
shasum -a 256 paysafe-wallet-saas-ios-0.4.0.zip | sed 's/ .*//'
on the downloaded artefact.
Usage
All wallet operations are provided via the Wallet
singleton:
import PaysafeWallet
let wallet = Wallet.instance
Configure SDK
In order to use the SDK, you need to configure it, configuration will be stored as long as you application is
not terminated. This is done by calling the configure
method of the Wallet
instance with a configuration token. Mind
that configure
is async operation and needs to be waited to complete.
// issue a <config-token> from your backend server
let configuration = Wallet.Configuration(configToken: "<config-token>", /* the config token you have received from your backend server */
baseURL: "https://api.paysafe.com") /* or your own server, which proxies the requests to the Paysafe Wallet API */
wallet.configure(with: configuration, completion: { result in
switch result {
case .success(let configurationResult):
// Request user token using configurationResult.digitalFingerprint
case .failure(let error):
// Handle error
}
})
The configuration token is issued from your backend server. The steps to generate it are explained in SDK Configuration.
Authenticate User
To ensure secure access to customer data by the SDK, it is necessary to provide a customer token. Customer tokens
exclusively permit access to resources linked to the specific customer for whom the token was generated. Call the
authenticate
method of the Wallet
instance to set the customer token:
// issue a <customer-token> from your backend server, passing configureResult.digitalFingerprint
let authConfiguration = Wallet.AuthenticationConfiguration(accessToken: "<customer-token>")
wallet.authenticate(with: authConfiguration)
The customer token is issued from your backend server passing the digitalFingerprint
value from the configuration result.
More details on getting the customer token are available in SDK User Authentication.
Wallet Operations
If the Configure SDK and the Authenticate operations were successful, you can start using the SDK for wallet operations.
wallet.profileService.getProfile(include: [], completion: { result in
switch result {
case .success(let customerInfo):
// Display customer information
case .failure(let error):
// Handle error
}
})
Objective-C support
Objective-C is not supported and SDK functionality can not be accessed using Objective-C.