tokenizeCardOnFile
Tokenize Card-on-File multi-use token into a single-use token.
Reference
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.
CVVs cannot be stored with multi-use tokens, but you can temporarily associate single use tokens with CVVs
Example
This example demonstrates how to catch errors that might be thrown by a function that tries tokenizing the Card-on-File multi-use token into a single-use token.
suspend fun tokenizeCardDataCatchingErrors(cardData: BrdgeCardData): String {
try {
val brdge = BrdgeAPI(clientAPIKey = Constants.prodClientAPIKey, domain = BrdgeDomain.Production)
val tokenizationResponse = brdge.paymentInstrumentTokenization.tokenizeCardOnFile(
token = this.multiUseToken,
cv2: this.cv2
)
return tokenizationResponse.token
} catch (cv2Error: BrdgeTokenizationValidationError.cv2Value) {
errorMessage = "Wrong CV2 value"
} catch (tokenLengthError: BrdgeTokenizationValidationError.tokenLength) {
errorMessage = "Wrong token length"
} catch (error: BrdgeTokenizationValidationError) {
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
Payment instrument to be tokenized (Card-on-File multi-use token).
: CV2 of the Tokenized payment instrument.
Throws
BR-DGE tokenization-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.