Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function initHostedFields() {
client.create({ authorization: braintreeParams.token }, function (
clientErr,
clientInstance
) {
if (clientErr) {
showErrorMessage(loadingErrorMsg);
return;
}
dataCollector.create({ client: clientInstance, kount: true }, function (
clientErr,
dataCollectorInstance
) {
if (clientErr) {
showErrorMessage(loadingErrorMsg);
return;
}
setAuthorization(authorization, onAuthorizationSuccess) {
if (!authorization && this.authorization) {
this.teardown();
} else if (authorization && authorization !== this.authorization) {
if (this.authorization) { this.teardown(); }
this.authorization = authorization;
Braintree.create({ authorization }, (err, clientInstance) => {
if (err) {
this.onError(err);
} else {
this.create(clientInstance, onAuthorizationSuccess);
if (this.wrapperHandlers.onDataCollectorInstanceReady) {
BraintreeDataCollector.create({
client: clientInstance,
kount: true,
}, this.wrapperHandlers.onDataCollectorInstanceReady);
}
}
});
}
}
fetchEnv((envData) => {
let currency = getCurrency().toLowerCase();
client.create({ authorization: braintreeParams.token }, function (
clientErr,
clientInstance
) {
if (clientErr) {
showErrorMessage(loadingErrorMsg);
return;
}
paypalCreate(
{
client: clientInstance,
merchantAccountId: envData.BRAINTREE_MERCHANT_ACCOUNTS[currency],
},
function (paypalCheckoutErr, paypalCheckoutInstance) {
if (paypalCheckoutErr) {
showErrorMessage(loadingErrorMsg);
function create(options) {
if (!options.authorization) {
return Promise.reject(new DropinError('options.authorization is required.'));
}
return client.create({
authorization: options.authorization
}).catch(function (err) {
return Promise.reject(new DropinError({
message: 'There was an error creating Drop-in.',
braintreeWebError: err
}));
}).then(function (clientInstance) {
clientInstance = setAnalyticsIntegration(clientInstance);
if (clientInstance.getConfiguration().authorizationType === 'TOKENIZATION_KEY') {
analytics.sendEvent(clientInstance, 'started.tokenization-key');
} else {
analytics.sendEvent(clientInstance, 'started.client-token');
}
return new Promise(function (resolve, reject) {