I encounter very strange behavior with the Braintree dropin user interface in the Ionic framework.
So, I use the solution: It is not possible to create a Braintree client token with a client ID
to create logic for the first time and return the client.
$http({
method: 'POST',
url: 'http://localhost:3000/api/v1/token',
data: {
customerId: braintreeReturnCustomerId
}
})
How I went to customerId in my customer view. On my nodejs server, I have logic to check if customerId is undefined. If it is undefined, this is the first client. If customerId matters, he is a return customer. Very straightforward:
app.post('/api/v1/token', jsonParser, function (request, response) {
var customerId = request.body.customerId;
if (customerId == undefined) {
gateway.clientToken.generate({}, function (err, res) {
if (err) throw err;
response.json({
"client_token": res.clientToken
});
});
} else {
console.log ("using exsiting customer!");
gateway.clientToken.generate({
customerId: customerId
}, function (err, res) {
if (err) throw err;
response.json({
"client_token": res.clientToken
});
});
}
});
Ionic View. , , , frist, customerId , . . ( Ionic ), , . clientId, . , "else" gateway.clientToken.generate({customerId: customerId}...
,
$window.location.reload(true);
Chrome ( Ionic Serve), .
, "cache: false". . , Dropin . , javascript- dropin UI, , , ...