Skip to main content
WeGive Pay does not require an npm package. This guide uses SDK 0.1.0. Keep the version in the URL so a release does not silently change your installed JavaScript. Test and live credentials use the same SDK file.

Option 1: Add a script tag

Load the browser bundle before your integration code:
The script exposes window.WeGive.Pay. The integrity value pins the file’s contents as well as its URL. Change both together when upgrading. Do not add async unless your application explicitly waits for the SDK to load before calling it. If your site forbids inline scripts, put initialization in an allowed external script or use your site’s nonce-based script policy.

Option 2: Import the ES module from its URL

Use this in browsers that support ES modules. The module loads companion code when needed for Payframes. A bundler may require local files instead of HTTPS module imports; use the next option in that case.

Option 3: Download and vendor a release

For a script-tag integration, download wegive-pay.iife.js, verify its checksum, and serve it from your application’s static assets. Keep the version in your local path, for example /vendor/wegive-pay/v0.1.0/wegive-pay.iife.js. For an ES module or bundled integration, download every runtime .js file listed in release.json, preserving their filenames and relative paths. Download the .d.ts files too if you use TypeScript. Downloading only wegive-pay.js leaves out the Payframes companion module. This Node.js script downloads and verifies the runtime files and type declarations into a local vendor directory. Save it as download-wegive-pay.mjs and run node download-wegive-pay.mjs:
Import the local module from your client-side application code, adjusting the relative path to your project:
For TypeScript, the release’s index.d.ts exports the public declarations. You can import types from that file while importing runtime code from wegive-pay.js:
If your compiler requires a declaration beside the JavaScript entry, add a local wegive-pay.d.ts adapter that re-exports the release’s declarations:
Vendoring the SDK hosts the browser library on your domain. Checkout, tokenization, and processing still use WeGive’s hosted services; the SDK is not an offline payment processor.

Available release files

Frameworks and browser policies

Initialize the SDK in browser code after the mount elements exist. In applications with server rendering, use a client component or browser-only lifecycle hook. Create one instance per active key configuration; do not reinitialize on every render. Mount once and clean up on route or component removal using button.unmount() or fields.destroy(). Allow the SDK origin in your content security policy, along with the WeGive API, secure-field, and verification resources required by your enabled integration. Tokenization loads third-party frames and scripts in addition to the SDK file; ask WeGive for the applicable allowlist if your site uses a restrictive policy. Do not disable verification scripts or use a policy that severs the checkout window’s connection to its opener. Test browser isolation policies with your actual integration. Continue with hosted checkout or Payframes.