PageSourceSearch

https://couroart.com.br/wp-content/plugins/clearsale-total/public/js/clearsale-total-public.js?ver=3.4.2

js couroart.com.br collected 2026-10-07 17:55:16 UTC 14,563 bytes, 514 lines download raw bytes

1var tonocheckout=0;
2
3(function( $ ) {
4	'use strict';
5
6// Pagseguro v 2.0.0
7//l 259 - template/direct-payment.php
8$(document).ready(function(){
9	$('.btn-form').on('click', function(e) {
10		//e.preventDefault();
11		console.log("Ajax:ClearSale:PagSeguro");
12
13		var metodo = 1; // pgseguro oficial
14		var card = $('#card_num').val();
15		var card_installments = $('#card_installments').val();
16		var card_holder = $('#card_holder_name').val();
17		//var cvv = $('#card_cod').val();
18		var cpf = $('#document-credit-card').val();
19		var validate = $('#card_expiration_month').val() + "/" + $('#card_expiration_year').val();
20
21		var order_id = $('#order').attr('data-target');
22		//var card_holder_birthdate = $('#card_holder_birthdate').val();
23
24		// se for boleto
25		var document_boleto = $('#document-boleto').val();
26		// cartao de debito
27		var document_debit = $('#document-debit').val();
28
29		var document = 0; // deveria se exclusivo
30		if (cpf.length >0) {
31			document = cpf;
32			if (card.length < 19) {
33				console.log("cartao credito < 19=" + card);
34				return;	//# cartao invalido
35			}
36		}
37		if (document_boleto.length >0) document = document_boleto;
38		if (document_debit.length >0) document = document_debit;
39		if (document.length <=0) {
40			console.log("sem # de documento=" + document);
41			return;
42		}
43
44		if (document.length <= 14 && validateCpf(document.toString()) === false) {
45			console.log("cpf invalido=" + document);
46			return; // cpf invalido
47		} else if (document.length > 14 && document.length <= 18 && validateCnpj(document.toString()) === false) { // cnpj
48			console.log("cnpj invalido=" + document);
49			return;
50		}
51
52		console.log("entrou card=" + card + " nome=" + card_holder);
53		console.log("documento=" + document);
54
55		var dados_pagseg = {
56			metodo: metodo,
57			order: order_id,
58			card: card,
59			card_holder: card_holder,
60			cpf: cpf,
61			validate: validate,
62			installments: card_installments,
63			doc_boleto: document_boleto,
64			doc_debito: document_debit
65		};
66
67		var dados_envio = {
68			'clearsale_total_ajax_nonce': js_global.clearsale_total_ajax_nonce,
69 			'pagseguro': dados_pagseg,
70			'action': 'clearsale_total_push'
71      		}
72
73		jQuery.ajax({
74			url: js_global.xhr_url,
75			type: 'POST',
76			data: dados_envio,
77			dataType: 'JSON',
78			success: function(response) {
79				if (response == '401'  ){
80					console.log('Requisição inválida')
81				}
82				else if (response == 402) {
83					console.log('Todos os posts já foram mostrados')
84				} else {
85					console.log('resposta=' + response)
86				}
87			}
88		});
89
90	});
91
92	function validateCpf(str) {
93		str = str.replace('.','');
94		str = str.replace('.','');
95		str = str.replace('.','');
96		str = str.replace('-','');
97		var strCPF = str;
98		var sum;
99		var rest;
100		sum = 0;
101
102		var equal_digits = 1;
103
104		for (i = 0; i < strCPF.length - 1; i++) {
105			if (strCPF.charAt(i) != strCPF.charAt(i + 1)) {
106				equal_digits = 0;
107				break;
108			}
109		}
110
111		if (!equal_digits) {
112			for (var i = 1; i <= 9; i++) {
113				sum = sum + parseInt(strCPF.substring(i-1, i)) * (11 - i);
114			}
115
116			rest = sum % 11;
117
118			if ((rest == 0) || (rest == 1)) {
119				rest = 0;
120			} else {
121				rest = 11 - rest;
122			};
123
124			if (rest != parseInt(strCPF.substring(9, 10)) ) {
125				return false;
126			}
127
128			sum = 0;
129			for (i = 1; i <= 10; i++) {
130				sum = sum + parseInt(strCPF.substring(i-1, i)) * (12 - i);
131			}
132
133			rest = sum % 11;
134
135			if ((rest == 0) || (rest == 1)) {
136				rest = 0;
137			} else {
138				rest = 11 - rest;
139			};
140
141			if (rest != parseInt(strCPF.substring(10, 11) ) ) {
142				return false;
143			}
144			return true;
145
146		} else {
147			return false;
148		}
149	};
150
151	function validateCnpj(str) {
152		str = str.replace('.','');
153		str = str.replace('.','');
154		str = str.replace('.','');
155		str = str.replace('-','');
156		str = str.replace('/','');
157		var cnpj = str;
158		var numbersVal;
159		var digits;
160		var sum;
161		var i;
162		var result;
163		var pos;
164		var size;
165		var equal_digits;
166
167		equal_digits = 1;
168
169		if (cnpj.length < 14 && cnpj.length < 15) {
170			return false;
171		}
172
173		for (i = 0; i < cnpj.length - 1; i++) {
174			if (cnpj.charAt(i) != cnpj.charAt(i + 1)) {
175				equal_digits = 0;
176				break;
177			}
178		}
179
180		if (!equal_digits) {
181			size = cnpj.length - 2
182			numbersVal = cnpj.substring(0,size);
183			digits = cnpj.substring(size);
184			sum = 0;
185			pos = size - 7;
186			for (i = size; i >= 1; i--)	{
187				sum += numbersVal.charAt(size - i) * pos--;
188				if (pos < 2) pos = 9;
189			}
190			result = sum % 11 < 2 ? 0 : 11 - sum % 11;
191			if (result != digits.charAt(0))
192				return false;
193			size = size + 1;
194			numbersVal = cnpj.substring(0,size);
195			sum = 0;
196			pos = size - 7;
197			for (i = size; i >= 1; i--)	{
198				sum += numbersVal.charAt(size - i) * pos--;
199				if (pos < 2)
200					pos = 9;
201			}
202			result = sum % 11 < 2 ? 0 : 11 - sum % 11;
203			if (result != digits.charAt(1)) {
204				return false;
205			}
206
207			return true;
208		} else {
209			return false;
210		}
211	};
212
213	//botão de fechar pedido do Woo - pegar dados do place_order
214    //$('form.woocommerce-checkout').on('click', "#place_order", function(e) {
215	let $form1 = $('form.woocommerce-checkout');
216	let $form2 = $('#order_review'); 
217	let $forms = $form1.add($form2);
218	$forms.on('click', "#place_order", function(e) {
219		console.log("Ajax:ClearSale:place_order entrou...");
220
221		var card = null;
222		var card_holder = null;
223		var validate = null;
224		var card_installments = null;
225		var cpf = null;
226		var metodo = null;
227		var document_boleto = null;
228		var document_debit = null;
229		var document_pix = null;
230		var checked_is = null;
231
232		if (document.querySelector('input[name="payment_method"]:checked')) {
233			checked_is = document.querySelector('input[name="payment_method"]:checked').value;
234			console.log("checked is:" + checked_is);
235			if (checked_is == "gerencianet_oficial") {
236				console.log("gn checked");
237				metodo = 4;
238			}
239			if (checked_is == "iugu-credit-card") {
240				console.log("iugu checked");
241				metodo = 6;
242			}
243			if (checked_is == "pagseguro") {
244				console.log("pagseg-claudio checked");
245				metodo = 8;
246			}
247			if (checked_is == "paypal-brasil-plus-gateway") {
248				console.log("paypal-brasil-plus-gateway");
249				metodo = 10;
250			}
251			if (checked_is == "pagbank_credit_card") {
252				console.log("pagbank_credit_card");
253				metodo = 11;
254			}
255			if (checked_is == "click2pay-credit-card") {
256				console.log("click2pay-credit-card");
257				metodo = 12;
258			}
259			if (checked_is == "virt_pagseguro") {
260				console.log("virtuaria_pagseguro");
261				metodo = 14;
262			}
263			if (checked_is == "rede_debit") {
264				console.log("linknacional_rede_debit");
265				metodo = 15;
266			}
267			if (checked_is == "rede_credit") {
268				console.log("linknacional_rede_credit");
269				metodo = 16;
270			}
271			if (checked_is == "lkn_cielo_debit") {
272				console.log("linknacional_cielo_debit_credit");
273				metodo = 17;
274			}
275			if (checked_is == "lkn_cielo_credit") {
276				console.log("linknacional_cielo_credit");
277				metodo = 18;
278			}
279
280		}
281		if (metodo == 4) {
282			console.log("Ajax:ClearSale:place_order: é gerencianet");
283			if (card == null) {
284				card = $('#gn_card_number_card').val();
285				if (card != null) {
286						card_holder = $('#gn_card_name_corporate').val();
287						validate = $('#gn_card_expiration_month').val() + "/" + $('#gn_card_expiration_year').val();
288						card_installments = $('#gn_card_installments').val();
289						cpf = $('#gn_card_cpf_cnpj').val();
289// CPF nao pede neste metodo
290				}
291			}
292			document_pix = $('#gn_pix_cpf_cnpj').val();
293			// gerencianet - boleto - nao pede doc
294			if (document.querySelector('input[name="paymentMethodRadio"]:checked')) {
295				var ck = document.querySelector('input[name="paymentMethodRadio"]:checked').value;
296				console.log("boleto checado =" + ck);
297				if (ck == "billet") {
298					if ($('#billing_cnpj').val()) {
299						document_boleto = $('#billing_cnpj').val();
300					} else {
301						document_boleto = $('#billing_cpf').val();
302					}
303				}
304			}
305		} // end if =4
306		if (metodo == 6) {
307			console.log("Ajax:ClearSale:place_order: é iugu");
308			if (card == null) {
309				card = $('#iugu-card-number').val();
310				if (card != null) {
311						card_holder = $('#iugu-card-holder-name').val();
312						validate = $('#iugu-card-expiry').val();
313						card_installments = 1; //nao pede
314						if ($('#billing_cnpj').val()) {// CPF | CNPJ nao pede neste metodo
315							cpf = $('#billing_cnpj').val();
316						} else {
317							cpf = $('#billing_cpf').val();
318						}
319				}
320			}
321		} // end of if =6
322		if (metodo == 8) {
323			console.log("Ajax:ClearSale:place_order: é pagseg-claudio");
324			if (card == null) {
325				card = $('#pagseguro-card-number').val();
326				if (card != null) {
327					card_holder = $('#pagseguro-card-holder-name').val();
328					validate = $('#pagseguro-card-expiry').val(); // mm/aaaa
329					card_installments = $('#pagseguro-card-installments').val();
330					cpf = $('#pagseguro-card-holder-cpf-field').val();
331				}
332			}
333		} // end of if =8
334		if (metodo == 10) {
335			console.log("Ajax:ClearSale:place_order: é paypal");
336			// nada a fazer, tem iframe
337		} // end of if =10
338		if (metodo == 11) {
339			console.log("Ajax:ClearSale:place_order: é Pagbank");
340			if (card == null) {
341				card = $('#pagbank_credit_card-card-number').val();
342				if (card != null) {
343					card_holder = $('#pagbank_credit_card-card-holder').val();
344					validate = $('#pagbank_credit_card-card-expiry').val(); // mm/yy
345					card_installments = $('#pagbank_credit_card-installments').val();
346					if (card_installments == null) card_installments = 1;
347					if ($('#billing_cnpj').val()) {// CPF | CNPJ nao pede neste metodo
348						cpf = $('#billing_cnpj').val();
349					} else {
350						cpf = $('#billing_cpf').val();
351					}
352				}
353			}
354		} // end of if =11
355		if (metodo == 12) {
356			console.log("Ajax:ClearSale:place_order: é click2pay");
357			if (card == null) {
358				card = $('#click2pay-credit-card-card-number').val();
359				if (card != null) {
360					card_holder = $('#click2pay-credit-card-card-holder').val();
361					validate = $('#click2pay-credit-card-card-expiry').val(); // mm/yy
362					card_installments = $('#click2pay-credit-card-card-installments').val();
363					if (card_installments == null) card_installments = 1;
364					if ($('#billing_cnpj').val()) {// CPF | CNPJ nao pede neste metodo
365						cpf = $('#billing_cnpj').val();
366					} else {
367						cpf = $('#billing_cpf').val();
368					}
369				}
370			}
371		} // end of if =12
372		if (metodo == 14) {
373			console.log("Ajax:ClearSale:place_order: é virt_pagseguro");
374			if (card == null) {
375				card = $('#virt-pagseguro-card-number').val();
376				if (card != null) {
377					card_holder = $('#virt-pagseguro-card-holder-name').val();
378					validate = $('#virt-pagseguro-card-expiry').val(); // mm/yyyy
379					card_installments = $('#virt-pagseguro-card-installments').val();
380					if (card_installments == null) card_installments = 1;
381					if ($('#billing_cnpj').val()) {// CPF | CNPJ nao pede neste metodo
382						cpf = $('#billing_cnpj').val();
383					} else {
384						cpf = $('#billing_cpf').val();
385					}
386				}
387			}
388		} // end of if =14
389		if (metodo == 15) {
390			console.log("Ajax:ClearSale:place_order: é rede_debit-linknacional");
391			if (card == null) {
392				card = $('#rede-debit-card-number').val();
393				if (card != null) {
394					card_holder = $('#rede-debit-card-holder-name').val();
395					validate = $('#rede-debit-card-expiry').val(); // mm/yyyy
396					card_installments = $('#rede-debit-card-installments').val();
397					if (card_installments == null) card_installments = 1;
398					if ($('#billing_cnpj').val()) {// CPF | CNPJ nao pede neste metodo
399						cpf = $('#billing_cnpj').val();
400					} else {
401						cpf = $('#billing_cpf').val();
402					}
403				}
404			}
405		} // end of if =15
406		if (metodo == 16) {
407			console.log("Ajax:ClearSale:place_order: é rede_credit-linknacional");
408			if (card == null) {
409				card = $('#rede-card-number').val();
410				if (card != null) {
411					card_holder = $('#rede-card-holder-name').val();
412					validate = $('#rede-card-expiry').val(); // mm/yyyy
413					card_installments = $('#rede-card-installments').val();
414					if (card_installments == null) card_installments = 1;
415					if ($('#billing_cnpj').val()) {// CPF | CNPJ nao pede neste metodo
416						cpf = $('#billing_cnpj').val();
417					} else {
418						cpf = $('#billing_cpf').val();
419					}
420				}
421			}
422		} // end of if =16
423		if (metodo == 17) {
424			console.log("Ajax:ClearSale:place_order: é cielo_debit_credit-linknacional");
425			if (card == null) {
426				card = $('#lkn_dcno').val();
427				if (card != null) {
428					card_holder = $('#lkn_dc_cardholder_name').val();
429					validate = $('#lkn_dc_expdate').val(); // mm/yyyy
430					card_installments = $('#lkn_cc_dc_installments').val();
431					if (card_installments == null) card_installments = 1;
432					if ($('#billing_cnpj').val()) {// CPF | CNPJ nao pede neste metodo
433						cpf = $('#billing_cnpj').val();
434					} else {
435						cpf = $('#billing_cpf').val();
436					}
437				}
438			}
439		} // end of if =17
440		if (metodo == 18) {
441			console.log("Ajax:ClearSale:place_order: é cielo_credit-linknacional");
442			if (card == null) {
443				card = $('#lkn_ccno').val();
444				if (card != null) {
445					card_holder = $('#lkn_cc_cardholder_name').val();
446					validate = $('#lkn_cc_expdate').val(); // mm/yyyy
447					card_installments = $('#lkn_cc_installments').val();
448					if (card_installments == null) card_installments = 1;
449					if ($('#billing_cnpj').val()) {// CPF | CNPJ nao pede neste metodo
450						cpf = $('#billing_cnpj').val();
451					} else {
452						cpf = $('#billing_cpf').val();
453					}
454				}
455			}
456		} // end of if =18
457
458		if (metodo == null) {
459			console.log("nada recuperado via ajax! saindo...");
460			return;
461		}
462		var order_id = cs_sessionid;
463
464		console.log("metodo=" + metodo + " order#=" + order_id);
465		console.log("entrou place_order card=" + card + " nome=" + card_holder);
466		console.log("installments=" + card_installments);
467		console.log("doc=" + cpf + " docpix=" + document_pix + " doc_bol=" + document_boleto);
468
469		var dados_ajax = {
470			metodo: metodo,
471			order: order_id,
472			card: card,
473			card_holder: card_holder,
474			cpf: cpf,
475			validate: validate,
476			installments: card_installments,
477			doc_boleto: document_boleto,
478			doc_debito: document_debit,
479			doc_pix: document_pix
480		};
481
482		var dados_envio = {
483			'clearsale_total_ajax_nonce': js_global.clearsale_total_ajax_nonce,
484 			'pagseguro': dados_ajax,
485			'action': 'clearsale_total_push'
486      		};
487
488		jQuery.ajax({
489			url: js_global.xhr_url,
490			type: 'POST',
491			data: dados_envio,
492			dataType: 'JSON',
493			success: function(response) {
494				if (response == '401'  ){
495					console.log('Requisição inválida!')
496				}
497				else if (response == 402) {
498					console.log('Todos os posts já foram mostrados!')
499				} else {
500					console.log('Resposta=' + response)
501				}
502			}
503		});
504
505
506
507	});
508
509});
510//-------
511
512
513})( jQuery );
514

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.