PageSourceSearch

https://www.verdilabcosmetics.com/wp-content/plugins/klarna-paymen…klarna-interoperability-token.js?ver=4.10.2

js verdilabcosmetics.com collected 2026-10-09 02:58:18 UTC 3,332 bytes, 111 lines download raw bytes

1"use strict"
2const { KlarnaSDK } = await import("@klarna/websdk_v2");
3const $ = jQuery;
4let configData = {};
5
6const params = document.getElementById(
7	'wp-script-module-data-@klarna/interoperability_token'
8);
9
10if (params?.textContent) {
11	try { configData = JSON.parse(params.textContent); } catch { }
12}
13
14const kp_interoperability_token = {
15	params: null,
16	Klarna: null,
17
18	init: async function () {
19		this.params = configData;
20		this.updateGlobalToken( this.params.token )
21		this.updateGlobalData( this.params.data )
22		this.Klarna = await KlarnaSDK({
23			clientId: this.params.client_id
24		});
25		this.bindKlarnaEvents();
26
27		// Set the klarna object to the window for other scripts to use as well.
28		$('body').trigger({ type: 'klarna_wc_sdk_loaded', Klarna: kp_interoperability_token.Klarna });
29
30		// Check if we should send shopping data to Klarna.
31		if ( true === kp_interoperability_token.params.send_data ) {
32			// Update the session data when cart or checkout is updated.
33			$( document.body ).on( "updated_cart_totals added_to_cart removed_from_cart updated_checkout wc-blocks_added_to_cart wc-blocks_removed_from_cart", kp_interoperability_token.updateSessionData );
34		}
35	},
36
37	bindKlarnaEvents: async function () {
38		kp_interoperability_token.Klarna.Interoperability.on( "tokenupdate", kp_interoperability_token.updateSessionToken )
39
40		// If we did not get a token from Klarna yet, trigger the token request.
41		if ( undefined === window.klarna_interoperability_token ) {
42			const result = await kp_interoperability_token.Klarna.Interoperability.token()
43			kp_interoperability_token.updateSessionToken( { interoperabilityToken: result } )
44		}
45	},
46
47	updateGlobalToken: function ( token ) {
48		// If the token is not set, return.
49		if ( ! token || token === "" ) {
50			return
51		}
52
53		window.klarna_interoperability_token = token
54	},
55
56	updateGlobalData: async function ( data ) {
57		// If the data is not set, return.
58		if ( ! data || data === "" ) {
59			return
60		}
61
62		window.klarna_interoperability_data = data
63	},
64
65	updateSessionToken: async function ( token ) {
66		const interoperabilityToken = token.interoperabilityToken
67		const { token_url, token_nonce } = kp_interoperability_token.params.ajax
68		await $.ajax( {
69			url: token_url,
70			type: "POST",
71			data: {
72				token: interoperabilityToken,
73				nonce: token_nonce,
74			},
75			async: true,
76			success: function ( response ) {
77				kp_interoperability_token.updateGlobalToken( interoperabilityToken )
78				// Check if we should send shopping data to Klarna.
79				if ( true === kp_interoperability_token.params.send_data ) {
80					kp_interoperability_token.updateSessionData()
81				}
82			},
83			error: function ( error ) {
84				console.error( "Error updating Interoperability Token:", error )
85			},
86		} )
87	},
88
89	updateSessionData: async function () {
90		const { data_url, data_nonce } = kp_interoperability_token.params.ajax
91		await $.ajax( {
92			url: data_url,
93			type: "POST",
94			data: {
95				nonce: data_nonce,
96			},
97			async: true,
98			success: function ( response ) {
99				const updatedData = response.data
100				kp_interoperability_token.updateGlobalData( updatedData )
101
102			},
103			error: function ( error ) {
104				console.error( "Error updating Interoperability data:", error )
105			},
106		} )
107	},
108}
109
110kp_interoperability_token.init();
111export const klarna_interoperability = kp_interoperability_token;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.