A lazy-loader utility for the Adyen Web SDK checkout script. Reuse when integrating Adyen payment methods in React applications.
// Source: https://github.com/juspay/hyperswitch-prism | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
* Lazy-load the Adyen Web SDK script.
* Returns the global `AdyenCheckout` constructor.
*/
export function loadAdyenScript(
environment: "test" | "live" = "test"
): Promise<any> {
const src =
environment === "live"
? "https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/5.53.0/adyen.js"
: "https://checkoutshopper-test.adyen.com/checkoutshopper/sdk/5.53.0/adyen.js";
return new Promise((resolve, reject) => {
const existing = document.querySelector<HTMLScriptElement>(
`script[src="${src}"]`
);
if (existing) {
// Already loa
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key