Am getting error TypeError: t.getVersion is not a function
, i have searched only the solution i found was about using the upgraded version of braintree-web here. In my case am using 3.60.0
, but still get the error when i add braintree.dataCollector.create
.
https://js.braintreegateway.com/web/3.60.0/js/client.min.js
https://js.braintreegateway.com/web/3.60.0/js/data-collector.min.js
https://js.braintreegateway.com/web/dropin/1.22.1/js/dropin.min.js
var form = document.querySelector('#payment-form');
var client_token = "<?php echo $clientToken;?>";
braintree.dropin.create({
authorization: client_token,
container: '#dropin-container',
paypal: {
flow: 'vault'
}
}, function (createErr, instance) {
if (createErr) {
console.log('Create Error', createErr);
return;
}
form.addEventListener('submit', function (event) {
event.preventDefault();
braintree.dataCollector.create({
client: instance,
paypal: true
}, function (err, dataCollectorInstance) {
if (err) {
return;
}
document.querySelector('#device').value = dataCollectorInstance.deviceData;
});
instance.requestPaymentMethod(function (err, payload) {
if (err) {
console.log('Request Payment Method Error', err);
return;
}
// Add the nonce to the form and submit
document.querySelector('#nonce').value = payload.nonce;
form.submit();
});
});
});
I was starting out trying to get the simple Drop In example implemented and ran in to the same issue! I know you posted the question a while ago but this may help anyone else coming across this question, as I did .
The clue was @Simon_Weaver's answer to the question Braintree PayPal checkout component throwing “e.client.getVersion is not a function” and these 2 little lines...
Unfortunately @Simon_Weaver didn't provide a proper example and "cheated".
In essence, you'll need to create a separate
clientInstance
and passing that when creating adataCollector
instead ofinstance
I have also moved the initialisation of the
dataCollector
out of the form submit handler - no need to do it all then.*** This hasn't been tested but should get you going in the right direction ***