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 { ENV, FUNDING, CARD } from '@paypal/sdk-constants';
import { FNCLS, FRAUDNET_ID } from '../config';
import type { FundingEligibility } from './fundingEligibility';
const FRAUDNET_URL = {
[ ENV.LOCAL ]: 'https://www.msmaster.qa.paypal.com/en_US/m/fb-raw.js',
[ ENV.STAGE ]: 'https://www.msmaster.qa.paypal.com/en_US/m/fb-raw.js',
[ ENV.SANDBOX ]: 'https://c.paypal.com/da/r/fb.js',
[ ENV.PRODUCTION ]: 'https://c.paypal.com/da/r/fb.js',
[ ENV.TEST ]: 'https://c.paypal.com/da/r/fb.js'
};
export function shouldRenderFraudnet({ fundingEligibility } : { fundingEligibility : FundingEligibility }) : boolean {
for (const fundingSource of Object.values(FUNDING)) {
// $FlowFixMe
const fundingConfig = fundingEligibility[fundingSource];
if (fundingConfig && fundingConfig.vaultedInstruments && fundingConfig.vaultedInstruments.length) {
return true;
}
if (fundingSource === FUNDING.CARD && fundingConfig && fundingConfig.vendors) {
export async function compileLocalSmartButtonRenderScript() : Promise<{ button : Object, version : string }> {
const dir = process.env.BUTTON_RENDER_DIR;
if (!dir) {
throw new Error(`Can not find directory to render smart buttons script`);
}
const button = requireScript(await compileWebpack(join(dir, WEBPACK_CONFIG), 'WEBPACK_CONFIG_BUTTON_RENDER'));
return { button, version: ENV.LOCAL };
}
export async function compileLocalSmartPaymentButtonRenderScript(dir : string) : Promise<{ button : Object, version : string }> {
const { WEBPACK_CONFIG_BUTTON_RENDER } = babelRequire(join(dir, WEBPACK_CONFIG));
const button = evalRequireScript(await compileWebpack(WEBPACK_CONFIG_BUTTON_RENDER, dir));
return { button, version: ENV.LOCAL };
}
import { testGlobals } from './test/globals';
import globals from './globals';
const FILE_NAME = 'sdk';
const PROTOCOL = 'https';
const HOSTNAME = 'localhost.paypal.com';
const PORT = 9000;
const WEBPACK_CONFIG_DEV = getWebpackConfig({
entry: './paypal.dev.js',
filename: `${ FILE_NAME }.js`,
debug: true,
minify: false,
env: ENV.LOCAL,
vars: {
...globals,
...testGlobals,
__PROTOCOL__: PROTOCOL,
__HOST__: `${ HOSTNAME }:${ PORT }`,
__SDK_HOST__: `${ HOSTNAME }:${ PORT }`,
__PORT__: PORT,
__PATH__: `/${ FILE_NAME }.js`,
__PAYPAL_CHECKOUT__: {
...testGlobals.__PAYPAL_CHECKOUT__,
__URI__: {
__CHECKOUT__: `/demo/dev/checkout.htm`,
__BUTTONS__: `/demo/dev/button.htm`,
__MENU__: `/demo/dev/menu.htm`
}
},
export async function compileLocalSmartMenuClientScript() : Promise<{ script : string, version : string }> {
const root = join(__dirname, '../../..');
const { WEBPACK_CONFIG_MENU_DEBUG } = babelRequire(join(root, WEBPACK_CONFIG));
const script = await compileWebpack(WEBPACK_CONFIG_MENU_DEBUG, root);
return { script, version: ENV.LOCAL };
}