Collecting device data

To detect fraud, use dataCollector to collect information about a customer's device on your checkout page and pass it to Kount for review.

If you are using the Drop-in UI, you can integrate using the Drop-in integration steps. Otherwise, use the following integration method:

Custom

If you are using script tags to load files, make sure to include:

HTML
Copy
Copied
<script src="https://js.braintreegateway.com/web/3.26.0/js/client.min.js"></script>
<script src="https://js.braintreegateway.com/web/3.26.0/js/data-collector.min.js"></script>

To collect device data, create a client and a dataCollector instance with some options. You can use the same client as you are using for other components, such as hostedFields or paypal.

JavaScript
Copy
Copied
braintree.client.create({
  authorization: 'CLIENT_AUTHORIZATION'
}, function (err, clientInstance) {
  // Creation of any other components...

  braintree.dataCollector.create({
    client: clientInstance,
    kount: true
  }, function (err, dataCollectorInstance) {
    if (err) {
      // Handle error in creation of data collector
      return;
    }
    // At this point, you should access the dataCollectorInstance.deviceData value and provide it
    // to your server, e.g. by injecting it into your form as a hidden input.
    var deviceData = dataCollectorInstance.deviceData;
  });
});

The data returned will have a deviceData string value. It is up to you to provide this value to your server. A common mechanism for this is to inject the device data value into your form as a hidden input.

JavaScript
Copy
Copied
// Inside of your client create callback...
braintree.dataCollector.create({
  client: clientInstance,
  kount: true
}, function (err, dataCollectorInstance) {
  if (err) {
    // Handle error in data collector creation
    return;
  }
  var form = document.getElementById('my-form-id');
  var deviceDataInput = form['device_data'];

  if (deviceDataInput == null) {
    deviceDataInput = document.createElement('input');
    deviceDataInput.name = 'device_data';
    deviceDataInput.type = 'hidden';
    form.appendChild(deviceDataInput);
  }

  deviceDataInput.value = dataCollectorInstance.deviceData;
});

Drop-in

Collect device data with the Drop-in UI by including a dataCollector object in your create call:

JavaScript
Copy
Copied
braintree.dropin.create({
  authorization: 'CLIENT_AUTHORIZATION',
  container: '#dropin-container',
  dataCollector: {
    kount: true // Required if Kount fraud data collection is enabled
  }
}, function (createErr, instance) {
  if (createErr) {
    // Handle error in Drop-in creation
    return;
  }

  button.addEventListener('click', function () {
    instance.requestPaymentMethod(function (requestPaymentMethodErr, payload) {
      // Submit payload.nonce and payload.deviceData to your server
    });
  });
});

When requestPaymentMethod is called, the response will include deviceData to send to your server. A common mechanism for this is to inject the device data value into your form as a hidden input.

JavaScript
Copy
Copied
var form = document.getElementById('my-form-id');
var deviceDataInput = form['device_data'];
var nonceInput = form['payment_method_nonce'];

braintree.dropin.create({
  authorization: 'CLIENT_AUTHORIZATION',
  container: '#dropin-container',
  dataCollector: {
    kount: true
  }
}, function (createErr, instance) {
  if (deviceDataInput == null) {
    deviceDataInput = document.createElement('input');
    deviceDataInput.name = 'device_data';
    deviceDataInput.type = 'hidden';
    form.appendChild(deviceDataInput);
  }

  button.addEventListener('click', function () {
    instance.requestPaymentMethod(function (requestPaymentMethodErr, payload) {
      deviceDataInput.value = payload.deviceData;
      nonceInput.value = payload.nonce;
    });
  });
});

Device data with PayPal

If you're also accepting PayPal using the Vault flow, you can collect device data for PayPal transactions.

Custom

If you're integrating with the dataCollector component, collect PayPal device data by adding paypal: true to your dataCollector.create options.

JavaScript
Copy
Copied
braintree.client.create({
  authorization: 'CLIENT_AUTHORIZATION'
}, function (err, clientInstance) {
  braintree.dataCollector.create({
    client: clientInstance,
    kount: true,
    paypal: true
  }, function (err, dataCollectorInstance) {
    // Prepare to send dataCollectorInstance.deviceData to your server
    // for both Kount and PayPal
  });
});

Drop-in

If you're using the Drop-in UI, collect PayPal device data by adding paypal: true to your dataCollector options in your create call.

JavaScript
Copy
Copied
braintree.dropin.create({
  authorization: 'CLIENT_AUTHORIZATION',
  container: '#dropin-container',
  dataCollector: {
    kount: true, // Required if Kount fraud data collection is enabled
    paypal: true // Required if PayPal fraud data collection is enabled
  }
}, function (createErr, instance) {
  button.addEventListener('click', function () {
    instance.requestPaymentMethod(function (requestPaymentMethodErr, payload) {
      // Send device data and nonce to your server
      deviceDataInput.value = payload.deviceData;
      nonceInput.value = payload.nonce;
    });
  });
});

Creating orders on behalf of customers

Kount, our fraud detection partner, flags multiple orders from the same device if there are multiple card numbers associated with that device. If your customer service reps manually create orders through your normal checkout flow, Kount may identify false positives. This can increase your decline rate.

There are two ways to prevent false positives when creating multiple orders on the same device:

  • Build a separate checkout flow that doesn’t use device data and make it accessible only to customer service reps (e.g. via a VPN). This prevents Kount from linking and flagging transactions based on device data.
  • Have customer service reps create transactions in the Braintree Control Panel instead of creating orders via your website. This bypasses Kount’s fraud screening.

Kount Custom integration

We offer a direct integration with Kount, our partner for providing advanced fraud detection technology. Like our Kount Standard integration, Kount Custom only checks credit card payment methods.

To use this feature, you must be processing at least 2500 transactions per month, and you’ll be subject to additional fees from Kount for their services. Learn more about the requirements and considerations.

Once you have spoken with our Account Management team and determined that Kount Custom is a good fit for your business, they'll help you get your own credentials and a Kount merchant ID. After you're set up, the JS v3 SDK will automatically start using the new Kount details that we configured in your Braintree gateway – no changes to your integration will be necessary.

See also

Contact our Accounts team for more information.

Next: Server-side →

Still have questions?

If you can’t find an answer, contact our Support team.