Changeset 2066586
- Timestamp:
- 04/10/2019 01:39:49 PM (7 years ago)
- Location:
- ipag-woocommerce/trunk
- Files:
-
- 2 edited
-
classes/ipag-gateway-credito.php (modified) (14 diffs)
-
ipag-gateway.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ipag-woocommerce/trunk/classes/ipag-gateway-credito.php
r2061198 r2066586 384 384 } 385 385 callPagSeguroCard = function() { 386 387 386 var session = "<?php echo $this->pagsegurosession($this->pagseguro_email, $this->pagseguro_token, $this->pagseguro_ambiente); ?>"; 387 388 388 var cid = $j('#ipag_cc_cvv').val(); 389 389 var number = $j('#cc_num').val(); 390 390 number = number.replace(/\D/g ,""); 391 var expiry = $j('#ipag_cc_expiry').val().split("/"); 392 var month = expiry[0]; 393 394 var year = expiry[1]; 391 var expiry_date = $j('#ipag_cc_expiry').val(); 392 var month = expiry_date.split("/")[0]; 393 var year = expiry_date.split("/")[1]; 394 var data = new Date(); 395 var ano = ""+data.getFullYear(); 396 year = ano.substring(0,2) + year; 395 397 var type = $j('#card_type').val(); 396 397 398 var idToken = $j('#cartao_tokenpagseguro'); 398 399 … … 405 406 406 407 validaPagSeguroCartao = function() { 407 408 408 var cid = $j('#ipag_cc_cvv').val(); 409 409 var number = $j('#cc_num').val(); 410 var expiry = $j('#ipag_cc_expiry').val().split("/"); 411 var month = expiry[0]; 412 var year = expiry[1]; 410 var expiry_date = $j('#ipag_cc_expiry').val(); 411 var month = expiry_date.split("/")[0]; 412 var year = expiry_date.split("/")[1]; 413 var data = new Date(); 414 var ano = ""+data.getFullYear(); 415 year = ano.substring(0,2) + year; 413 416 var type = $j('#card_type').val(); 414 415 416 417 418 417 if(checkLength(cid,2) && checkLength(number.trim(),10) && checkLength(month,0) && checkLength(year,0) && checkLength(cid,2)){ 419 420 418 callPagSeguroCard(); 421 422 419 } 423 420 } … … 426 423 $j('#ipag_cc_cvv').keyup(function(){validaPagSeguroCartao()}); 427 424 $j('#cc_num').keyup(function(){validaPagSeguroCartao()}); 428 $j('#ipag_cc_venc_month').change(function(){validaPagSeguroCartao()}); 429 $j('#ipag_cc_venc_year').change(function(){validaPagSeguroCartao()}); 425 $j('#ipag_cc_expiry').keyup(function(){validaPagSeguroCartao()}); 430 426 }); 431 427 … … 440 436 expirationYear: year, 441 437 success: function(callback) { 442 console.log(callback); 438 443 439 }, 444 440 error: function(callback) { … … 499 495 </p> 500 496 <p class="form-row"> 501 <label for="ipag_cc_ name"><?php _e('Validade do Cartão', 'ipag-gateway');?> <abbr class="required" title="Digite exatamente o nome escrito na frente do cartão">*</abbr></label>502 <input type="tel" name="ipag_cc_expiry" id="ipag_cc_expiry" class="input-text half-fill" placeholder="<?php _e('MM / YYYY', 'ipag-woocommerce');?>" autocomplete="off" style="font-size: 1.5em; padding: 8px;" />497 <label for="ipag_cc_expiry"><?php _e('Validade do Cartão (Formato MM/AA)', 'ipag-gateway');?> <abbr class="required" title="Digite exatamente o nome escrito na frente do cartão">*</abbr></label> 498 <input type="tel" name="ipag_cc_expiry" id="ipag_cc_expiry" class="input-text half-fill" placeholder="<?php _e('MM / AA', 'ipag-woocommerce');?>" autocomplete="off" style="font-size: 1.5em; padding: 8px;" /> 503 499 </p> 504 500 … … 528 524 <script> 529 525 function ipagSelecionaBandeiraCredito(elem,cvvId,cardtype){ 530 console.log('setting card type');531 526 document.getElementById('card_type').value = elem.id; 532 527 document.getElementById(cvvId).value = ''; … … 600 595 601 596 jQuery(document).ready(function(){ 602 jQuery('#ipag_cc_expiry').mask('00/00 00');597 jQuery('#ipag_cc_expiry').mask('00/00'); 603 598 var cc_num = document.querySelector('#cc_num'); 599 var expiry_date = document.querySelector('#ipag_cc_expiry'); 600 expiry_date.onblur = function(e){ 601 602 if(this.value.length==5) 603 { 604 605 var splittedval = this.value.split('/'); 606 607 if(splittedval[0]<1 || splittedval[0]>12 ) 608 { 609 610 this.value = ''; 611 612 } 613 } else { 614 this.value = ''; } 615 } 604 616 605 617 cc_num.onkeyup = function (e) { … … 632 644 public function expiryMesValido($mes, $ano) 633 645 { 646 $ano = substr(date('Y'), 0, 2).$ano; 634 647 if (strlen($mes) == 2) { 635 648 $intMes = intval($mes); … … 657 670 { 658 671 $valid = false; 672 $ano = substr(date('Y'), 0, 2).$ano; 659 673 660 674 if (strlen($ano) == 4) { … … 746 760 $mes = date('m'); 747 761 $ano2d = preg_replace('/^[\d]{2}/', '', $ano); 748 $cc_val_ano2d = preg_replace('/^[\d]{2}/', '', $cc_val_ano); 762 749 763 $anovalid1 = true; 750 if ($cc_val_ano 2d< $ano2d) {764 if ($cc_val_ano < $ano2d) { 751 765 $anovalid1 = false; 752 766 } 753 if ($cc_val_ano == $ano && $cc_val_mes < $mes) {767 if ($cc_val_ano == $ano2d && $cc_val_mes < $mes) { 754 768 $anovalid1 = false; 755 769 } … … 757 771 $cardTokenPS = (isset($_POST['cartao_tokenpagseguro'])) ? $_POST['cartao_tokenpagseguro'] : ''; 758 772 759 $this->writeLog('fingerprint PagSeguro Cartão '.print_r($fingerprintPS, true)); 760 if ($this->pagseguro_habilitado) { 773 if ($this->pagseguro_habilitado == 'yes') { 774 775 $this->writeLog('Hash PagSeguro Cartão '.print_r($_POST['cartao_hashpagseguro'], true)); 776 $this->writeLog('Token PagSeguro Cartão '.print_r($_POST['cartao_tokenpagseguro'], true)); 761 777 //check pagseguro enabled 762 if (!isset($_POST['cartao_hashpagseguro']) || !isset($_POST['cartao_tokenpagseguro'])) { 763 $error_message = __(' Erro ao processar pagamento PagSeguro, entre em contato com o lojista!', 'ipag-gateway'); 778 if (empty($_POST['cartao_hashpagseguro']) || empty($_POST['cartao_tokenpagseguro'])) { 779 $this->writeLog('Erro: Recuperação do token PagSeguro. '); 780 $error_message = __(' Não foi possível processar o cartão. Verifique os dados do cartão!', 'ipag-gateway'); 764 781 wc_add_notice(__('Payment error:', 'ipag-gateway').$error_message, 'error'); 765 782 $fingerprintPS = ''; … … 775 792 } 776 793 777 if (in_array($cc_metodo, $this->accepted_cards) && $this->cartaoValido($cc_numero) && !empty($cc_nome) && strlen($cc_cvv) > 2 && !empty($cc_numero) && $anovalid1 ) {794 if (in_array($cc_metodo, $this->accepted_cards) && $this->cartaoValido($cc_numero) && !empty($cc_nome) && strlen($cc_cvv) > 2 && !empty($cc_numero) && $anovalid1 && $this->expiryMesValido($cc_val_mes, $cc_val_ano)) { 778 795 779 796 $payload = array( … … 790 807 'cvv_cartao' => $cc_cvv, 791 808 'mes_cartao' => $cc_val_mes, 792 'ano_cartao' => preg_replace('/^[\d]{2}/', '', $cc_val_ano),809 'ano_cartao' => $cc_val_ano, 793 810 'cpf_cartao' => $cc_cpf, 794 811 'nome' => $args['billingName'], … … 870 887 $error_message = __(' Invalid credit card. Please choose another one!', 'ipag-gateway'); 871 888 wc_add_notice(__('Payment error:', 'ipag-gateway').$error_message, 'error'); 872 } elseif (!$anovalid1 ) {889 } elseif (!$anovalid1 || !$this->expiryMesValido($cc_val_mes, $cc_val_ano)) { 873 890 $error_message = __(' Validade do cartão expirada! ', 'ipag-gateway'); 874 891 wc_add_notice(__('Payment error:', 'ipag-gateway').$error_message, 'error'); -
ipag-woocommerce/trunk/ipag-gateway.php
r2052892 r2066586 38 38 add_action('woocommerce_order_details_after_order_table', array('WC_Gateway_iPag_Boleto', 'pending_payment_message'), 5); 39 39 add_action('woocommerce_order_details_after_order_table', array('WC_Gateway_iPag_ItauShopline', 'pending_payment_message'), 5); 40 add_action('woocommerce_before_checkout_form', array('WC_iPag_Loader', 'reset_session')); 40 41 41 42 if (is_admin()) { … … 101 102 102 103 $sql = "CREATE TABLE IF NOT EXISTS $table_name ( 103 id INT(11) NOT NULL AUTO_INCREMENT,104 order_id INT(11) NOT NULL,105 trans_id VARCHAR(128) NOT NULL,106 status INT(11) NOT NULL,107 payment_date DATE NOT NULL,108 PRIMARY KEY pkipag_id (id)109 ) $collate;";104 id INT(11) NOT NULL AUTO_INCREMENT, 105 order_id INT(11) NOT NULL, 106 trans_id VARCHAR(128) NOT NULL, 107 status INT(11) NOT NULL, 108 payment_date DATE NOT NULL, 109 PRIMARY KEY pkipag_id (id) 110 ) $collate;"; 110 111 111 112 $wpdb->query($sql);
Note: See TracChangeset
for help on using the changeset viewer.