Collecting device data

Braintree Data enables you to collect data about a customer's device and include it when creating a transaction or verification on your server. For more information, refer to the iOS header file for BTData.

  1. Add the Braintree/Data subspec to your Podfile. For example:
    pod 'Braintree', '~> 3.9'
    pod 'Braintree/Data', '~> 3.9'
  2. In your app, initialize BTData using initWithClient: for your environment, e.g. sandbox:

    #import "Braintree.h"
    #import "BTData.h"
    // ...
    // Retain your `BTData` instance for your entire application lifecycle.
    @property (nonatomic, strong) BTData *data;
    // ...
    // Example. You should use your existing Braintree or BTClient object.
    // If CLIENT_TOKEN_FROM_SERVER is invalid, `braintree.client` and
    // the subsequent `` object will be nil.
    Braintree *braintree = [Braintree braintreeWithClientToken:CLIENT_TOKEN_FROM_SERVER];
    BTClient *client = braintree.client; = [[BTData alloc] initWithClient:client environment:BTDataEnvironmentSandbox];
  3. Optionally, set a delegate to receive lifecycle notifications.
  4. Before submitting a transaction from your server, call collectDeviceData:
    NSString *deviceData = [ collectDeviceData];
    NSLog(@"Send this device data to your server: %@", deviceData);
  5. Send the returned string to your server along with transaction data to be included with the request to the Braintree gateway.

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 Advanced Fraud Tools. Subsequent transactions can still pass device data.


If you're also accepting PayPal using the Vault flow, you can simultaneously collect that device data by adding a paypal option to your dataCollector. See the PayPal Vault guide for details.

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 a few 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.
  • Skip Advanced Fraud Tools checks completely to avoid sending a transaction to Kount for evaluation.

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 is also compatible with many 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.

  1. Once you've acquired your Kount merchant ID, initialize BTData using initWithClient:environment:.
  2. Invoke setCollectorUrl: and/or setFraudMerchantId: with your own Kount merchant ID.
  3. Call collectDeviceData as shown above.
[self.dataCollector setFraudMerchantId:@"YOUR_MERCHANT_ID"];
[self.dataCollector collectDeviceData];

Contact us for more information.

Next Page: Server-side →