createCardOnFile
Create a new Card-on-File.
Reference
Discussion
Further streamline your checkout experience by securely storing customer card details in BR-DGE to save them having to re-enter cardholder details in future.
Please see Vault for more information.
Please note that we cannot store CVV values with Card on File.
Example
This example demonstrates how to catch errors that might be thrown by a function that tries creating new Card-on-File.
suspend fun createNewCardOnFile() {
try {
val brdge = BrdgeAPI(clientAPIKey = Constants.prodClientAPIKey, domain = BrdgeDomain.Production)
val createCardOnFileResponse = brdge.paymentInstrumentTokenization.createCardOnFile(
cardData = this.cardData,
customerId = this.customerId
)
this.multiUseToken = createCardOnFileResponse.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 (error: BrdgeCustomerIdValidationError) {
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 multi-use token
Parameters
Payment instrument that is a credit or debit card without CVV.
Identifier for the merchant's customer who owns the payment instrument to be tokenized.
Throws
BR-DGE card-related validation errors. This will be the most common error thrown.
BR-DGE Customer ID validation errors.
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 validation errors.
This is an internal SDK error.