A set of components allowing easy integration of PayPal Buttons and PayPal Checkout into your site, powered by zoid.
See developer.paypal.com/docs/checkout
Please submit any issues about the JS SDK here: https://github.com/paypal/paypal-js/issues
Please feel free to follow the Contribution Guidelines to contribute to this repository. PRs are welcome, but for major changes please raise an issue first.
Set up your env:
npm installRun tests:
npm testRun in dev mode:
npm run devnpm testRuns all testing tasks lint, flow, karma, jest-ssr, jest-screenshot, & check-size.
| Flags | Description |
|---|---|
| --clear-cache | Clear Babel Loader and PhantomJS cache |
| --debug | Debug mode. PhantomJS, Karma, and CheckoutJS |
| --quick | Fastest testing. Minimal output, no coverage |
| --browser | Choose Browser |
npm run lint
npm run lint -- --fix
# attempt to automatically fix any problemsRuns eslint using definitions extended from Grumbler-Scripts.
npm run flow
Checks for typing issues using Flow. Prior to running this task, flow-typed should be run to generate type interfaces for the various 3rd-party libraries we use.
npm run karma
npm run karma -- --keep-open
# keeps the test browser window open to allow debugging
npm run karma -- --capture-console
# dumps the browser's console output into the terminalRuns Karma tests using the Mocha framework. Responsible for running the test/e2e & test/integration directories.
npm run jest-ssrChecks for the correct rendering of components on the server-side using Jest.
npm run jest-screenshotUses Puppeteer & Jest to take screenshots and checks against existing views to look for discrepancies. Tests are defined in test/screenshot/config.js.
npm run check-sizeChecks to make sure that the compiled & gzipped bundle doesn't exceed the recommended size limit.
This package is published weekly, Every Wednesday. Please view our Changelog to stay updated with bug fixes and new features.
Our usage of svg logos is optimized for performance. Here's how it works for the two-phased render for the Buttons component:
-
First Render - Buttons are first rendered on the client-side inside an
<iframe>tag using the code bundled inside the JS SDK script. This<iframe>tag has no src attribute at this point in the rendering life cycle. We leverage the__WEB__global variable to determine if we are rendering client-side or server-side. The__WEB__global variable will equal true when rendering client-side. To minimize the bundle size of the JS SDK script, we load these svg logos from the www.paypalobjects.com CDN as external images (ex:<PayPalLogoExternalImage />). -
Second Render - The second phase of rendering happens on the server-side. This
<iframe>tag is fully rendered by setting the src attribute and making an http request to the server to populate the contents which are securely hosted by PayPal's servers on www.paypal.com. The same code in this repo is used to render the buttons on the server-side. To ensure there are no issues with the logos, we have decided to inline the svg code for this server-side render (ex:<PayPalLogoInlineSVG />). The__WEB__global variable is set to false to control what code executes during the server render.