1(function($){ 2 $( document ).ready( 3 function(){ 4 $( "#place_order" ).on( 5 'click', 6 function(e){ 7 var zipMoneyErrorDiv = $( "#zipMoneyErrorDiv" ); 8 var zipMoneyInfoDiv = $( "#zipMoneyInfoDiv" ); 9 zipMoneyErrorDiv.hide(); 10 zipMoneyInfoDiv.hide(); 11 12 var paymentMethod = $( 'form[name="checkout"] input[name="payment_method"]:checked' ).val(); 13 14 var checkoutId = null; // log the checkoutId. if the user close the iframe, it will make an ajax call to remove the record in 15 16 if (paymentMethod == "zipmoney") { 17 18 Zip.Checkout.init( 19 { 20 redirect: "<?php echo $is_iframe_checkout ? 0 : 1?>", 21 checkoutUri: "<?php echo WC_Zipmoney_Payment_Gateway_Util::get_checkout_endpoint_url();?>", 22 redirectUri: "<?php echo WC_Zipmoney_Payment_Gateway_Util::get_complete_endpoint_url()?>", 23 onCheckout: function(resolve, reject, args) { 24 var errorDiv = $( '#zipMoneyErrorDiv' ); 25 errorDiv.hide(); 26 27 $.ajax( 28 { 29 type: 'POST', 30 url: '<?php echo WC_Zipmoney_Payment_Gateway_Util::get_wc_checkout_url()?>', 31 data: $( 'form.checkout' ).serialize(), 32 dataType: "json", 33 success: function (result) { 34 console.log( "successfully triggered" ); 35 // console.log("test ". result); 36 37 if (result.checkout_id) { 38 checkoutId = result.checkout_id; 39 } 40 41 if (result.redirect_uri) { 42 // if the checkout is successful 43 console.log( "resolved" ); 44 resolve( 45 { 46 data: {redirect_uri: result.redirect_uri} 47 } 48 ); 49 } else { 50 console.log( "reject" ); 51 errorDiv.html( result.messages ); 52 errorDiv.show(); 53 // scroll up to show the error 54 $( "html, body" ).animate( 55 { 56 scrollTop: ( $( 'form.checkout' ).offset().top - 200) 57 }, 58 1000 59 ); 60 reject(); 61 } 62 }, 63 error: function (jqXHR, textStatus, errorThrown) { 64 console.log( 'error triggered' ); 65 // wc_checkout_form.submit_error( '<div class="woocommerce-error">' + errorThrown + '</div>' ); 66 reject(); 67 } 68 } 69 ); 70 }, 71 onComplete: function (response) { 72 console.log( "onComplete is called." ); 73 74 console.log( response ); 75 76 if (response.state === "approved" || response.state === "referred") { 77 // show the redirect block 78 $( "div.zip-overlay" ).css( "display", "block" ); 79 80 location.href = "<?php echo WC_Zipmoney_Payment_Gateway_Util::get_complete_endpoint_url();?>?result=" + 81 response.state + "&checkoutId=" + response.checkoutId; 82 83 // show the over lay 84 } else if ((response.state === "cancelled" || response.state === "declined") && checkoutId) { 85 // clear the wp_options 86 87 $.post( "<?php echo WC_Zipmoney_Payment_Gateway_Util::get_clear_options_url()?>", {checkout_id:checkoutId} ); 88 } 89 }, 90 onError: function(response){ 91 console.log( "onError is called." ); 92 93 console.log( response ); 94 alert( response.message ); 95 } 96 97 } 98 ); 99 100 e.preventDefault(); 101 } 102 } 103 ); 104 $( ".wc-block-components-checkout-place-order-button" ).on( 105 'click', 106 function(e){ 107 var payment_method = $( 'input[name="radio-control-wc-payment-method-options"]:checked' ).val(); 108 // show the over lay 109 if (payment_method == 'zipmoney') { 110 $( 'div.zip-overlay' ).css( 'display', 'block' ); 111 } 112 } 113 ); 114 115 } 116 ); 117 118})( window.jQuery || window.$ );
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.