Adyen Script Loader Utility (adyen/utils.ts)

hyperswitch-prism · plugins/medusa/medusa-custom-payments-react/src/connectors/adyen/utils.ts · typescript · Apache-2.0
integration, payments, lang:typescript, tag:loader

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