New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

paypal-checkout

Package Overview
Dependencies
Maintainers
1
Versions
293
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paypal-checkout - npm Package Compare versions

Comparing version 4.0.33 to 4.0.34

demo/angular.htm

2

gulpfile.babel.js

@@ -40,3 +40,3 @@ import gulp from 'gulp';

gulp.task('lint', function() {
return gulp.src([ 'src/**/*.js', 'test/**/*.js' ]).pipe(eslint())
return gulp.src([ 'src/**/*.js', 'test/{tests,windows}/**/*.js' ]).pipe(eslint())
.pipe(eslint.format())

@@ -43,0 +43,0 @@ .pipe(eslint.failAfterError());

@@ -20,2 +20,6 @@ var argv = require('yargs').argv;

files: [
'test/lib/react_v15.1.0.js',
'test/lib/react-dom_v15.1.0.js',
'test/lib/angular.min.js',
{ pattern: 'test/test.js', included: true, served: true },

@@ -22,0 +26,0 @@ { pattern: 'test/**/*', included: false, served: true }

{
"name": "paypal-checkout",
"version": "4.0.33",
"version": "4.0.34",
"description": "Checkout components, for integratng checkout products.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,2 +10,3 @@

import { validateProps, urlWillRedirectPage } from '../common';
import { enableCheckoutIframe } from '../checkout';

@@ -138,3 +139,11 @@ import componentTemplate from './componentTemplate.htm';

return original.call(this, data, { ...actions, redirect });
let restart = () => {
if (actions.restart) {
enableCheckoutIframe();
return actions.restart();
}
};
return original.call(this, data, { ...actions, redirect, restart });
};

@@ -256,1 +265,20 @@ }

});
if (Button.isChild() && window.xprops.onAuthorize) {
window.xchild.onProps(() => {
let onAuthorize = window.xprops.onAuthorize;
window.xprops.onAuthorize = (data, actions) => {
let restart = actions.restart;
if (restart) {
actions.restart = () => {
enableCheckoutIframe();
return restart();
};
}
return onAuthorize(data, actions);
};
});
}
import { config } from '../config';
export function validateProps(props) {
export function validateProps(props, required = true) {
if (!required) {
return;
}
if (props.env && !config.paypalUrls[props.env]) {

@@ -7,0 +11,0 @@ throw new Error(`Invalid env: ${props.env}`);

@@ -615,4 +615,2 @@

setupBridge(config.env);
if (options.locale) {

@@ -656,8 +654,13 @@ config.locale = normalizeLocale(options.locale);

return renderButtons(id, options).then(buttons => {
buttons.forEach(button => {
$logger.info(`listen_click_paypal_button`);
listenClick(button.container, button.button, button.click, button.condition);
});
});
return Promise.all([
setupBridge(config.env),
renderButtons(id, options).then(buttons => {
buttons.forEach(button => {
$logger.info(`listen_click_paypal_button`);
listenClick(button.container, button.button, button.click, button.condition);
});
})
]);
}

@@ -664,0 +667,0 @@

@@ -5,6 +5,14 @@

import paypal from 'src/index';
import { Checkout, Button } from 'src/index';
import xcomponent from 'xcomponent/src/index';
import postRobot from 'post-robot/src/index';
import './tests';
Checkout.props.timeout = Button.props.timeout = {
type: 'number',
required: false,
def() {
return 500;
}
};
paypal.setup({

@@ -17,3 +25,3 @@ env: 'test'

return xcomponent.destroyAll().then(() => {
return postRobot.destroyBridges();
// return postRobot.destroyBridges();
});

@@ -20,0 +28,0 @@ });

@@ -76,3 +76,33 @@

});
it('should render button, render checkout, then error out', (done) => {
return paypal.Button.render({
testAction: 'error',
payment() {
return generateECToken();
},
onError(err) {
assert.ok(err instanceof Error);
return done();
},
onAuthorize() {
return done(new Error('Expected onCancel to not be called'));
},
onCancel() {
return done(new Error('Expected onCancel to not be called'));
}
}, '#testContainer').then(button => {
button.window.paypal.Checkout.contexts.lightbox = (flow === 'lightbox');
button.window.document.querySelector('button').click();
});
});
});
}

@@ -521,2 +521,33 @@

it('should render a button into a container and click on the button, restart the payment, then complete the payment', (done) => {
let isRestarted = false;
return paypal.Button.render({
payment() {
return generateECToken();
},
onAuthorize(data, actions) {
if (isRestarted) {
return done();
}
isRestarted = true;
return actions.restart();
},
onCancel() {
return done(new Error('Expected onCancel to not be called'));
}
}, '#testContainer').then(button => {
button.window.paypal.Checkout.contexts.lightbox = (flow === 'lightbox');
button.window.document.querySelector('button').click();
});
});
if (flow === 'lightbox') {

@@ -548,4 +579,97 @@

});
it('should render checkout, popout, then redirect', () => {
let token = generateECToken();
paypal.Button.render({
testAction: 'popout',
payment() {
return token;
},
onAuthorize(data, actions) {
return actions.redirect(window);
}
}, '#testContainer').then(button => {
button.window.paypal.Checkout.contexts.lightbox = (flow === 'lightbox');
button.window.document.querySelector('button').click();
});
return onHashChange().then(urlHash => {
assert.equal(urlHash, `#return?token=${token}&PayerID=YYYYYYYYYYYYY`);
});
});
it('should render checkout, popout, then redirect and await the promise', (done) => {
let token = generateECToken();
paypal.Button.render({
testAction: 'popout',
payment() {
return token;
},
onAuthorize(data, actions) {
return actions.redirect(window).then(() => {
done();
});
},
onCancel() {
return done(new Error('Expected onCancel to not be called'));
}
}, '#testContainer').then(button => {
button.window.paypal.Checkout.contexts.lightbox = (flow === 'lightbox');
button.window.document.querySelector('button').click();
});
});
it('should render a button into a container and click on the button, restart the payment, popout, then complete the payment', (done) => {
let isRestarted = false;
return paypal.Button.render({
payment() {
return generateECToken();
},
onAuthorize(data, actions) {
if (isRestarted) {
return done();
}
isRestarted = true;
return this.updateProps({
testAction: 'popout'
}).then(() => {
return actions.restart();
});
},
onCancel() {
return done(new Error('Expected onCancel to not be called'));
}
}, '#testContainer').then(button => {
button.window.paypal.Checkout.contexts.lightbox = (flow === 'lightbox');
button.window.document.querySelector('button').click();
});
});
}
});
}

@@ -5,1 +5,2 @@

export * from './error';
export * from './drivers';

@@ -39,3 +39,29 @@

});
it('should render checkout, then error out', (done) => {
return paypal.Checkout.render({
testAction: 'error',
payment() {
return generateECToken();
},
onError(err) {
assert.ok(err instanceof Error);
return done();
},
onAuthorize() {
return done(new Error('Expected onCancel to not be called'));
},
onCancel() {
return done(new Error('Expected onCancel to not be called'));
}
});
});
});
}

@@ -474,4 +474,51 @@

});
it('should render checkout, popout, then redirect', () => {
let token = generateECToken();
paypal.Checkout.render({
testAction: 'popout',
payment() {
return token;
},
onAuthorize(data, actions) {
return actions.redirect(window);
}
});
return onHashChange().then(urlHash => {
assert.equal(urlHash, `#return?token=${token}&PayerID=YYYYYYYYYYYYY`);
});
});
it('should render checkout, popout, then redirect and await the promise', (done) => {
let token = generateECToken();
paypal.Checkout.render({
testAction: 'popout',
payment() {
return token;
},
onAuthorize(data, actions) {
return actions.redirect(window).then(() => {
done();
});
},
onCancel() {
return done(new Error('Expected onCancel to not be called'));
}
});
});
}
});
}

@@ -57,3 +57,2 @@

export const CHILD_URI = '/base/test/windows/checkout/index.htm';
export const CHILD_REDIRECT_URI = '/base/test/windows/redirect/index.htm';

@@ -60,0 +59,0 @@

import paypal from 'src/index';
import { config } from 'src/config';
import { onHashChange, uniqueID, generateECToken, CHILD_URI, CHILD_REDIRECT_URI, IE8_USER_AGENT, createElement, createTestContainer, destroyTestContainer } from '../common';
import { onHashChange, uniqueID, generateECToken, CHILD_REDIRECT_URI, IE8_USER_AGENT, createElement, createTestContainer, destroyTestContainer } from '../common';

@@ -32,3 +33,3 @@ for (let flow of [ 'popup', 'lightbox' ]) {

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -80,3 +81,3 @@

props: {
href: `${CHILD_URI}?token=${token}#${hash}`
href: `${config.checkoutUrl}&token=${token}#${hash}`
}

@@ -118,3 +119,3 @@ });

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -171,3 +172,3 @@

props: {
href: `${CHILD_URI}?token=${token}#${hash}`
href: `${config.checkoutUrl}&token=${token}#${hash}`
}

@@ -209,3 +210,3 @@ });

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -282,3 +283,3 @@

props: {
href: `${CHILD_URI}?token=${token}#${hash}`
href: `${config.checkoutUrl}&token=${token}#${hash}`
}

@@ -341,3 +342,3 @@ });

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -368,3 +369,3 @@

event.preventDefault();
paypal.checkout.startFlow(`${CHILD_URI}?token=${token}#${hash}`);
paypal.checkout.startFlow(`${config.checkoutUrl}&token=${token}#${hash}`);
});

@@ -392,3 +393,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -440,3 +441,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -489,3 +490,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -517,3 +518,3 @@

paypal.checkout.initXO();
paypal.checkout.startFlow(`${CHILD_URI}?token=${token}#${hash}`);
paypal.checkout.startFlow(`${config.checkoutUrl}&token=${token}#${hash}`);
});

@@ -541,3 +542,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -590,3 +591,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -641,3 +642,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -670,3 +671,3 @@

setTimeout(() => {
paypal.checkout.startFlow(`${CHILD_URI}?token=${token}#${hash}`);
paypal.checkout.startFlow(`${config.checkoutUrl}&token=${token}#${hash}`);
}, 200);

@@ -695,3 +696,3 @@ });

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -746,3 +747,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -799,3 +800,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -851,3 +852,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -902,3 +903,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -951,3 +952,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -1025,3 +1026,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -1028,0 +1029,0 @@

import paypal from 'src/index';
import { config } from 'src/config';
import { onHashChange, uniqueID, generateECToken, CHILD_URI, createElement, createTestContainer, destroyTestContainer } from '../common';
import { onHashChange, uniqueID, generateECToken, createElement, createTestContainer, destroyTestContainer } from '../common';

@@ -30,3 +31,3 @@ for (let flow of [ 'popup', 'lightbox' ]) {

props: {
action: CHILD_URI
action: config.checkoutUrl
},

@@ -69,3 +70,3 @@

props: {
href: `${CHILD_URI}?token=${token}#${hash}`
href: `${config.checkoutUrl}&token=${token}#${hash}`
}

@@ -97,3 +98,3 @@ });

props: {
action: CHILD_URI
action: config.checkoutUrl
},

@@ -141,3 +142,3 @@

props: {
href: `${CHILD_URI}?token=${token}#${hash}`
href: `${config.checkoutUrl}&token=${token}#${hash}`
}

@@ -170,3 +171,3 @@ });

props: {
href: `${CHILD_URI}?token=${token}#${hash}`
href: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -206,3 +207,3 @@

props: {
href: `${CHILD_URI}?token=${token}#${hash}`
href: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -209,0 +210,0 @@

import paypal from 'src/index';
import { config } from 'src/config';
import { onHashChange, uniqueID, generateECToken, CHILD_URI, CHILD_REDIRECT_URI, IE8_USER_AGENT, createElement, createTestContainer, destroyTestContainer } from '../common';
import { onHashChange, uniqueID, generateECToken, CHILD_REDIRECT_URI, IE8_USER_AGENT, createElement, createTestContainer, destroyTestContainer } from '../common';

@@ -32,3 +32,3 @@ for (let flow of [ 'popup', 'lightbox' ]) {

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -76,3 +76,3 @@

props: {
href: `${CHILD_URI}?token=${token}#${hash}`
href: `${config.checkoutUrl}&token=${token}#${hash}`
}

@@ -110,3 +110,3 @@ });

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -159,3 +159,3 @@

props: {
href: `${CHILD_URI}?token=${token}#${hash}`
href: `${config.checkoutUrl}&token=${token}#${hash}`
}

@@ -193,3 +193,3 @@ });

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -216,3 +216,3 @@

event.preventDefault();
paypal.checkout.startFlow(`${CHILD_URI}?token=${token}#${hash}`);
paypal.checkout.startFlow(`${config.checkoutUrl}&token=${token}#${hash}`);
});

@@ -240,3 +240,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -284,3 +284,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -329,3 +329,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -353,3 +353,3 @@

paypal.checkout.initXO();
paypal.checkout.startFlow(`${CHILD_URI}?token=${token}#${hash}`);
paypal.checkout.startFlow(`${config.checkoutUrl}&token=${token}#${hash}`);
});

@@ -377,3 +377,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -422,3 +422,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -469,3 +469,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -494,3 +494,3 @@

setTimeout(() => {
paypal.checkout.startFlow(`${CHILD_URI}?token=${token}#${hash}`);
paypal.checkout.startFlow(`${config.checkoutUrl}&token=${token}#${hash}`);
}, 200);

@@ -519,3 +519,3 @@ });

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -566,3 +566,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -615,3 +615,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -663,3 +663,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -732,3 +732,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -779,3 +779,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -824,3 +824,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -891,3 +891,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -961,3 +961,3 @@

props: {
action: `${CHILD_URI}?token=${token}#${hash}`
action: `${config.checkoutUrl}&token=${token}#${hash}`
},

@@ -964,0 +964,0 @@

@@ -5,3 +5,3 @@

import { onHashChange, uniqueID, generateECToken, CHILD_URI, CHILD_REDIRECT_URI, IE8_USER_AGENT, createTestContainer, destroyTestContainer } from '../common';
import { onHashChange, uniqueID, generateECToken, CHILD_REDIRECT_URI, IE8_USER_AGENT, createTestContainer, destroyTestContainer } from '../common';

@@ -84,3 +84,3 @@ for (let flow of [ 'popup', 'lightbox' ]) {

click(event) {
paypal.checkout.startFlow(`${CHILD_URI}?token=${token}#${hash}`);
paypal.checkout.startFlow(`${config.checkoutUrl}&token=${token}#${hash}`);
}

@@ -109,3 +109,3 @@

click(event) {
paypal.checkout.startFlow(`${CHILD_URI}?token=${token}#${hash}`);
paypal.checkout.startFlow(`${config.checkoutUrl}&token=${token}#${hash}`);
}

@@ -134,3 +134,3 @@

click(event) {
paypal.checkout.startFlow(`${CHILD_URI}?token=${token}#${hash}`);
paypal.checkout.startFlow(`${config.checkoutUrl}&token=${token}#${hash}`);
}

@@ -162,3 +162,3 @@

click(event) {
paypal.checkout.startFlow(`${CHILD_URI}?token=${token}#${hash}`);
paypal.checkout.startFlow(`${config.checkoutUrl}&token=${token}#${hash}`);
}

@@ -391,3 +391,3 @@

setTimeout(() => {
paypal.checkout.startFlow(`${CHILD_URI}?token=${token}#${hash}`);
paypal.checkout.startFlow(`${config.checkoutUrl}&token=${token}#${hash}`);
}, 100);

@@ -394,0 +394,0 @@ }

import paypal from 'src/index';
import { config } from 'src/config';
import { onHashChange, uniqueID, generateECToken, CHILD_URI, CHILD_REDIRECT_URI, createElement,
import { onHashChange, uniqueID, generateECToken, CHILD_REDIRECT_URI, createElement,
createTestContainer, destroyTestContainer } from '../common';

@@ -46,3 +47,3 @@

testButton.addEventListener('click', event => {
paypal.checkout.startFlow(`${CHILD_URI}?token=${token}#${hash}`);
paypal.checkout.startFlow(`${config.checkoutUrl}&token=${token}#${hash}`);
});

@@ -104,3 +105,3 @@

paypal.checkout.startFlow(`${CHILD_URI}?token=${token}#${hash}`);
paypal.checkout.startFlow(`${config.checkoutUrl}&token=${token}#${hash}`);
}, 100);

@@ -107,0 +108,0 @@ });

@@ -13,4 +13,3 @@

document.querySelector('#button').addEventListener('click', event => {
function renderCheckout() {
paypal.Checkout.renderTo(window.parent, {

@@ -37,5 +36,14 @@

}
},
restart() {
renderCheckout();
}
});
},
onAuth() {
// pass
},
onCancel: window.xprops.onCancel,

@@ -46,2 +54,6 @@ commit: window.xprops.commit,

});
}
document.querySelector('#button').addEventListener('click', event => {
renderCheckout();
});

@@ -48,0 +60,0 @@

@@ -11,9 +11,18 @@

let hash = window.location.hash ? `&hash=${window.location.hash.slice(1)}` : '';
return paypal.Promise.try(() => {
window.xprops.onAuthorize({
paymentToken,
cancelUrl: `#cancel?token=${paymentToken}${ hash }`,
returnUrl: `#return?token=${paymentToken}&PayerID=YYYYYYYYYYYYY${ hash }`,
currentUrl: window.location.href
if (window.xprops.onAuth) {
return window.xprops.onAuth('xxxyyy');
}
}).then(() => {
let hash = window.location.hash ? `&hash=${window.location.hash.slice(1)}` : '';
window.xprops.onAuthorize({
paymentToken,
cancelUrl: `#cancel?token=${paymentToken}${ hash }`,
returnUrl: `#return?token=${paymentToken}&PayerID=YYYYYYYYYYYYY${ hash }`,
currentUrl: window.location.href
});
});

@@ -38,3 +47,3 @@ });

paypal.Checkout.renderPopupTo(window.parent, {
paypal.Checkout.renderPopupTo(window.xchild.getParentComponentWindow(), {

@@ -47,3 +56,2 @@ url: window.location.href,

onError: window.xprops.onError
});

@@ -78,4 +86,8 @@

});
} else if (window.xprops.testAction === 'error') {
window.xprops.onError(new Error('something went wrong'));
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc