tokenizeSingleUseCardholderData

Tokenize cardholder data into a single-use token.

Reference

REST API

Discussion

For one off payments, you can exchange cardholder data for a single-use token that can be used as a payment instrument via BR-DGEs Tokenized Payment Flow.

Example

This example demonstrates how to catch errors that might be thrown by a function that tries tokenizing the customers card data.

suspend fun tokenizeCardDataCatchingErrors(cardData: BrdgeCardData): String {
try {
val brdge = BrdgeAPI(clientAPIKey = Constants.prodClientAPIKey, domain = BrdgeDomain.Production)
val tokenizationResponse = brdge.paymentInstrumentTokenization.tokenizeSingleUseCardholderData(cardData)
return tokenizationResponse.token
} catch (cv2Error: BrdgeCardValidationError.CV2Value) {
errorMessage = "Wrong CV2 value"
} catch (expiryDateError: BrdgeCardValidationError.ExpiryDateValue) {
errorMessage = "Wrong Expiry Date value. It needs to be in MM-YY format."
} catch (error: BrdgeCardValidationError) {
errorMessage = error.message
} catch (unauthorizedError: BrdgeNetworkError.Unauthorised) {
errorMessage = "Unauthorised..."
} catch (apiError: BrdgeNetworkError.ApiError) {
errorMessage = apiError.message
} catch (urlError: BrdgeNetworkError.UrlError) {
errorMessage = "No internet connection, please try again..."
} catch (e: Exception) {
errorMessage = "Something went wrong... Please try again."
}
}

Return

Response with single-use token.

Parameters

cardData

Payment instrument to be tokenized (cardholder data).

Throws

BR-DGE card-related validation errors. This will be the most common error thrown.

This will be thrown if the BR-DGE REST API error is not a validation error or the validation error code cannot be matched to BrdgeCardValidationError.

This is an internal SDK error.