Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (id !== orderID) {
throw new Error(`Expected orderID to be ${ orderID }, got ${ id }`);
}
return renderToOriginal(...args);
});
}));
return checkoutInstance;
}));
createButtonHTML();
await mockSetupButton({ merchantID: [ 'XYZ12345' ], fundingEligibility: DEFAULT_FUNDING_ELIGIBILITY });
await clickButton(FUNDING.PAYPAL);
});
});
mockFunction(checkoutInstance, 'render', expect('remder', async ({ original: renderToOriginal, args }) => {
return props.createOrder().then(id => {
if (id !== orderID) {
throw new Error(`Expected orderID to be ${ orderID }, got ${ id }`);
}
return renderToOriginal(...args);
});
}));
return checkoutInstance;
}));
const fundingEligibility = {
[ FUNDING.PAYPAL ]: {
eligible: true
},
[ FUNDING.CARD]: {
eligible: true,
vendors: {
[ CARD.VISA ]: {
eligible: true
},
[ CARD.AMEX ]: {
eligible: true
},
[ CARD.MASTERCARD ]: {
eligible: true
}
}
}
if (id !== orderID) {
throw new Error(`Expected orderID to be ${ orderID }, got ${ id }`);
}
return renderToOriginal(...args);
});
}));
return checkoutInstance;
}));
createButtonHTML();
await mockSetupButton({ merchantID: [ 'XYZ12345' ], fundingEligibility: DEFAULT_FUNDING_ELIGIBILITY });
await clickButton(FUNDING.PAYPAL);
});
});
if (!props.window) {
throw new Error(`Expected window to be passed to Checkout`);
}
return CheckoutOriginal(props);
}));
window.xprops.onClick = mockAsyncProp(expect('onClick', (data, actions) => {
return ZalgoPromise.delay(50).then(() => actions.resolve());
}));
window.xprops.createOrder = mockAsyncProp(expect('createOrder', () => ZalgoPromise.delay(50).then(() => orderID)));
window.xprops.onApprove = mockAsyncProp(expect('onApprove', () => ZalgoPromise.resolve()));
createButtonHTML();
await mockSetupButton({ merchantID: [ 'XYZ12345' ], fundingEligibility: DEFAULT_FUNDING_ELIGIBILITY });
await clickButton(FUNDING.PAYPAL);
});
});
mockFunction(window.paypal, 'Checkout', expect('Checkout', ({ original: CheckoutOriginal, args: [ props ] }) => {
const checkoutInstance = CheckoutOriginal(props);
mockFunction(checkoutInstance, 'renderTo', expect('renderTo', async () => {
return props.onCancel({ orderID });
}));
return checkoutInstance;
}));
createButtonHTML();
await mockSetupButton({ merchantID: [ 'XYZ12345' ], fundingEligibility: DEFAULT_FUNDING_ELIGIBILITY });
await clickButton(FUNDING.PAYPAL);
});
});
return await wrapPromise(async ({ expect }) => {
const orderID = 'XXXXXXXXXX';
window.xprops.onInit = mockAsyncProp(expect('onInit', (data, actions) => {
return actions.enable();
}));
window.xprops.onClick = mockAsyncProp(expect('onClick', () => ZalgoPromise.resolve()));
window.xprops.createOrder = mockAsyncProp(expect('createOrder', () => ZalgoPromise.delay(50).then(() => orderID)));
window.xprops.onApprove = mockAsyncProp(expect('onApprove', () => ZalgoPromise.resolve()));
createButtonHTML();
await mockSetupButton({ merchantID: [ 'XYZ12345' ], fundingEligibility: DEFAULT_FUNDING_ELIGIBILITY });
await clickButton(FUNDING.PAYPAL);
});
});
return ZalgoPromise.try(() => {
return {
win,
fundingSource: FUNDING.PAYPAL
};
});
}));
return await wrapPromise(async ({ expect }) => {
const fundingSource = FUNDING.PAYPAL;
let clientConfigCalled = false;
const gqlMock = getGraphQLApiMock({
handler: expect('clientConfigCall', ({ data }) => {
if (!data.query.includes('mutation UpdateClientConfig')) {
return {};
}
if (data.variables.fundingSource !== fundingSource) {
throw new Error(`Expected fundingSource to be ${ fundingSource }, got ${ data.variables.fundingSource }`);
}
clientConfigCalled = true;
return {};
})
shape = DEFAULT_STYLE.SHAPE,
tagline = (layout === BUTTON_LAYOUT.HORIZONTAL),
height,
period
} = style;
if (values(BUTTON_LAYOUT).indexOf(layout) === -1) {
throw new Error(`Invalid layout: ${ layout }`);
}
if (label && values(BUTTON_LABEL).indexOf(label) === -1) {
throw new Error(`Invalid label: ${ label }`);
}
const FUNDING_CONFIG = getFundingConfig();
const fundingConfig = FUNDING_CONFIG[FUNDING.PAYPAL];
if (!fundingConfig) {
throw new Error(`Expected ${ FUNDING.PAYPAL } to be eligible`);
}
if (color && fundingConfig.colors.indexOf(color) === -1) {
throw new Error(`Unexpected style.color for ${ FUNDING.PAYPAL } button: ${ color }, expected ${ fundingConfig.colors.join(', ') }`);
}
if (shape && fundingConfig.shapes.indexOf(shape) === -1) {
throw new Error(`Unexpected style.shape for ${ FUNDING.PAYPAL } button: ${ shape }, expected ${ fundingConfig.shapes.join(', ') }`);
}
if (height !== undefined) {
if (typeof height !== 'number') {
throw new TypeError(`Expected style.height to be a number, got: ${ height }`);
import { getSofortConfig } from './sofort';
import { getEpsConfig } from './eps';
import { getMybankConfig } from './mybank';
import { getP24Config } from './p24';
import { getZimplerConfig } from './zimpler';
import { getWechatpayConfig } from './wechatpay';
import { getPayuConfig } from './payu';
import { getVerkkopankkiConfig } from './verkkopankki';
import { getBlikConfig } from './blik';
import { getTrustlyConfig } from './trustly';
import { getOxxoConfig } from './oxxo';
import { getBoletoConfig } from './boleto';
import { getMaximaConfig } from './maxima';
export const FUNDING_PRIORITY = [
FUNDING.PAYPAL,
FUNDING.VENMO,
FUNDING.ITAU,
FUNDING.CREDIT,
FUNDING.IDEAL,
FUNDING.SEPA,
FUNDING.BANCONTACT,
FUNDING.GIROPAY,
FUNDING.EPS,
FUNDING.SOFORT,
FUNDING.MYBANK,
FUNDING.BLIK,
FUNDING.P24,
FUNDING.ZIMPLER,
FUNDING.WECHATPAY,
FUNDING.PAYU,
FUNDING.VERKKOPANKKI,