Search code examples
javascriptbraintree

Braintree kount dataCollector throwing “e.getVersion is not a function”


Using version 3.36.0 of the braintree sdk I get the error e.getVersion is not a function. I'm including the client, hosted-fields and data-collector .js files. Not sure what I'm missing. My hosted fields integration works fine until I add the below code to the hosted fields create call back.

                braintree.dataCollector.create({
                    client: hostedFieldsInstance,
                    kount: true
                }, function (err, dataCollectorInstance) {
                    console.log('callback dc');
                    if (err) {
                        // Handle error in data collector creation
                        return;
                    }
                    var form = document.getElementById('product-details-form');
                    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;
                });

Solution

  • Found the issue with the help of braintree support. I was setting the client to the hostedFieldsInstance instead of the clientInstance.