PageSourceSearch

https://vorhus.is/wp-content/plugins/verifone-hosted/assets/js/ver…?ver=ef9b5d43888a06604c532e9818325721

js vorhus.is collected 2026-10-10 03:23:12 UTC 11,555 bytes, 289 lines download raw bytes

1(function () {
2    "use strict";
3
4    var isBlocksVerifoneJs = "undefined" !== typeof wc && "undefined" !== typeof wc.blocksComponents;
5    var publicKeyAlias;
6    var encrypted;
7    var isCardinalSetup = false;
8    var jwt;
9    var threeDsLookupData;
10    var ccaJwt;
11    var $ = jQuery.noConflict();
12    var formVerifoneJs = $('form.woocommerce-checkout, form.wc-block-checkout__form');
13
14    function verifoneJsCall() {
15        if (formVerifoneJs.length || $('form#order_review').length) {
16            $('#verifone_error').html('').hide();
17            $('#place_order').attr('disabled', true);
18
19            if (formVerifoneJs.length) {
20                if ($("#payment_method_verifone_inline_cart,#radio-control-wc-payment-method-options-verifone_inline_cart").is(':checked')) {
21                    $.ajax({
22                        type: 'GET',
23                        url: verifoneKeyUrl,
24                        success: function (response) {
25                            if ('undefined' !== typeof response.error) {
26                                $('#verifone_error').html(response.error).get(0).scrollIntoView();
27                            } else {
28                                let card = {
29                                    "cardNumber": $('[name="verifone-card-number"]', '#wc-verifone-cc-form').val(),
30                                    "expiryMonth": $('[name="verifone-card-expiry"]', '#wc-verifone-cc-form').val().split("/")[0],
31                                    "expiryYear": $('[name="verifone-card-expiry"]', '#wc-verifone-cc-form').val().split("/")[1],
32                                    "cvv": $('[name="verifone-card-cvc"]', '#wc-verifone-cc-form').val()
33                                };
34
35                                if (!card.cardNumber || !card.expiryMonth || !card.expiryYear || !card.cvv) {
36                                    $('#verifone_error').html("Enter card details").get(0).scrollIntoView();
37                                    $('#place_order').attr('disabled', false);
38                                    return;
39                                }
40
41                                verifone.encryptCard(card, response.info.public_key).then((encryptedData) => {
42                                    publicKeyAlias = response.info.public_key_alias;
43                                    encrypted = encryptedData;
44
45                                    if (verifone3DSEnabled)
46                                        verifoneTokenCreate();
47                                    else
48                                        verifoneAjaxSubmit();
49                                })
50                            }
51                        },
52                        error: function (response, data) {
53                            $('#place_order').attr('disabled', false);
54                            console.error("Error response: " + response + " && data: " + data);
55                            return false;
56                        }
57                    });
58                }
59            }
60        }
61    }
62
63    function isDomReadyForVerifoneInlineJs() {
64        if ($("#payment_method_verifone_inline_cart,#radio-control-wc-payment-method-options-verifone_inline_cart").is(':checked')) {
65            if (formVerifoneJs.length) {
66                formVerifoneJs.unbind('submit');
67                formVerifoneJs.on('submit', bindVerifoneInline);
68                moveVerifoneJsWrapper();
69            } else if ($('form#order_review').length) {
70                $("form#order_review").unbind('submit');
71                $("form#order_review").on('submit', bindVerifoneInline);
72            }
73            $("#verifone_wrapper").show();
74        } else {
75            formVerifoneJs.off('submit', bindVerifoneInline);
76            $("form#order_review").off('submit', bindVerifoneInline);
77            $("#verifone_wrapper").hide();
78        }
79
80        if(isBlocksVerifoneJs)
81            wooBlocksVerifoneJsInit();
82    }
83
84    function moveVerifoneJsWrapper() {
85        let parent = $("#payment_method_verifone_inline_cart:checked, #radio-control-wc-payment-method-options-verifone_inline_cart__label").closest(".wc_payment_method.payment_method_verifone_inline_cart, .wc-block-components-radio-control-accordion-option");
86
87        if(parent.length)
88            $("#verifone_wrapper").appendTo(parent);
89    }
90
91    function getOrderAmount() {
92        let orderReview = document.querySelector(".woocommerce-checkout-review-order");
93
94        if (orderReview) {
95            let orderTotalElement = orderReview.querySelector(".order-total .woocommerce-Price-amount");
96
97            if (orderTotalElement) {
98                let orderTotalText = orderTotalElement.textContent;
99                let orderTotal = parseFloat(orderTotalText.replace(/[^0-9.,]/g, "").replace('.', ''));
100                return orderTotal;
101            }
102        }
103    }
104
105    function verifoneErrorShow(error) {
106        $('#verifone_error').html(error).show();
107        let targetOffset = $("#verifone_error").offset().top - 30;
108        $(document).scrollTop(targetOffset);
109        $('#place_order').attr('disabled', false);
110    }
111
112    $(document).on('ready', function () {
113        formVerifoneJs = $('form.woocommerce-checkout, form.wc-block-checkout__form');
114        $("#payment_method_verifone_inline_cart").removeAttr("checked")
115
116        if ($('form#add_payment_method').length || formVerifoneJs.length || $('form#order_review').length) {
117            isDomReadyForVerifoneInlineJs();
118            moveVerifoneJsWrapper();
119        }
120    });
121
122    $(document).on("change", "form[name='checkout'] input[name='payment_method'], [name='radio-control-wc-payment-method-options']", function () {
123        isDomReadyForVerifoneInlineJs();
124    });
125
126    function wooBlocksVerifoneJsInit() {
127        moveVerifoneJsWrapper();
128
129        if ($("[name='radio-control-wc-payment-method-options']:checked, #payment_method_verifone_inline_cart:checked").val() === 'verifone_inline_cart') {
130            $("button.wc-block-components-checkout-place-order-button").unbind('click');
131            $("button.wc-block-components-checkout-place-order-button").on('click', bindVerifoneInline);
132
133            $("#verifone_wrapper").show();
134        } else {
135            $("button.wc-block-components-checkout-place-order-button").off('click', bindVerifoneInline);
136            $("#verifone_wrapper").hide();
137        }
138    }
139
140    var checkVerifoneJsDocumentLoadedInterval = setInterval(function () {
141        if (document.readyState === 'complete') {
142            formVerifoneJs = $("form.woocommerce-checkout, form.wc-block-checkout__form");
143            isBlocksVerifoneJs = "undefined" !== typeof wc && "undefined" !== typeof wc.blocksComponents;
144            clearInterval(checkVerifoneJsDocumentLoadedInterval);
145
146            if(isBlocksVerifoneJs)
147                wooBlocksVerifoneJsInit();
148        }
149    }, 300);
150
151    $(document).on("change", "form[id='order_review'] input[name='payment_method']", function () {
152        isDomReadyForVerifoneInlineJs();
153    });
154
155    function bindVerifoneInline(e) {
156        e.preventDefault();
157        e.stopPropagation();
158        verifoneJsCall();
159        return false;
160    }
161
162    function verifoneAjaxSubmit() {
163        const formData = formVerifoneJs.find('input:not(#verifone-card-number,#verifone-card-expiry,#verifone-card-cvc),textarea,select').serializeArray();
164
165        formData.push({ name: 'key_alias', value: publicKeyAlias });
166        formData.push({ name: 'encrypted', value: encrypted });
167
168        if (threeDsLookupData) formData.push({ name: 'three_ds_lookup_data', value: JSON.stringify(threeDsLookupData) });
169        if (ccaJwt) formData.push({ name: 'cca_jwt', value: ccaJwt });
170
171        let ajaxUrl;
172        if (isBlocksVerifoneJs)
173            ajaxUrl = verifoneJsBlocksCheckoutUrl;
174        else
175            ajaxUrl = wc_checkout_params.checkout_url;
176
177        $.ajax({
178            type: 'POST',
179            data: formData,
180            url: ajaxUrl,
181            success: function (response) {
182                if ('undefined' !== typeof response.info)
183                    response = response.info;
184
185                if ('undefined' !== typeof response.error) {
186                    verifoneErrorShow(response.error);
187                    return false;
188                } else {
189                    window.location.replace(response.redirect);
190                }
191            },
192            error: function (response, data) {
193                verifoneErrorShow(response);
194                return false;
195            }
196        });
197    }
198
199    function verifoneTokenCreate() {
200        $.ajax({
201            type: "POST",
202            data: {},
203            url: verifone3DSJwtUrl,
204            success: function (response) {
205                if ('undefined' !== typeof response.error) {
206                    verifoneErrorShow(response.error);
207                    return;
208                }
209
210                jwt = response.info;
211
212                cardinalSetup();
213            },
214            error: function (response, data) {
215                verifoneErrorShow(response);
216                return false;
217            }
218        });
219    }
220
221    function verifoneThreeDSLookup(sessionId) {
222        $.ajax({
223            type: "POST",
224            data: {
225                sessionId: sessionId,
226                amount: getOrderAmount(),
227                billing_first_name: $('#billing_first_name').val(),
228                billing_last_name: $('#billing_last_name').val(),
229                billing_address_1: $('#billing_address_1').val(),
230                billing_city: $('#billing_city').val(),
231                billing_country: $('#billing_country').val(),
232                email: $('#billing_email').val(),
233                encrypted: encrypted,
234                key_alias: publicKeyAlias,
235            },
236            url: verifone3DSLookup,
237            success: function (response) {
238                if ('undefined' !== typeof response.error) {
239                    verifoneErrorShow(response.error);
240                    return;
241                }
242
243                threeDsLookupData = response.info;
244
245                if (threeDsLookupData.acs_url)
246                    Cardinal.continue('cca',
247                        {
248                            "AcsUrl": threeDsLookupData.acs_url,
249                            "Payload": threeDsLookupData.payload,
250                        },
251                        {
252                            "OrderDetails": {
253                                "TransactionId": threeDsLookupData.transaction_id
254                            }
255                        }
256                    );
257                else
258                    verifoneAjaxSubmit();
259            },
260            error: function (response, data) {
261                verifoneErrorShow(response);
262                return false;
263            }
264        });
265    }
266
267    function cardinalSetup() {
268        Cardinal.configure({});
269
270        if (!isCardinalSetup) {
271            Cardinal.on('payments.setupComplete', function (setupCompleteData) {
272                verifoneThreeDSLookup(setupCompleteData.sessionId);
273            });
274
275            Cardinal.on('payments.validated', function (decodedResponseData, responseJWT) {
276                if ("SUCCESS" === decodedResponseData.ActionCode) {
277                    ccaJwt = responseJWT;
278                    verifoneAjaxSubmit();
279                } else {
280                    verifoneErrorShow('Payment cannot be made with this card.');
281                }
282            });
283
284            isCardinalSetup = true;
285        }
286
287        Cardinal.setup("init", { jwt: jwt });
288    }
289})();

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.