Client-Side Implementation

Collecting device dataAnchorIcon

DataCollector enables you to collect data about a customer's device and correlate it with a session identifier on your server.

Get the SDKAnchorIcon

Add the following to your build.gradle:

  1. Groovy
dependencies {
    implementation 'com.braintreepayments.api:data-collector:4.49.1'
}

InitializingAnchorIcon

Drop-inAnchorIcon

Device data will be collected automatically when using Drop-in. Device data can be accessed on the DropInResult returned in onDropInSuccess.

  1. Java
  2. Kotlin
@Override
public void onDropInSuccess(@NonNull DropInResult dropInResult) {
    String deviceData = result.getDeviceData();
}

Send the device data string response from Drop-in to your server to be included in verification or transaction requests.

CustomAnchorIcon

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.

  1. Java
  2. 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
        });
    }
}

PayPalAnchorIcon

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.