Klarna Web SDK v2
    Preparing search index...

    Interface KlarnaConfig

    Config package. Runtime configuration for integration metadata and session.

    interface KlarnaConfig {
        IntegrationMetadata: IntegrationMetadata;
        setAcquiringConfig(acquiringConfig: AcquiringConfig): Promise<void>;
        setEnablementCodes(enablementCodes: string[]): Promise<void>;
        setKlarnaNetworkSessionToken(
            klarnaNetworkSessionToken: string,
        ): Promise<void>;
        setPartnerAccountId(partnerAccountId: string): Promise<void>;
        setSdkToken(sdkToken: string): Promise<void>;
    }
    Index
    IntegrationMetadata: IntegrationMetadata

    Interface for managing integration metadata dynamically.

    • Parameters

      • acquiringConfig: AcquiringConfig

        The acquiring configuration for payment account.

      Returns Promise<void>

      "Enables integrators to dynamically specify the acquiring configuration at runtime.

      Identify the Payment Account with either paymentAccountId, or paymentAcquiringAccountId and paymentAccountReference. If you pass both, the SDK uses paymentAccountId.

      Each call replaces the whole acquiring configuration. The SDK clears fields you leave out; it does not keep them from the configuration passed at initialization or in an earlier call."

      label="Example"

      await klarna.Config.setAcquiringConfig({
      paymentAccountId: "payment-account-123",
      });
      await klarna.Config.setAcquiringConfig({
      paymentAcquiringAccountId: "acq-account-123",
      paymentAccountReference: "partner-ref-456",
      });

      Config

      Config.setAcquiringConfig

      Config

      general-availability

      Config.setAcquiringConfig

      true

      true

    • Parameters

      • enablementCodes: string[]

        Up to 20 enablement codes to use for subsequent operations.

      Returns Promise<void>

      "Enables integrators to change the enablement codes for the SDK instance at runtime. The codes replace those set at initialization and apply to every presentation, placement and payment that doesn't set its own. An empty array clears them.

      Call this when a campaign starts after the SDK has loaded."

      label="Example"

      await klarna.Config.setEnablementCodes(["autumn-campaign"]);
      

      Config

      Config.setEnablementCodes

      Config

      internal-future-release

      Config.setEnablementCodes

      false

      false

    • Parameters

      • klarnaNetworkSessionToken: string

        The token to resume the session.

      Returns Promise<void>

      "Sets a Klarna Network Session token to resume a previously established session. Use this when the customer navigates between pages (e.g. from cart to checkout) and you need to restore the SDK session without requiring the customer to re-authenticate. The token is typically obtained from your server after the initial payment flow or from the onComplete callback."

      label="Example"

      // Fetch the session token from your server
      const response = await fetch("/api/klarna/session-token");
      const { klarnaNetworkSessionToken } = await response.json();

      // Resume the Klarna session on the new page
      await klarna.Config.setKlarnaNetworkSessionToken(klarnaNetworkSessionToken);

      Config

      Config.setKlarnaNetworkSessionToken

      Config

      general-availability

      Config.setKlarnaNetworkSessionToken

      true

      true

    • Parameters

      • partnerAccountId: string

        The partner account ID to use for subsequent operations.

      Returns Promise<void>

      "Enables integrators to dynamically specify the Partner's account ID at runtime. This field is only used when the integrator is an Acquiring Partner or has a complex partner account setup. For direct integration or partner integration, this field can be omitted.

      Call this before initiating a payment when the partner account differs from the one used during SDK initialization."

      label="Example"

      // Switch to a specific partner account before creating a payment
      await klarna.Config.setPartnerAccountId("partner-account-456");

      Config

      Config.setPartnerAccountId

      Config

      general-availability

      Config.setPartnerAccountId

      true

      true

    • Parameters

      • sdkToken: string

        The SDK token to resume a session.

      Returns Promise<void>

      "Enables integrators to dynamically specify an SDK token that can resume a session.

      Migration: Replace calls to setSdkToken with {@docs-portal-link Config.setKlarnaNetworkSessionToken}. The token value is the same — only the method name has changed."

      label="Example"

      // Deprecated — migrate to setKlarnaNetworkSessionToken
      await klarna.Config.setSdkToken("eyJhbGciOi...");

      // New equivalent
      await klarna.Config.setKlarnaNetworkSessionToken("eyJhbGciOi...");

      use {@docs-portal-link Config.setKlarnaNetworkSessionToken} instead. This property will be removed in future versions.

      Config

      Config.setSdkToken

      Config

      deprecated

      Config.setSdkToken

      true

      true