Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* @flow */
import { FUNDING } from '@paypal/sdk-constants/src';
import { CLASS, ATTRIBUTE } from '../../../constants';
export const labelStyle = `
.${ CLASS.BUTTON }[${ ATTRIBUTE.FUNDING_SOURCE }=${ FUNDING.CARD }]:not(.${ CLASS.VAULT }) {
border-radius: 0 !important;
}
.${ CLASS.BUTTON } .${ CLASS.VAULT_LABEL } {
max-width: 60%;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
`;
clientConfigCalled = true;
return {};
})
}).expectCalls();
window.xprops.onApprove = mockAsyncProp(expect('onApprove', async () => {
gqlMock.done();
if (!clientConfigCalled) {
throw new Error(`Expected clientConfig mutation to be called`);
}
}));
const fundingEligibility = {
[ FUNDING.CARD ]: {
eligible: true,
vendors: {
[ CARD.VISA ]: {
eligible: true
}
}
}
};
createButtonHTML(fundingEligibility);
await mockSetupButton({ merchantID: [ 'XYZ12345' ], fundingEligibility });
await clickButton(FUNDING.CARD, CARD.VISA);
});
});
return inlineMemoize(getFundingConfig, () => {
return {
[ FUNDING.PAYPAL ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.paypal && __paypal_checkout__.serverConfig.fundingEligibility.paypal.eligible)) ? getPayPalConfig() : null,
[ FUNDING.VENMO ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.venmo && __paypal_checkout__.serverConfig.fundingEligibility.venmo.eligible)) ? getVenmoConfig() : null,
[ FUNDING.ITAU ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.itau && __paypal_checkout__.serverConfig.fundingEligibility.itau.eligible)) ? getItauConfig() : null,
[ FUNDING.CREDIT ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.credit && __paypal_checkout__.serverConfig.fundingEligibility.credit.eligible)) ? getCreditConfig() : null,
[ FUNDING.CARD ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.card && __paypal_checkout__.serverConfig.fundingEligibility.card.eligible)) ? getCardConfig() : null,
[ FUNDING.IDEAL ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.ideal && __paypal_checkout__.serverConfig.fundingEligibility.ideal.eligible)) ? getIdealConfig() : null,
[ FUNDING.SEPA ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.sepa && __paypal_checkout__.serverConfig.fundingEligibility.sepa.eligible)) ? getSepaConfig() : null,
[ FUNDING.BANCONTACT ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.bancontact && __paypal_checkout__.serverConfig.fundingEligibility.bancontact.eligible)) ? getBancontactConfig() : null,
[ FUNDING.GIROPAY ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.giropay && __paypal_checkout__.serverConfig.fundingEligibility.giropay.eligible)) ? getGiropayConfig() : null,
[ FUNDING.SOFORT ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.sofort && __paypal_checkout__.serverConfig.fundingEligibility.sofort.eligible)) ? getSofortConfig() : null,
[ FUNDING.EPS ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.eps && __paypal_checkout__.serverConfig.fundingEligibility.eps.eligible)) ? getEpsConfig() : null,
[ FUNDING.MYBANK ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.mybank && __paypal_checkout__.serverConfig.fundingEligibility.mybank.eligible)) ? getMybankConfig() : null,
[ FUNDING.P24 ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.p24 && __paypal_checkout__.serverConfig.fundingEligibility.p24.eligible)) ? getP24Config() : null,
[ FUNDING.PAYU ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.payu && __paypal_checkout__.serverConfig.fundingEligibility.payu.eligible)) ? getPayuConfig() : null,
[ FUNDING.VERKKOPANKKI ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.verkkopankki && __paypal_checkout__.serverConfig.fundingEligibility.verkkopankki.eligible)) ? getVerkkopankkiConfig() : null,
[ FUNDING.BLIK ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.blik && __paypal_checkout__.serverConfig.fundingEligibility.blik.eligible)) ? getBlikConfig() : null,
[ FUNDING.TRUSTLY ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.truslty && __paypal_checkout__.serverConfig.fundingEligibility.trustly.eligible)) ? getTrustlyConfig() : null,
[ FUNDING.ZIMPLER ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.zimpler && __paypal_checkout__.serverConfig.fundingEligibility.zimpler.eligible)) ? getZimplerConfig() : null,
[ FUNDING.WECHATPAY ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.wechatpay && __paypal_checkout__.serverConfig.fundingEligibility.wechatpay.eligible)) ? getWechatpayConfig() : null,
[ FUNDING.OXXO ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.oxxo && __paypal_checkout__.serverConfig.fundingEligibility.oxxo.eligible)) ? getOxxoConfig() : null,
[ FUNDING.BOLETO ]: (!__TREE_SHAKE__ || (__paypal_checkout__.serverConfig.fundingEligibility.boleto && __paypal_checkout__.serverConfig.fundingEligibility.boleto.eligible)) ? getBoletoConfig() : null,
min-height: ${ height || style.minHeight }px;
max-height: ${ height || style.maxHeight }px;
}
.${ CLASS.BUTTON } .${ CLASS.SPINNER } {
height: ${ perc(buttonHeight, 50) }px;
width: ${ perc(buttonHeight, 50) }px;
}
.${ CLASS.BUTTON } > .${ CLASS.BUTTON_LABEL } {
height: ${ perc(buttonHeight, 35) + 5 }px;
max-height: ${ perc(buttonHeight, 60) }px;
min-height: ${ perc(buttonHeight, 40) }px;
}
.${ CLASS.BUTTON }[${ ATTRIBUTE.FUNDING_SOURCE }=${ FUNDING.CARD }]:not([${ ATTRIBUTE.PAYMENT_METHOD_ID }]) .${ CLASS.BUTTON_LABEL } {
height: 100%;
min-height: 100%;
max-height: 100%;
}
.${ CLASS.BUTTON }[${ ATTRIBUTE.FUNDING_SOURCE }=${ FUNDING.EPS }] .${ CLASS.BUTTON_LABEL },
.${ CLASS.BUTTON }[${ ATTRIBUTE.FUNDING_SOURCE }=${ FUNDING.MYBANK }] .${ CLASS.BUTTON_LABEL } {
height: ${ perc(buttonHeight, 50) + 5 }px;
max-height: ${ perc(buttonHeight, 70) }px;
min-height: ${ perc(buttonHeight, 40) }px;
}
.${ CLASS.BUTTON }.${ CLASS.SHAPE }-${ BUTTON_SHAPE.RECT } {
border-radius: 4px;
}
const vendorConfig = vendors[name];
if (!vendorConfig) {
return null;
}
const { Label } = vendorConfig;
return (
<div name="" class="{"> onClick(event, { card: name }) }
tabindex='0'
role='button'
{ ...{
[ ATTRIBUTE.FUNDING_SOURCE ]: FUNDING.CARD,
[ ATTRIBUTE.CARD ]: name
} }
>
<label>
</label></div>
);
}).filter(Boolean).slice(0, maxCards);
},
}).filter(source => {
return source && source !== FUNDING.CARD;
});
const getElements = () : { buttonsContainer : HTMLElement, cardButtonsContainer : HTMLElement, cardFieldsContainer : HTMLElement } => {
const buttonsContainer = document.querySelector('#buttons-container');
const cardButtonsContainer = document.querySelector(`[${ DATA_ATTRIBUTES.FUNDING_SOURCE }="${ FUNDING.CARD }"]`);
const cardFieldsContainer = document.querySelector('#card-fields-container');
if (!buttonsContainer || !cardButtonsContainer || !cardFieldsContainer) {
throw new Error(`Did not find card fields elements`);
}
return { buttonsContainer, cardButtonsContainer, cardFieldsContainer };
};
}).filter(source => {
return source && source !== FUNDING.CARD;
});
display: none !important;
}
.${ CLASS.BUTTON }.${ CLASS.LOADING } * {
display: none !important;
}
.${ CLASS.BUTTON }.${ CLASS.LOADING } .${ CLASS.SPINNER } {
display: block !important;
}
.${ CLASS.CONTAINER } .${ CLASS.VAULT_HEADER } {
margin-top: 10px;
}
.${ CLASS.BUTTON }[${ ATTRIBUTE.FUNDING_SOURCE }=${ FUNDING.CARD }] .${ CLASS.TEXT } {
position: absolute;
visibility: hidden;
}
`;