@@ -92,7 +92,7 @@ define([
92
92
subscribeTotal ( ) {
93
93
const _self = this ;
94
94
95
- this . platformConfig . updateTotals . totals . subscribe ( function ( ) {
95
+ this . platformConfig . updateTotals . totals . subscribe ( function ( ) {
96
96
if ( _self . methodCode === 'twocreditcards' || _self . methodCode === 'boletoCreditcard' ) {
97
97
let totalAmount = 0 ;
98
98
const separator = '.' ;
@@ -373,7 +373,7 @@ define([
373
373
374
374
} ) ;
375
375
376
- formObject . inputAmount . on ( 'keyup' , function ( ) {
376
+ formObject . inputAmount . on ( 'keyup' , function ( ) {
377
377
const element = $ ( this ) ;
378
378
379
379
const originalValue = paymentMethodController . platformConfig . updateTotals . getTotals ( ) ( ) . grand_total ;
@@ -435,10 +435,11 @@ define([
435
435
|| element . attr ( 'name' ) . startsWith ( 'payment[cc_exp_year]' )
436
436
) {
437
437
paymentMethodController . validateCcExpDateField ( formObject ) ;
438
- return ;
438
+
439
439
}
440
440
} ) ;
441
441
}
442
+
442
443
addCreditCardNumberListener ( formObject ) {
443
444
444
445
const paymentMethodController = this ;
@@ -459,8 +460,8 @@ define([
459
460
formObject . creditCardNumber . on ( 'change' , function ( ) {
460
461
const element = $ ( this ) ;
461
462
462
- setTimeout ( function ( ) {
463
- paymentMethodController . setBin ( binObj , element , formObject ) ;
463
+ setTimeout ( function ( ) {
464
+ paymentMethodController . setBin ( binObj , element , formObject ) ;
464
465
} , 300 ) ;
465
466
} ) ;
466
467
}
@@ -481,7 +482,7 @@ define([
481
482
sumTotal = ( sumTotal + sumInterestTotal ) . toString ( ) ;
482
483
sumInterestTotal = sumInterestTotal . toString ( ) ;
483
484
484
- return { sumTotal, sumInterestTotal } ;
485
+ return { sumTotal, sumInterestTotal} ;
485
486
}
486
487
487
488
boletoCreditCardTotal ( paymentMethod ) {
@@ -500,7 +501,7 @@ define([
500
501
}
501
502
sumInterestTotal = sumInterestTotal . toString ( ) ;
502
503
503
- return { sumTotal, sumInterestTotal } ;
504
+ return { sumTotal, sumInterestTotal} ;
504
505
}
505
506
506
507
updateTotalByPaymentMethod ( paymentMethod , event ) {
@@ -557,7 +558,7 @@ define([
557
558
formHandler . init ( formObject ) ;
558
559
559
560
560
- formObject . savedCreditCardSelect . on ( 'change' , function ( ) {
561
+ formObject . savedCreditCardSelect . on ( 'change' , function ( ) {
561
562
const value = $ ( this ) . val ( ) ;
562
563
const currentSavedCardBrand = $ ( this ) . find ( optionSelectedSelector ) . attr ( 'brand' ) ;
563
564
@@ -718,7 +719,7 @@ define([
718
719
url : installmentsUrl ,
719
720
method : 'GET' ,
720
721
cache : true ,
721
- } ) . done ( function ( data ) {
722
+ } ) . done ( function ( data ) {
722
723
formHandler = new FormHandler ( ) ;
723
724
724
725
if ( ! data . length ) return ;
@@ -731,6 +732,7 @@ define([
731
732
formHandler . switchBrand ( selectedBrand ) ;
732
733
} ) ;
733
734
}
735
+
734
736
fillBrandList ( formObject , method ) {
735
737
if ( method == undefined ) {
736
738
method = 'pagarme_creditcard' ;
@@ -751,14 +753,15 @@ define([
751
753
amount = amount . replace ( separator , this . platformConfig . currency . decimalSeparator ) ;
752
754
753
755
if ( card === 1 ) {
754
- const orderAmountOriginal = amount . replace ( this . platformConfig . currency . decimalSeparator , "." ) ;
756
+ const orderAmountOriginal = amount . replace ( this . platformConfig . currency . decimalSeparator , "." ) ;
755
757
const amountBalance = ( this . platformConfig . updateTotals . getTotals ( ) ( ) . grand_total - orderAmountOriginal ) . toFixed ( 2 ) ;
756
758
formObject . inputAmount . val ( amountBalance . replace ( "." , this . platformConfig . currency . decimalSeparator ) ) ;
757
759
return ;
758
760
}
759
761
760
762
formObject . inputAmount . val ( amount ) ;
761
763
}
764
+
762
765
validateCcNumberField ( element , formObject ) {
763
766
if ( element . val ( ) === '' ) {
764
767
formObject . creditCardBrand . val ( '' ) ;
@@ -768,12 +771,14 @@ define([
768
771
formHandler . switchBrand ( '' ) ;
769
772
}
770
773
}
774
+
771
775
validateCcExpDateField ( formObject ) {
772
776
const cardExpirationMonth = formObject . creditCardExpMonth ;
773
777
const cardExpirationYear = formObject . creditCardExpYear ;
774
778
775
- const cardDate = new Date ( cardExpirationYear . val ( ) , cardExpirationMonth . val ( ) - 1 ) ;
776
- const dateNow = new Date ( ) ;
779
+ const cardDate = new Date ( cardExpirationYear . val ( ) , cardExpirationMonth . val ( ) - 1 ) ;
780
+ let dateNow = new Date ( ) ;
781
+ dateNow = new Date ( dateNow . getFullYear ( ) , dateNow . getMonth ( ) ) ;
777
782
778
783
const monthParentsElements = cardExpirationMonth . parent ( ) . parent ( ) ;
779
784
const yearParentsElements = cardExpirationYear . parent ( ) . parent ( ) ;
@@ -817,6 +822,7 @@ define([
817
822
818
823
return false ;
819
824
}
825
+
820
826
setBin ( binObj , creditCardNumberElement , formObject ) {
821
827
822
828
const bin = binObj ;
@@ -838,13 +844,13 @@ define([
838
844
this . fillInstallments ( formObject ) ;
839
845
}
840
846
841
- return ;
847
+
842
848
}
843
849
844
850
limitCharacters ( element , limit ) {
845
851
const val = element . val ( ) ;
846
852
847
- if ( val != "" && val . length > limit ) {
853
+ if ( val != "" && val . length > limit ) {
848
854
element . val ( val . substring ( 0 , limit ) ) ;
849
855
}
850
856
}
0 commit comments