Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var setupComplete = false;
var self = this;
var paypalType = isCredit ? 'paypalCredit' : 'paypal';
var paypalConfiguration = this.model.merchantConfiguration[paypalType];
this.paypalConfiguration = assign({}, paypalConfiguration);
this.model.asyncDependencyStarting();
asyncDependencyTimeoutHandler = setTimeout(function () {
self.model.asyncDependencyFailed({
view: self.ID,
error: new DropinError('There was an error connecting to PayPal.')
});
}, ASYNC_DEPENDENCY_TIMEOUT);
return btPaypal.create({client: this.client}).then(function (paypalInstance) {
var checkoutJSConfiguration;
var buttonSelector = '[data-braintree-id="paypal-button"]';
var environment = self.client.getConfiguration().gatewayConfiguration.environment === 'production' ? 'production' : 'sandbox';
var locale = self.model.merchantConfiguration.locale;
self.paypalInstance = paypalInstance;
self.paypalConfiguration.offerCredit = Boolean(isCredit);
checkoutJSConfiguration = {
env: environment,
style: self.paypalConfiguration.buttonStyle || {},
commit: self.paypalConfiguration.commit,
payment: function () {
return paypalInstance.createPayment(self.paypalConfiguration).catch(reportError);
},
onAuthorize: function (data) {