3DS Mobile SDK Methods
Create Session
This method collects information from the browser on the background and sends it to the Basis Theory API, which then returns a newly created 3DS section.
Usage
- iOS
- Android
let threeDSService = // Initialize threeDSService
let session = try await threeDSService.createSession(tokenId: textFieldContent)
let threeDSService = // Initialize threeDSService
let session = await threeDSService.createSession(tokenId)
Parameters
The createSession
method takes an object as parameter w/ the following attributes:
Attribute | Required | Type | Description |
---|---|---|---|
pan | true | string | The Basis Theory token id for the card token to be used |
Return
The method returns a CreateThreeDsSessionResponse
object with the following attributes:
Attribute | Type | Description |
---|---|---|
id | string | The created session id |
cardBrand | string | The brand for the used card (i.e. Visa) |
Start Challenge
This method initiates the 3DS challenge process, if it was deemed necessary during the 3DS authentication.
Usage
- iOS
- Android
let threeDSService = // Initialize threeDSService
let session = // Create 3DS Session
try await self.threeDSService.startChallenge(
sessionId: sessionId, viewController: self,
onCompleted: { result in
// process successful challenge result
},
onFailure: { result in
// process failed challenge result
})
Parameters
The startChallenge
method takes in the following attributes:
Attribute | Type | Description |
---|---|---|
sessionId | string | The 3DS session ID provided by createSession |
viewController | Activity | ViewController |
onCompleted | Function | Callback to handle 3DS challenge completion. |
onFailure | Function | Callback to handle 3DS challenge failure |
Both callback functions take a ChallengeResponse
object with the following properties:
public struct ChallengeResponse {
public let id: String
public let status: String // "successful" | "attempted" | "failed" | "unavailable" | "rejected"
public let details: String? // additional details depending on the status
}
let threeDSService = // Initialize threeDSService
let session = // Create 3DS Session
threeDsService.startChallenge(
session.id,
activity, // current activity
::onChallengeCompleted, // success handler
::onChallengeFailed // failure handler
)
Parameters
The startChallenge
method takes in the following attributes:
Attribute | Type | Description |
---|---|---|
sessionId | string | The 3DS session ID provided by createSession |
activity | Activity | Activity or FragmentActivity |
onCompleted | Function | Callback to handle 3DS challenge completion. |
onFailure | Function | Callback to handle 3DS challenge failure |
Callbacks
Success callback
fun onChallengeCompleted(result: ChallengeResponse) {
// process successful challenge result
}
Failure callback
fun onChallengeFailed(result: ChallengeResponse) {
// process failed challenge result
}
Both callback functions take a ChallengeResponse
object with the following properties:
data class ChallengeResponse(
val id: String,
val status: String, // "successful" | "attempted" | "failed" | "unavailable" | "rejected"
val details: String? = null // additional details depending on the status
)