Credit Cards
Client-Side Implementation
The SSL certificates for all Braintree SDKs are set to expire by June 30, 2025. This will impact existing versions of the SDK in published versions of your app. To reduce the impact, upgrade the Android SDK to version 4.45.0+ or version 5.0.0+ for the new SSL certifications.
If you do not decommission your app versions that include the older SDK versions or force upgrade your app with the updated certificates by the expiration date, 100% of your customer traffic will fail.
Get the SDK
Add the following in your app-level build.gradle:
- Kotlin
- Groovy
dependencies {
implementation("com.braintreepayments.api:card:5.2.0")
}
Initialization
Collect card data from your UI to construct a Card. Then, create a CardClient with a Tokenization Key or Client Token and call tokenize() to get a nonce that can be sent to your server:
- Kotlin
class MyActivity : AppCompatActivity() {
private fun tokenizeCard() {
val card = Card(
number = "4111111111111111",
expirationMonth = "12",
expirationYear = "2028",
cvv = "123"
)
val cardClient = CardClient(
context = this,
authorization = "[TOKENIZATION_KEY or CLIENT_TOKEN]"
)
cardClient.tokenize(card) { cardResult ->
when (cardResult) {
is CardResult.Success -> {
// send cardResult.nonce.string to your server
}
is CardResult.Failure -> {
// handle error
}
}
}
}
}