BTDataCollector

@objc
public class BTDataCollector : NSObject

Braintree’s advanced fraud protection solution.

  • Initializes a BTDataCollector instance.

    Declaration

    Swift

    @objc(initWithAuthorization:)
    public init(authorization: String)

    Parameters

    authorization

    A valid client token or tokenization key used to authorize API calls.

Public methods

  • Returns a client metadata ID.

    Note

    This returns a raw client metadata ID, which is not the correct format for device data when creating a transaction. Instead, it is recommended to use collectDeviceData.

    Declaration

    Swift

    @objc
    public func clientMetadataID(_ pairingID: String?) -> String

    Parameters

    pairingID

    A pairing ID to associate with this clientMetadataID must be 10-32 chars long or null

    Return Value

    A client metadata ID to send as a header

  • Collects device data based on your merchant configuration.

    We recommend that you call this method as early as possible, e.g. at app launch. If that’s too early, calling it when the customer initiates checkout is also fine. Use the return value on your server, e.g. with Transaction.sale.

    Declaration

    Swift

    @objc
    public func collectDeviceData(_ completion: @escaping (String?, Error?) -> Void)

    Parameters

    completion

    A completion block that returns either a device data string that should be passed into server-side calls, such as Transaction.sale, or an error with the failure reason.

  • collectDeviceData() Asynchronous

    Collects device data based on your merchant configuration.

    We recommend that you call this method as early as possible, e.g. at app launch. If that’s too early, calling it when the customer initiates checkout is also fine. Use the return value on your server, e.g. with Transaction.sale.

    Throws

    An Error describing the failure

    Declaration

    Swift

    public func collectDeviceData() async throws -> String

    Return Value

    A device data string that should be passed into server-side calls, such as Transaction.sale.

  • This method should be used for markets where high coverage of device data is needed (ex: Predictions Market). Collects device data based on your merchant configuration.

    We recommend that you call this method as early as possible, e.g. at app launch. If that’s too early, calling it when the customer initiates checkout is also fine. When using this method you should only proceed if a success is returned. In cases where an error is returned, retrying this method is recommended.

    Use the return value on your server, e.g. with Transaction.sale. or in client side requests such as PayPal, Venmo, or Local Payment Methods.

    Declaration

    Swift

    @objc
    public func collectDeviceDataOnSuccess(
        riskCorrelationID: String? = nil,
        _ completion: @escaping (String?, Error?) -> Void
    )

    Parameters

    riskCorrelationID

    Optional: A risk correlation ID to associate with this device data collection

    completion

    A completion block that returns either a device data string or an error with the failure reason. Retries are recommended on failure.

  • This method should be used for markets where high coverage of device data is needed (ex: Predictions Market). Collects device data based on your merchant configuration.

    We recommend that you call this method as early as possible, e.g. at app launch. If that’s too early, calling it when the customer initiates checkout is also fine. When using this method you should only proceed if a success is returned. In cases where an error is returned, retrying this method is recommended.

    Use the return value on your server, e.g. with Transaction.sale. or in client side requests such as PayPal, Venmo, or Local Payment Methods.

    Throws

    An Error describing the failure or timeout. Retries are recommended on failure to ensure coverage.

    Declaration

    Swift

    public func collectDeviceDataOnSuccess(riskCorrelationID: String? = nil) async throws -> String

    Parameters

    riskCorrelationID

    Optional: A risk correlation ID to associate with this device data collection.

    Return Value

    A device data string that should be passed into server-side calls, such as Transaction.sale.