PageSourceSearch

https://skiclassics.com/wp-content/plugins/mystripe/assets/mystripe-js-functions.js?ver=1763536946

js skiclassics.com collected 2026-10-02 11:53:08 UTC 26,640 bytes, 1,451 lines download raw bytes

1jQuery(document).ready(function($) {
2
3
4
5    console.log("mystripe-js-functions.js loaded");
6
7
8
9    const setProcessing = (isProcessing) => {
10
11        if(isProcessing) {
12
13            document.querySelector(".overlay").classList.remove("hidden");
14
15        } else {
16
17            document.querySelector(".overlay").classList.add("hidden");
18
19        }
20
21    }
22
23
24
25
26
27    let redirect_url = jQuery("#redirectUrl").val();
28
29    let plugin_base_url = jQuery("#baseUrl").val() + '/wp-content/plugins';
30    
31
32
33
34
35
36    if( jQuery("div.payment-status-check").length != 0 ){
37
38        // console.log("Ready to verify");
39
40        // setProcessing(true);       
41
42        paymentStatusCheck();
43
44
45
46    };
47
48
49
50
51
52    let elements;
53
54    let stripe;
55
56    if(jQuery("#stripePk").length != 0){
57
58        stripe = Stripe(jQuery("#stripePk").val());
59
60    } 
61
62    
63
64    $(document).on('click', 'span#MystripeCoupon', function () {
65
66        const $this = $(this);
67
68        const isItalic = $this.css('font-style') === 'italic';
69
70        
71
72        // Toggle font style
73
74        $this.css('font-style', isItalic ? 'normal' : 'italic');
75
76
77
78        // Toggle the " X" at the end
79
80        const originalText = "Coupon";
81
82        if (!isItalic && $this.text() === originalText) {
83
84        $this.text(originalText + ' X');
85
86        } else if (isItalic && $this.text().endsWith(' X')) {
87
88        $this.text(originalText);
89
90        }
91
92
93
94        jQuery(this).parent().next().toggleClass("hidden");
95
96        
97
98    });
99
100
101
102    $(document).on('click', '.mystripe-coupon-fields-wrapper span.mystripe-btn', function () {
103
104        const code = jQuery(this).prev().val();
105
106        if(code != ""){
107
108            // console.log(code);
109
110            mystripeCouponCheck(code);
111
112        } else {
113
114            console.error("no value!");
115
116        }
117
118    });
119
120
121
122
123
124
125
126
127
128
129
130    if(jQuery("#news-marketing-checkbox").length != 0){
131
132        updateMarketingCheckboxSession(plugin_base_url); // sets/loads the default marketing checkbox setting if checkbox present
133
134    }
135
136
137
138    jQuery(document).on("change", "#news-marketing-checkbox", function(){
139
140        updateMarketingCheckboxSession(plugin_base_url); // handles changes to the marketing checkbox
141
142    })    
143
144
145
146    jQuery(document).on("click", "div.rule span",function(){
147
148        jQuery("div.rule label.news-marketing-checkbox-label").click();
149
150    });
151
152
153
154
155
156    jQuery(document).on("click", "span#editAddress",function(){
157
158        toggleMystripePaymentFormFields();
159
160 
161
162    });
163
164
165
166    jQuery(document).on("click", "span#proceedPayment",function(){
167
168        if(formIsValid()){
169
170            toggleMystripePaymentFormFields();
171
172            initializeStripe();
173
174        } else {
175
176            validateForm(); // will show errors etc
177
178            
179
180        }
181
182 
183
184    });
185
186
187
188    if(formIsValid() && jQuery("span#proceedPayment").length != 0){
189
190        jQuery("span#proceedPayment").click(); // auto-submits shipping fields form if already filled on pageload
191
192    }
193
194
195
196    
197
198    function toggleMystripePaymentFormFields(){
199
200        if (jQuery(".mystripe-shipping-address-module .mystripe-cta-wrapper").css("display") !== "none") {
201
202            jQuery(".mystripe-shipping-address-module p").hide();
203
204            jQuery(".mystripe-shipping-address-module .mystripe-cta-wrapper").hide();
205
206            jQuery(".mystripe-shipping-address-module .mystripe-form-field").hide();
207
208            jQuery(".mystripe-shipping-address-module").append('<span id="editAddress">Edit address fields</span>');
209
210        } else {
211
212            jQuery(".mystripe-shipping-address-module p").show();
213
214            jQuery(".mystripe-shipping-address-module .mystripe-cta-wrapper").show();
215
216            jQuery(".mystripe-shipping-address-module .mystripe-form-field").show();
217
218            jQuery(".mystripe-shipping-address-module span#editAddress").remove();
219
220            jQuery(".mystripe-place-order-module").addClass("hidden");
221
222            jQuery(".payment-fields-content").hide();
223
224            jQuery("#payment-element").empty();
225
226        }
227
228    }
229
230
231
232    
233
234    function formIsValid() {
235
236        
237
238        const $requiredInputs = $('.mystripe-form-field :required');
239
240        let allValid = true;
241
242        const errors = [];
243
244        const formData = {};
245
246    
247
248        $requiredInputs.each(function () {
249
250            const $field = $(this);
251
252            const tag = this.tagName.toLowerCase();
253
254            const type = $field.attr('type');
255
256            const name = $field.attr('name');
257
258            let val = $field.val();
259
260    
261
262            $field.removeClass('input-error');
263
264    
265
266            // Handle select fields
267
268            if (tag === 'select') {
269
270            // If no value is selected, consider it invalid
271
272            if (!val || val === "") {
273
274                allValid = false;
275
276                errors.push({ field: this, reason: 'This field is required.' });
277
278                $field.addClass('input-error');
279
280                return;
281
282            }
283
284            } else {
285
286            // For other fields, just trim the value
287
288            if (typeof val === 'string') {
289
290                val = val.trim();
291
292            }
293
294    
295
296            // Validate empty (for inputs)
297
298            if (!val || (Array.isArray(val) && val.length === 0)) {
299
300                allValid = false;
301
302                errors.push({ field: this, reason: 'This field is required.' });
303
304                $field.addClass('input-error');
305
306                return;
307
308            }
309
310    
311
312            // Validate email (for email type inputs)
313
314            if (type === 'email' && !validateEmail(val)) {
315
316                allValid = false;
317
318                errors.push({ field: this, reason: 'Invalid email address.' });
319
320                $field.addClass('input-error');
321
322                return;
323
324            }
325
326            }
327
328    
329
330            // Save valid value to formData
331
332            if (name) {
333
334            formData[name] = val;
335
336            }
337
338        });
339
340    
341
342        // Return form data if all fields are valid
343
344        if (allValid) {
345
346            $('.error-msg').remove(); // Clear any previous error messages
347
348            return formData;
349
350        } else {
351
352            return false;
353
354        }
355
356    }
357
358    
359
360           
361
362    function validateForm() {
363
364        
365
366        const $requiredInputs = $('.mystripe-form-field :required');
367
368        let allValid = true;
369
370        const errors = [];
371
372        const formData = {};
373
374    
375
376        $requiredInputs.each(function () {
377
378            const $field = $(this);
379
380            const tag = this.tagName.toLowerCase();
381
382            const type = $field.attr('type');
383
384            const name = $field.attr('name');
385
386            let val = $field.val();
387
388    
389
390            $field.removeClass('input-error');
391
392    
393
394            // Handle select fields
395
396            if (tag === 'select') {
397
398            // If no value is selected, consider it invalid
399
400            if (!val || val === "") {
401
402                allValid = false;
403
404                errors.push({ field: this, reason: 'This field is required.' });
405
406                $field.addClass('input-error');
407
408                return;
409
410            }
411
412            } else {
413
414            // For other fields, just trim the value
415
416            if (typeof val === 'string') {
417
418                val = val.trim();
419
420            }
421
422    
423
424            // Validate empty (for inputs)
425
426            if (!val || (Array.isArray(val) && val.length === 0)) {
427
428                allValid = false;
429
430                errors.push({ field: this, reason: 'This field is required.' });
431
432                $field.addClass('input-error');
433
434                return;
435
436            }
437
438    
439
440            // Validate email (for email type inputs)
441
442            if (type === 'email' && !validateEmail(val)) {
443
444                allValid = false;
445
446                errors.push({ field: this, reason: 'Invalid email address.' });
447
448                $field.addClass('input-error');
449
450                return;
451
452            }
453
454            }
455
456    
457
458            // Save valid value to formData
459
460            if (name) {
461
462            formData[name] = val;
463
464            }
465
466        });
467
468    
469
470        // Return form data if all fields are valid
471
472        if (allValid) {
473
474            $('.error-msg').remove(); // Clear any previous error messages
475
476            return formData;
477
478        } else {
479
480            showErrors(errors); // Display error messages
481
482            return false;
483
484        }
485
486    }
487
488           
489
490    
491
492    function validateEmail(email) {
493
494        // Simple email validation regex
495
496        return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
497
498    }
499
500              
501
502        
503
504    
505
506    function showErrors(errors) {
507
508        $('.error-msg').remove(); // clear old errors
509
510      
511
512        errors.forEach(error => {
513
514          const $input = $(error.field);
515
516          const msg = $('<div class="error-msg" style="color:red; font-size:0.9em;"></div>').text(error.reason);
517
518          $input.after(msg); // insert error message after the input field
519
520        });
521
522    }
523
524    
525
526    function mystripeCouponCheck(code){
527
528    
529
530        setProcessing(true);
531
532    
533
534        $.ajax({
535
536            url: mystripe_ajax_object.ajax_url,
537
538            method: 'POST',
539
540            data: {
541
542                action: 'coupon_check',
543
544                coupon_code: code,
545
546            },
547
548            success: function(response) {
549
550                // console.log(response);
551
552                if (response.success) {
553
554                    location.reload(true); // Force a reload and ignore cache
555
556                    
557
558                } else {
559
560                    console.log('Failed:', response);
561
562                    setProcessing(false);
563
564                }
565
566            }
567
568        });    
569
570    }
571
572
573
574  
575
576    async function initialize(plugin_base_url, pi_data) { // Fetches a payment intent and captures the client secret
577
578
579
580        // let elements;
581
582        // const stripe = Stripe(jQuery("#stripePk").val());
583
584    
585
586        const { clientSecret } = await fetch(plugin_base_url + '/mystripe/includes/stripe/create-pi.php', {
587
588          method: "POST",
589
590          headers: { "Content-Type": "application/json" },
591
592          body: JSON.stringify({ 
593
594              amount:pi_data.amount,
595
596              currency:pi_data.currency,
597
598           }),
599
600        }).then((r) => r.json());
601
602      
603
604        const appearance = {
605
606          theme: 'flat',
607
608        };
609
610      
611
612        elements = stripe.elements({ clientSecret, appearance });
613
614      
615
616        const paymentElementOptions = {
617
618          layout: "accordion",
619
620        };
621
622      
623
624        const paymentElement = elements.create("payment", paymentElementOptions);
625
626        paymentElement.on('ready', () => {
627
628            // console.log('Payment Element is fully loaded');
629
630            jQuery(".mystripe-payment-module form#payment-form").removeClass("disabled-overlay");
631
632            jQuery(".mystripe-payment-module").removeClass("hidden");
633
634            setProcessing(false);
635
636
637
638        });
639
640        paymentElement.mount("#payment-element");
641
642        updatePayButton(pi_data.amount, pi_data.currency); // Inserts the visual/text of what you are paying
643
644        jQuery(".payment-fields-content").show();
645
646    }
647
648      
649
650    async function handleSubmit(e) {
651
652        e.preventDefault();
653
654        setLoading(true);
655
656        const { error } = await stripe.confirmPayment({
657
658          elements,
659
660          confirmParams: {
661
662            return_url: redirect_url + '?payment_status_check', // After payment action is confirmed, we redirect to double-check the payment intent status
663
664          },
665
666        });
667
668      
669
670        if (error.type === "card_error" || error.type === "validation_error") {
671
672          showMessage(error.message);
673
674        } else {
675
676          showMessage("An unexpected error occurred.");
677
678        }
679
680        
681
682        setLoading(false);
683
684    }
685
686      
687
688    // ------- UI helpers -------
689
690    
691
692    function showMessage(messageText) {
693
694    const messageContainer = document.querySelector("#payment-message");
695
696    messageContainer.classList.remove("hidden");
697
698    messageContainer.textContent = messageText;
699
700    setTimeout(function () {
701
702        messageContainer.classList.add("hidden");
703
704        messageContainer.textContent = "";
705
706    }, 4000);
707
708    }
709
710      
711
712    // Show a spinner on payment submission
713
714    function setLoading(isLoading) {
715
716    if (isLoading) {
717
718        // Disable the button and show a spinner
719
720        document.querySelector("#submit").disabled = true;
721
722        document.querySelector("#spinner").classList.remove("hidden");
723
724        document.querySelector("#button-text").classList.add("hidden");
725
726    } else {
727
728        document.querySelector("#submit").disabled = false;
729
730        document.querySelector("#spinner").classList.add("hidden");
731
732        document.querySelector("#button-text").classList.remove("hidden");
733
734    }
735
736    }
737
738    
739
740    function updateMarketingCheckboxSession(plugin_base_url) {
741
742        
743
744        jQuery.ajax({
745
746            url: plugin_base_url + '/mystripe/includes/stripe/update-checkbox-session.php',
747
748            type: "POST",
749
750            data: { marketing_opt_in: jQuery("#news-marketing-checkbox").is(":checked") ? 1 : 0 }
751
752        });
753
754    }
755
756          
757
758    function loadStripeScript() {
759
760        if (!document.querySelector('script[src="https://js.stripe.com/v3/"]')) {
761
762            const script = document.createElement('script');
763
764            script.src = "https://js.stripe.com/v3/";
765
766            script.async = true;
767
768            document.head.appendChild(script);
769
770        }
771
772    }
773
774  
775
776    function updatePayButton(amountCents, currency) {
777
778        const amountFormatted = (amountCents / 100).toFixed(2); // e.g. "29.99"
779
780        document.getElementById("button-text").textContent = `Pay `+currency+` ${amountFormatted}`;
781
782        // console.log("Just updated PayButton");
783
784    }
785
786    
787
788    async function startPaymentProcess(data) {
789
790        try {
791
792            await saveShippingAddress(data) // store shipping details <- to store the form fields in SESSION for later creation of the WC order
793
794            .then(result => { 
795
796                updateCheckoutHtml(); // updateCartHtml based on shipping, taxes etc coming from the stored shipping address           
797
798                if(result.amount && result.currency){
799
800                    jQuery(".mystripe-place-order-module").addClass("hidden");
801
802
803
804                    
805
806                    $('div.rule').insertAfter('div#payment-element');
807
808
809
810                    initialize(plugin_base_url, result); // console.log("Starting initialize...");
811
812                    document.querySelector("#payment-form")
813
814                    .addEventListener("submit", handleSubmit);
815
816                } else if(result.amount == 0) {
817
818
819
820                    $('.mystripe-place-order-module').prepend($('div.rule'));
821
822
823
824
825
826                    jQuery(".mystripe-place-order-module").removeClass("hidden");
827
828                    setProcessing(false);
829
830                    
831
832                    // console.error('Did not get amount and currency back...');        
833
834                } else {
835
836                    console.error('No amount and amount not 0...');        
837
838                }
839
840            });
841
842               
843
844        } catch (err) {
845
846            console.error('Something went wrong:', err);
847
848        }      
849
850        return data;
851
852    }
853
854    
855
856    function updateCheckoutHtml(){
857
858        $.ajax({
859
860            url: mystripe_ajax_object.ajax_url,
861
862            method: 'POST',
863
864            data: {
865
866                action: 'update_cart_html'
867
868            },
869
870            success: function(response) {
871
872                if (response.success) {
873
874                    if(response.data.summaryHtml){
875
876                        jQuery("#mystripeSummaryField").html(response.data.summaryHtml);
877
878                    }
879
880                } else {
881
882                    console.log('Failed to update cart html:', response.data);
883
884                }
885
886            }
887
888        });    
889
890    }
891
892
893
894    async function saveShippingAddress(shipping_address) {
895
896        return new Promise((resolve, reject) => {
897
898            $.ajax({
899
900                url: plugin_base_url + '/mystripe/includes/stripe/set-shipping-address.php',
901
902                type: "POST",
903
904                data: JSON.stringify({ shipping_address }),
905
906                contentType: "application/json", // Set content type
907
908                dataType: "json"
909
910            })
911
912            .then(function(response) {
913
914                // console.log(response);
915
916                if(response.shipping_address){
917
918                    resolve(response);
919
920                }                
921
922            })
923
924            .catch(function(error) {
925
926                console.log('rejected saveShippingAddress: ', error);
927
928                reject("Error:", error);
929
930            });  
931
932        });
933
934    }
935
936    
937
938    function initializeStripe(){
939
940        const startTime = performance.now();
941
942        setProcessing(true);
943
944        // loadStripeScript(); //to connect to Stripe API
945
946        startPaymentProcess(formIsValid())
947
948        .then(result => {
949
950            const endTime = performance.now();
951
952            const duration = endTime - startTime;
953
954            let actionDuration = duration;
955
956            console.log(`Action duration: ${actionDuration.toFixed(3)} ms`);
957
958        })
959
960        .catch((error) => {
961
962            console.error("Error:", error)
963
964
965
966            const endTime = performance.now();
967
968            const duration = endTime - startTime;
969
970            let actionDuration = duration;
971
972            console.log(`Action duration: ${actionDuration.toFixed(3)} ms`);
973
974            setProcessing(false);
975
976        });
977
978    }
979
980
981
982    window.removeItem = function(productId,placement) {
983
984        setProcessing(true);
985
986
987
988        // Send AJAX request to WordPress
989
990        $.ajax({
991
992            url: mystripe_ajax_object.ajax_url,
993
994            method: 'POST',
995
996            data: {
997
998                action: 'update_cart_item',
999
1000                product_id: productId,
1001
1002                placement: placement,
1003
1004            },
1005
1006            success: function(response) {
1007
1008                console.log('Cart updated:', response);
1009
1010                if (response.success) {
1011
1012
1013
1014                    if(placement == 'cart'){
1015
1016                        location.reload(true);
1017
1018                    } else {
1019
1020                        location.reload(true);
1021
1022                    }
1023
1024                    
1025
1026                } else {
1027
1028                    if(response.data.msg){
1029
1030                        console.log('Failed to update cart:', response.data.msg);
1031
1032                    }
1033
1034                    
1035
1036                    if(response.data.url){
1037
1038                        window.location.replace(response.data.url);
1039
1040                    }
1041
1042                    
1043
1044                }
1045
1046            }
1047
1048        });
1049
1050    }
1051
1052
1053
1054    $(document).on('click', '.mystripe-place-order-module button', function() {
1055
1056        setProcessing(true);
1057
1058        try {
1059
1060                                    
1061
1062            // Make sure Rule integration runs
1063
1064            // Make sure Fortnox integration runs
1065
1066
1067
1068            createWoocommerceOrder(plugin_base_url, { amount_received:0 })
1069
1070            .then(response => {
1071
1072                // Handle the response if the promise resolves successfully
1073
1074                console.log('Order created successfully:', response);
1075
1076                if(response.thank_you_url){
1077
1078                    window.location.replace(response.thank_you_url);
1079
1080                    // setProcessing(false);   
1081
1082                }
1083
1084            })
1085
1086            .catch(error => {
1087
1088                // Handle the error if the promise is rejected
1089
1090                console.error('Error creating order:', error);
1091
1092                window.location.replace(redirect_url + '?error_code=missing_order_id');
1093
1094                // setProcessing(false);        
1095
1096
1097
1098            })
1099
1100            .finally(() => {
1101
1102                // This will run regardless of whether the promise resolved or rejected
1103
1104                // console.log('Payment processing completed.');
1105
1106            });            
1107
1108        
1109
1110        } catch (error) {
1111
1112        
1113
1114            // Handle rejection (error), but no redirect happens here
1115
1116            console.error('Error during the request:', error);
1117
1118            window.location.replace(redirect_url + '?error_code=repeat');
1119
1120            // setProcessing(false);
1121
1122        }
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132    });
1133
1134
1135
1136
1137
1138    
1139
1140    $(document).on('click', '.quantity-selector button', function() {
1141
1142        setProcessing(true);    
1143
1144        var productId = jQuery(this).parent().parent().parent().attr("data-product-id"); 
1145
1146        var quantity = parseInt(jQuery(this).attr("data-item-value"), 10);
1147
1148        const $input = $('#quantity-' + productId); // Use jQuery to select the input by ID
1149
1150        const min = parseInt($input.attr('min')); // Get the "min" attribute
1151
1152        const max = parseInt($input.attr('max')); // Get the "max" attribute
1153
1154        let value = parseInt($input.val()); // Get the current value of the input
1155
1156        value = Math.max(min, Math.min(max, value + quantity)); // Adjust the value
1157
1158        // $input.val(value); // Set the new value
1159
1160
1161
1162        // Handle the quantity change here
1163
1164        // Send AJAX request to WordPress
1165
1166        $.ajax({
1167
1168            url: mystripe_ajax_object.ajax_url,
1169
1170            method: 'POST',
1171
1172            data: {
1173
1174                action: 'update_cart_quantity',
1175
1176                product_id: productId,
1177
1178                quantity: value
1179
1180            },
1181
1182            success: function(response) {
1183
1184                if (response.success) {
1185
1186                    console.log('Cart updated:', response.data);
1187
1188                    if(response.data.cartHtml){
1189
1190                        jQuery("#mystripeCartFields").html(response.data.cartHtml);
1191
1192                        $input.val(value); // Set the new value
1193
1194                        setProcessing(false);                    
1195
1196                    }
1197
1198
1199
1200                    if(response.data.item_count){
1201
1202                        jQuery(".badge-holder span.cart-count").text(response.data.item_count);
1203
1204                    }
1205
1206                    
1207
1208                } else {
1209
1210                    console.log('Failed to update cart html:', response.data);
1211
1212                    setProcessing(false);       
1213
1214                }
1215
1216            }
1217
1218        });    
1219
1220        
1221
1222    });
1223
1224
1225
1226
1227
1228    async function paymentStatusCheck() {
1229
1230        setProcessing(true);      
1231
1232        const queryString = window.location.search;
1233
1234        const urlParams = new URLSearchParams(queryString);
1235
1236        const paymentIntent = urlParams.get("payment_intent");
1237
1238        const paymentIntentClientSecret = urlParams.get("payment_intent_client_secret");
1239
1240        const response = await fetch(plugin_base_url + '/mystripe/includes/stripe/check-payment-intent.php', {
1241
1242            headers: {
1243
1244            Accept: "application/json",
1245
1246            "Content-Type": "application/json",
1247
1248            },
1249
1250            method: "POST",
1251
1252            body: JSON.stringify({ payment_intent: paymentIntent, client_secret: paymentIntentClientSecret }),
1253
1254        });
1255
1256        const res = await response.json();
1257
1258        // console.log("paymentstatuscheck:", res);
1259
1260        
1261
1262        if(res.payment.status){
1263
1264            
1265
1266            switch (res.payment.status) {
1267
1268            case 'requires_payment_method':
1269
1270            case 'requires_confirmation':
1271
1272            case 'requires_action':
1273
1274            case 'processing':
1275
1276            case 'canceled':
1277
1278                window.location.replace(redirect_url + '?error_code='+res.payment.status);
1279
1280                break;
1281
1282    
1283
1284            case 'succeeded':
1285
1286                
1287
1288                try {
1289
1290                                    
1291
1292                    // Make sure Rule integration runs
1293
1294                    // Make sure Fortnox integration runs
1295
1296    
1297
1298                    createWoocommerceOrder(plugin_base_url, { amount_received:res.payment.amount_received ,payment_status:res.payment.status, payment_intent:paymentIntent })
1299
1300                    .then(response => {
1301
1302                        // Handle the response if the promise resolves successfully
1303
1304                        // console.log('Order created successfully:', response);
1305
1306                        if(response.thank_you_url){
1307
1308                            window.location.replace(response.thank_you_url);
1309
1310                            // setProcessing(false);   
1311
1312                        }
1313
1314                    })
1315
1316                    .catch(error => {
1317
1318                        // Handle the error if the promise is rejected
1319
1320                        // console.error('Error creating order:', error);
1321
1322                        window.location.replace(redirect_url + '?error_code=missing_order_id');
1323
1324                        // setProcessing(false);        
1325
1326    
1327
1328                    })
1329
1330                    .finally(() => {
1331
1332                        // This will run regardless of whether the promise resolved or rejected
1333
1334                        // console.log('Payment processing completed.');
1335
1336                    });            
1337
1338                
1339
1340                } catch (error) {
1341
1342                
1343
1344                    // Handle rejection (error), but no redirect happens here
1345
1346                    // console.error('Error during the request:', error);
1347
1348                    window.location.replace(redirect_url + '?error_code=repeat');
1349
1350                    // setProcessing(false);
1351
1352                }
1353
1354                break;
1355
1356            
1357
1358            
1359
1360            default:
1361
1362                window.location.replace(redirect_url + '?error_code=uncaught_payment_status&status=' + res.payment.status);
1363
1364                // setProcessing(false);
1365
1366                break;
1367
1368            }
1369
1370        } else {
1371
1372            window.location.replace(redirect_url + '?error_code=missing_payment_status');
1373
1374            // setProcessing(false);
1375
1376        }
1377
1378    
1379
1380    }
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390    function createWoocommerceOrder(plugin_base_url, send_data) {
1391
1392        return new Promise((resolve, reject) => {
1393
1394          jQuery.ajax({
1395
1396              url: plugin_base_url + '/mystripe/includes/stripe/create-woocommerce-order.php',
1397
1398              type: "POST",
1399
1400              data: JSON.stringify({ send_data }),
1401
1402              success: function(response) {
1403
1404                let res = JSON.parse(response);
1405
1406      
1407
1408                if(res.order_id && res.thank_you_url){
1409
1410                  resolve(res);
1411
1412                }else {
1413
1414                  reject('Invalid response data');
1415
1416                }
1417
1418              },
1419
1420              error: function(xhr, status, error) {
1421
1422                reject('AJAX Error: ' + error);
1423
1424              }
1425
1426          });
1427
1428        });
1429
1430      }
1431
1432      
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448});
1449
1450
1451

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.