1jQuery(document).ready(function($) { 2 3 var cf7pp_formid; 4 var cf7pp_id_long; 5 var cf7pp_pub_key; 6 var cf7pp_amount_total; 7 var cf7pp_stripe_return; 8 var cf7pp_tags_id; 9 var cf7pp_input_id; 10 var cf7pp_payment_id; 11 12 13 14 15 // for redirect method 1 16 document.addEventListener('wpcf7mailsent', function( event ) { 17 18 if (ajax_object_cf7pp.method == 1) { 19 20 var cf7pp_id_long = event.detail.unitTag; 21 var cf7pp_id = event.detail.contactFormId; 22 23 var cf7pp_formid = cf7pp_id; 24 25 cf7pp_redirect(cf7pp_formid, cf7pp_id_long); 26 } 27 28 }, false ); 29 30 31 32 33 34 35 36 37 // for redirect method 2 38 if (ajax_object_cf7pp.method == 2) { 39 var cf7pp_form_counter = 0; 40 jQuery('.wpcf7-form').bind('DOMSubtreeModified', function(e) { 41 if (cf7pp_form_counter == 0) { 42 var $form = jQuery(this); 43 var interval = setInterval(function(){ 44 if ($form.hasClass('sent')) { 45 clearInterval(interval); 46 47 // get form id 48 var cf7pp_id = $form.parent().attr('id').substring(7); 49 50 cf7pp_id = cf7pp_id.split('-')[0]; 51 52 var cf7pp_id_long = $form.parent().attr('id'); 53 54 cf7pp_redirect(cf7pp_id, cf7pp_id_long); 55 cf7pp_form_counter = 1; 56 } 57 }, 500); 58 } 59 }); 60 } 61 62 63 64 // used for redirect method 1 and 2 65 function cf7pp_redirect(cf7pp_id, cf7pp_id_long) { 66 67 var cf7pp_forms = ajax_object_cf7pp.forms; 68 var cf7pp_result_paypal = cf7pp_forms.indexOf(cf7pp_id+'|paypal'); 69 var cf7pp_result_stripe = cf7pp_forms.indexOf(cf7pp_id+'|stripe'); 70 71 72 var cf7pp_gateway; 73 74 var cf7pp_data = { 75 'action': 'cf7pp_get_form_post', 76 }; 77 78 jQuery.ajax({ 79 type: "GET", 80 data: cf7pp_data, 81 dataType: "json", 82 async: false, 83 url: ajax_object_cf7pp.ajax_url, 84 xhrFields: { 85 withCredentials: true 86 }, 87 success: function (response) { 88 cf7pp_gateway = response.gateway; 89 cf7pp_skip = response.skip; 90 cf7pp_pub_key = response.pub_key; 91 cf7pp_amount_total = response.amount_total; 92 cf7pp_stripe_return = response.stripe_return; 93 cf7pp_tags_id = response.tags_id; 94 cf7pp_input_id = response.input_id; 95 cf7pp_payment_id = response.payment_id; 96 } 97 }); 98 99 100 var cf7pp_paypal_path = ajax_object_cf7pp.path_paypal+cf7pp_id+'&cf7pp_t='+cf7pp_tags_id+'&cf7pp_i='+cf7pp_input_id+'&cf7pp_p='+cf7pp_payment_id; 101 var cf7pp_stripe_path = ajax_object_cf7pp.path_stripe+cf7pp_id+'&cf7pp_t='+cf7pp_tags_id+'&cf7pp_i='+cf7pp_input_id+'&cf7pp_p='+cf7pp_payment_id+'&cf7pp_fid='+cf7pp_id_long+'&cf7pp_return='+window.location.href; 102 103 104 // skip redirect for 0.00 amounts 105 if (cf7pp_skip != '1') { 106 107 108 // gateway chooser 109 if (cf7pp_gateway != null) { 110 // paypal 111 if (cf7pp_result_paypal > -1 && cf7pp_gateway == 'paypal') { 112 window.location.href = cf7pp_paypal_path; 113 } 114 115 // stripe 116 if (cf7pp_result_stripe > -1 && cf7pp_gateway == 'stripe') { 117 window.location.href = cf7pp_stripe_path; 118 } 119 } else { 120 // no gateway chooser 121 if (cf7pp_result_paypal > -1) { 122 window.location.href = cf7pp_paypal_path; 123 } 124 125 // stripe 126 if (cf7pp_result_stripe > -1) { 127 window.location.href = cf7pp_stripe_path; 128 } 129 } 130 } 131 132 }; 133 134 135 // show stripe success message 136 let searchParams = new URLSearchParams(window.location.search) 137 138 if (searchParams.has('cf7pp_stripe_success')) { 139 140 let fid = searchParams.get('cf7pp_fid'); 141 let tags_id = searchParams.get('cf7pp_tags_id'); 142 let success_url = searchParams.get('cf7pp_success'); 143 let redirect = searchParams.get('cf7pp_redirect'); 144 145 if (redirect == '1') { 146 window.location.href = success_url; 147 } else { 148 149 var cf7pp_data = { 150 'action': 'cf7pp_get_form_stripe_success', 151 'cf7pp_tags_id': tags_id, 152 'cf7pp_success': success_url, 153 'cf7pp_redirect': redirect, 154 }; 155 156 jQuery.ajax({ 157 type: "POST", 158 data: cf7pp_data, 159 dataType: "json", 160 async: false, 161 url: ajax_object_cf7pp.ajax_url, 162 xhrFields: { 163 withCredentials: true 164 }, 165 success: function (response) { 166 var html_response = response.html; 167 168 jQuery('#'+fid).html(html_response); 169 170 } 171 }); 172 173 } 174 175 } 176 177 178 179});
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.