Advanced Client-Side Implementation
Use Advanced client-side if you need more direct control over card inputs, formatting, validation, or tokenization behavior that Card Fields doesn't cover.
Card Fields is recommended for merchants who want SDK-managed card entry while keeping control over the rest of checkout. Advanced client-side is intended for merchants with custom requirements who need to directly manage more of the card entry flow.
If you don't need that level of control, use Standard client-side to integrate Card Fields instead.
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:
- Groovy
dependencies {
implementation 'com.braintreepayments.api:card:4.49.1'
}Initialization
Collect card data from your UI to construct a Card. Then, create a BraintreeClient with a ClientTokenProvider or Tokenization Key. Construct a CardClient and call tokenize to get a nonce that can be sent to your server:
- Kotlin
- Java
class MyActivity: AppCompatActivity() {
private lateinit var braintreeClient: BraintreeClient
private lateinit var cardClient: CardClient
private fun tokenizeCard() {
val card = Card()
card.number = "4111111111111111"
card.expirationDate = "09/2018"
braintreeClient = BraintreeClient(this, ExampleClientTokenProvider())
cardClient = CardClient(braintreeClient)
cardClient.tokenize(card) { cardNonce, error ->
// send cardNonce.string to your server
}
}
}