@@ -24,20 +24,25 @@ function pay(args, checkout, form) {
2424 data : {
2525 action : 'setTransactionId' ,
2626 id : r . transaction . id
27- }
28- } ) . done ( function ( r ) {
29- if ( r . err ) {
30- return 0 ;
31- }
32- if ( checkout ) {
33- checkout . checkAllErrors ( ) ;
34- } else {
35- /* Remove form submit event which prevent form action to proceed */
36- /* Set form action attribute */
37- /* Force submit form */
38- $ ( form ) . off ( 'submit' , submitForm ) . attr ( "action" , $ ( form ) . find ( "#payLikeCheckout" ) . attr ( "action" ) ) . submit ( ) ;
27+ } ,
28+ error : function ( jqXHR , textStatus , errorThrown ) {
29+ if ( errorThrown ) {
30+ console . error ( errorThrown ) ;
31+ return 0 ;
32+ }
33+ } ,
34+ success : function ( data , textStatus , jqXH ) {
35+ if ( checkout ) {
36+ checkout . checkAllErrors ( ) ;
37+ } else {
38+ /* Remove form submit event which prevent form action to proceed */
39+ /* Set form action attribute */
40+ /* Force submit form */
41+ $ ( form ) . off ( 'submit' , submitForm ) . attr ( "action" , $ ( form ) . find ( "#payLikeCheckout" ) . attr ( "action" ) ) . submit ( ) ;
42+ }
3943 }
4044 } )
45+
4146 return false ;
4247 } ) ;
4348}
@@ -57,12 +62,14 @@ function submitForm(e) {
5762 url : orderDataPath ,
5863 data : {
5964 action : 'getOrderTotalsData'
65+ } ,
66+ error : function ( jqXHR , textStatus , errorThrown ) {
67+ console . error ( errorThrown ) ;
68+ } ,
69+ success : function ( data , textStatus , jqXHR ) {
70+ var checkoutObj = ( typeof checkout === 'undefined' ) ? ( false ) : ( checkout ) ;
71+ pay ( data , checkoutObj , form ) ;
6072 }
61- } ) . done ( function ( r ) {
62- var checkoutObj = typeof checkout === 'undefined'
63- ? false
64- : checkout ;
65- pay ( r , checkoutObj , form ) ;
6673 } )
6774 /* Prevent form action to proceed */
6875 e . preventDefault ( e ) ;
0 commit comments