Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}).catch((err) => {
if (!(err.details && err.details.find && err.details.find(detail => detail.issue === 'CONTINGENCY'))) {
return ZalgoPromise.reject(err);
}
const url = `${ err.links.find(link => link.rel === '3ds-contingency-resolution').href }`;
return contingencyFlow.start(url);
}).then((payload) => {
// does contingency flow give a payload?
configuration.correlationId = correlationId;
// $FlowFixMe
configuration.paypalApi = getPayPalAPIDomain();
const orderIdFunction = () => {
return ZalgoPromise.resolve().then(() => {
return options.createOrder();
});
};
let button;
if (buttonSelector && options.onApprove) {
button = document.querySelector(buttonSelector);
if (!button) {
return ZalgoPromise.reject(new Error(`Could not find selector \`${ buttonSelector }\` on the page`));
}
}
const hostedFieldsCreateOptions = JSON.parse(JSON.stringify(options));
return btClient.create({
authorization: clientToken,
paymentsSdk: true,
configuration
}).then((btClientInstance) => {
hostedFieldsCreateOptions.paymentsSdk = true;
hostedFieldsCreateOptions.client = btClientInstance;
return hostedFields.create(hostedFieldsCreateOptions);
}).then((hostedFieldsInstance) => {
hostedFieldsInstance.submit = createSubmitHandler(hostedFieldsInstance, orderIdFunction);
window.xprops.onApprove = avoid('onApprove', () => ZalgoPromise.reject(new Error(`Avoid onApprove`)));
window.xprops.createOrder = avoid('createOrder', () => ZalgoPromise.reject(new Error(`Avoid createOrder`)));
window.xprops.onApprove = avoid('onApprove', () => ZalgoPromise.reject(new Error(`Avoid onApprove`)));
} catch (err) {
return;
}
if (!window || window.closed) {
return;
}
try {
receiveMessage({
data: message,
origin: this.origin,
source: this.source
}, { on, send });
} catch (err) {
ZalgoPromise.reject(err);
}
}
}
const winDetails = popupWindowsByName.get(data.name);
if (!winDetails) {
return;
}
try {
receiveMessage({
data: message,
origin: winDetails.domain,
source: winDetails.win
}, { on, send });
} catch (err) {
ZalgoPromise.reject(err);
}
}
};
.catch(err => {
return ZalgoPromise.all([
close(),
ZalgoPromise.reject(err)
]);
}).then(noop);
});