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 SDKAnchorIcon

Add the following in your app-level build.gradle:

  1. Groovy
dependencies {
  implementation 'com.braintreepayments.api:card:4.49.1'
}

InitializationAnchorIcon

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:

  1. Kotlin
  2. 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
    }
  }
}

If you accept cookies, we’ll use them to improve and customize your experience and enable our partners to show you personalized PayPal ads when you visit other sites. Manage cookies and learn more