Client-Side Implementation
Important
The SSL certificates for Braintree Mobile (iOS and Android) SDKs are set to expire on March 30, 2026. 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.
Collecting device data
DataCollector
enables you to collect data about a customer's device and correlate it
with a session identifier on your server.
Get the SDK
Add the following to your build.gradle
:
- Kotlin
- Groovy
dependencies {
implementation("com.braintreepayments.api:data-collector:5.2.0")
}
- Groovy
dependencies {
implementation 'com.braintreepayments.api:data-collector:4.49.1'
}
Initializing
Create a DataCollector
with a Tokenization Key or Client Token and call
DataCollector.collectDeviceData()
when verifying a card or creating a transaction.
- Kotlin
class MyActivity : AppCompatActivity() {
private lateinit var dataCollector: DataCollector
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
dataCollector = DataCollector(
context = this,
authorization = "[TOKENIZATION_KEY or CLIENT_TOKEN]"
)
}
private fun collectDeviceData() {
val dataCollectorRequest = DataCollectorRequest(hasUserLocationConsent)
dataCollector.collectDeviceData(this, dataCollectorRequest) { dataCollectorResult ->
when (dataCollectorResult) {
is DataCollectorResult.Success -> {
// send deviceData to your server to be included in verification or transaction requests
}
is DataCollectorResult.Failure -> {
// Handle error
}
}
}
}
}
Note
User Data Consent
Merchant applications are responsible for collecting user data consent. If your app has obtained consent from the user to collect location data in compliance with Google Play Developer Program policies , set `hasUserLocationConsent` to `true`. This flag enables PayPal to collect necessary information required for Fraud Detection and Risk Management. Merchant App Disclosure
Merchant applications may be required to display a disclosure before collecting user location data in accordance with Google’s Best practices for prominent disclosures and consent. By setting
Merchant applications are responsible for collecting user data consent. If your app has obtained consent from the user to collect location data in compliance with Google Play Developer Program policies , set `hasUserLocationConsent` to `true`. This flag enables PayPal to collect necessary information required for Fraud Detection and Risk Management. Merchant App Disclosure
Merchant applications may be required to display a disclosure before collecting user location data in accordance with Google’s Best practices for prominent disclosures and consent. By setting
hasUserLocationConsent
to true, your app is enabled to share device
location data with a third party (PayPal) for Fraud Detection and Risk Management.
Drop-in
Device data will be collected automatically when using Drop-in. Device data can be accessed on the
DropInResult
returned in onDropInSuccess
.
- Java
- Kotlin
@Override
public void onDropInSuccess(@NonNull DropInResult dropInResult) {
String deviceData = result.getDeviceData();
}
Note
If you choose to
automatically vault a customer's new payment method, verifications for those payment methods will not include device data when they are evaluated by
our Premium Fraud Management Tools. Subsequent transactions can still pass device data.
Custom
First, create a BraintreeClient
with a
ClientTokenProvider
or Tokenization Key. Construct a DataCollector
and call
dataCollector#collectDeviceData
when verifying a card or creating a transaction.
Note
User Data Consent
Merchant applications are responsible for collecting user data consent. If your app has obtained consent from the user to collect location data in compliance with Google Play Developer Program policies , set `hasUserLocationConsent` to `true`. This flag enables PayPal to collect necessary information required for Fraud Detection and Risk Management. Merchant App Disclosure
Merchant applications may be required to display a disclosure before collecting user location data in accordance with Google’s Best practices for prominent disclosures and consent. By setting
Merchant applications are responsible for collecting user data consent. If your app has obtained consent from the user to collect location data in compliance with Google Play Developer Program policies , set `hasUserLocationConsent` to `true`. This flag enables PayPal to collect necessary information required for Fraud Detection and Risk Management. Merchant App Disclosure
Merchant applications may be required to display a disclosure before collecting user location data in accordance with Google’s Best practices for prominent disclosures and consent. By setting
hasUserLocationConsent
to true, your app is enabled to share device
location data with a third party (PayPal) for Fraud Detection and Risk Management.
- Java
- Kotlin
public class MyActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
braintreeClient = new BraintreeClient(this, new ExampleClientTokenProvider());
dataCollector = new DataCollector(braintreeClient);
}
private void collectDeviceData() {
DataCollectorRequest dataCollectorRequest = new DataCollectorRequest(hasUserLocationConsent);
dataCollector.collectDeviceData(this, dataCollectorRequest, (deviceData, error) -> {
// send deviceData to your server to be included in verification or transaction requests
});
}
}
PayPal
If you're also accepting PayPal using the
Vault flow, you can simultaneously collect that
device data by using the dataCollector
.
See the PayPal Vault guide for details.