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. Device data collection capabilities are included in version 2.16.0+ of our JavaScript SDK.

To collect device data, pass some additional dataCollector options to your braintree.setup call. The following example is for custom, but will also work for dropin.

JavaScript
Copy
Copied
braintree.setup(CLIENT_AUTHORIZATION, 'custom', {
  dataCollector: {
    kount: {environment: 'sandbox'}
  },
  onReady: function (braintreeInstance) {
    // At this point, you should access the braintreeInstance.deviceData value
    // and provide it to your server, e.g. by injecting it into your form as a
    // hidden input.
    deviceData = braintreeInstance.deviceData;
  }
  /* ... */
});

Available options for dataCollector.kount.environment:

  • sandbox
  • production

The braintreeInstance returned by onReady will have an additional deviceData string value. It is up to you to provide this value to your server. The most common mechanism for this is to inject the device data value into your form as a hidden input inside of your onReady callback.

JavaScript
Copy
Copied
braintree.setup(CLIENT_AUTHORIZATION, 'custom', {
  dataCollector: {
    kount: {environment: 'sandbox'}
  },
  onReady: function (braintreeInstance) {
    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 = braintreeInstance.deviceData;
  }
  /* ... */
});

Standalone usage

If you are not using braintree.setup for your integration, you can still collect device data by setting up the data collector directly through braintree.data.setup:

JavaScript
Copy
Copied
var dataCollector = braintree.data.setup({
  kount: {environment: 'sandbox'},
});

dataCollector.deviceData; /* for use in transaction creation */

You can use the teardown method to reset to a clean state; the same best practices apply to calling teardown on braintree.data.setup as do braintree.setup. In the case of braintree.data.setup calling teardown will invalidate any previously generated device data from the client session.

JavaScript
Copy
Copied
dataCollector.teardown(); /* for cleanly resetting your integration */

Device data with PayPal

If you're also accepting PayPal using the Vault flow, you can collect device data for PayPal transactions by adding paypal: true to your dataCollector options.

JavaScript
Copy
Copied
braintree.setup(CLIENT_AUTHORIZATION, 'custom', {
  dataCollector: {
    kount: {environment: 'sandbox'},
    paypal: true
  },
  onReady: function (braintreeInstance) {
    deviceData = braintreeInstance.deviceData;
  }
  /* ... */
});

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.
  • If you are using Kount Standard, have customer service reps create transactions in the Braintree Control Panel instead of creating orders via your website. This ensures that the transactions will be automatically approved by Kount's fraud rules. Kount Custom merchants need to create their own rules to mimic this behavior.

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 checks credit card and certain Google Pay transactions.

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 Accounts team and determined Kount Custom is a good fit for your business, they'll help you get your own credentials and a Kount merchant ID. Then, follow the instructions below to use your own Kount credentials and rules instead of Braintree's.

To use your own Kount merchant ID for fraud detection, pass it in as an additional dataCollector.kount.merchantId parameter in your braintree.setup call:

JavaScript
Copy
Copied
braintree.setup(CLIENT_AUTHORIZATION, 'custom', {
  dataCollector: {
    kount: {
      environment: 'sandbox',
      merchantId: 'my-custom-kount-id'
    }
  },
  onReady: function (braintreeInstance) {
    braintreeInstance.deviceData;
  }
  /* ... */
});

Contact our Accounts team for more information.

Next Page: Server-side →

Still have questions?

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