PageSourceSearch

https://www.trafficsafetystore.com/js/Checkout/confirm-cart-shared.js

js trafficsafetystore.com collected 2026-09-24 22:01:38 UTC 3,107 bytes, 81 lines download raw bytes

1//Contains js functions shared between the confirm page and cart pages
2//should be loaded before any checkout JS files
3function paymentNonceIsValid(payload) {
4    if (typeof payload === 'undefined' || payload === null || typeof payload.nonce === "undefined") {
5        console.log("The payload object is undefined");
6        return false;
7    }
8
9    if (payload.nonce == null || payload.nonce === "") {
10        console.log("Could not get a valid non empty nonce from payload");
11        return false;
12
13    }
14    return true;
15}
16
17
18
19function tokenizePaypalPaymentWithRetry(paypalCheckoutInstance, data, callback, attemptsLeft, delay) {
20    return paypalCheckoutInstance.tokenizePayment(data)
21        .then(function (payload) {
22            if (paymentNonceIsValid(payload)) {
23                $("#paymentNonce").val(payload.nonce);
24                callback();
25            } else {
26                if (attemptsLeft > 0) {
27                    console.log("Invalid Payment nonce, will retry" + attemptsLeft + "time(s)");
28
29                    setTimeout(function () {
30                        return tokenizePaypalPaymentWithRetry(paypalCheckoutInstance, data,callback, attemptsLeft - 1, delay);
31                    }, delay);
32                }
33                $("#paymentNonce").val("");
34                callback();
35            }
36        });
37}
38
39function tokenizePaypalPaymentFromCartWithRetry(paypalCheckoutInstance, data, paymentMethod, attemptsLeft, delay) {
40    return paypalCheckoutInstance.tokenizePayment(data)
41        .then(function(payload) {
42            if (paymentNonceIsValid(payload)) {
43                SetPaymentMethodAndProceedToCart(paymentMethod, payload);
44            } else {
45                if (attemptsLeft > 0) {
46                    console.log("Invalid Payment nonce, will retry " + attemptsLeft + " time(s)");
47                    setTimeout(function () {
48                        return tokenizePaypalPaymentFromCartWithRetry(paypalCheckoutInstance, data, paymentMethod, attemptsLeft - 1,delay);
49                    }, delay);
50                }
51                payload.nonce = "";
52                SetPaymentMethodAndProceedToCart(paymentMethod, payload);
53            }
54        });
55}
56
57function clearShippingSessionData() {
58    try {
59        sessionStorage.removeItem('Zip');
60        sessionStorage.removeItem('State');
61        sessionStorage.removeItem('state');
62        sessionStorage.removeItem('City');
63        sessionStorage.removeItem('StateAbbrev');
64        sessionStorage.removeItem('Address1');
65        sessionStorage.removeItem('cartState');
66    } catch (e) {
67        console.error('Failed to clear shipping session data:', e);
68    }
69}
70function SetPaymentMethodAndProceedToCart(paymentMethod, payload) {
71    var payloadJson = null;
72    if (payload ) {
73        payloadJson = JSON.stringify(payload);
74    }
75
76    // clear stale session data so confirm page doesn't use old zip/state
77    clearShippingSessionData();
78    sessionStorage.setItem('paymentMethod', paymentMethod);
79    sessionStorage.setItem('payloadFromCart', payloadJson);
80    $(location).attr('href', "/checkout/confirm");
81}

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.