Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ApplePayView.prototype.initialize = function () {
var self = this;
var isProduction = self.client.getConfiguration().gatewayConfiguration.environment === 'production';
self.applePayConfiguration = assign({}, self.model.merchantConfiguration.applePay);
self.applePaySessionVersion = self.applePayConfiguration.applePaySessionVersion || DEFAULT_APPLE_PAY_SESSION_VERSION;
delete self.applePayConfiguration.applePaySessionVersion;
self.model.asyncDependencyStarting();
return btApplePay.create({client: this.client}).then(function (applePayInstance) {
var buttonDiv = self.getElementById('apple-pay-button');
self.applePayInstance = applePayInstance;
self.model.on('changeActivePaymentView', function (paymentViewID) {
if (paymentViewID !== self.ID) {
return;
}
global.ApplePaySession.canMakePaymentsWithActiveCard(self.applePayInstance.merchantIdentifier).then(function (canMakePayments) {
if (!canMakePayments) {
if (isProduction) {
self.model.reportError('applePayActiveCardError');
} else {
console.error('Could not find an active card. This may be because you\'re using a production iCloud account in a sandbox Apple Pay Session. Log in to a Sandbox iCloud account to test this flow, and add a card to your wallet. For additional assistance, visit https://help.braintreepayments.com'); // eslint-disable-line no-console
self.model.reportError('developerError');