Credit Cards
Client-Side Implementation
Important
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 iOS SDK to version 6.17.0+ 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:
- 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
}
}
}