1var last_request = []; 2(() => { 3 "use strict"; 4 5 var querystring = document.currentScript.src.substring( document.currentScript.src.indexOf("?") ); 6 var urlParams = new URLSearchParams( querystring ); 7 const name = urlParams.get('name'); 8 const paymentFieldsUrl = urlParams.get('payment_fields_url'); 9 10 const {registerPaymentMethod} = window.wc.wcBlocksRegistry; 11 const {getPaymentMethodData} = window.wc.wcSettings; 12 const {decodeEntities} = wp.htmlEntities; 13 const {createElement} = window.React; 14 const {checkoutData} = window.wc.wcSettings.allSettings; 15 16 const paymentMethodData = getPaymentMethodData(name); 17 18 class Content extends window.React.Component{ 19 componentDidMount(){ 20 if(this.paymentFields){ 21 jQuery('#div-' + name).html(this.paymentFields) 22 } 23 } 24 25 render(){ 26 this.paymentFields = getPaymentFields(); 27 if(this.paymentFields){ 28 return createElement('div', { 29 id: 'div-' + name 30 }); 31 } 32 return decodeEntities(paymentMethodData.description || ""); 33 } 34 } 35 36 const options = { 37 name: name, 38 label: decodeEntities(paymentMethodData.title || ""), 39 ariaLabel: decodeEntities(paymentMethodData.title || ""), 40 placeOrderButtonLabel: decodeEntities(paymentMethodData.buttonLabel || ""), 41 content: createElement(Content, null), 42 edit: createElement(Content, null), 43 canMakePayment: () => true, 44 supports: { 45 features: paymentMethodData.supports 46 } 47 }; 48 49 registerPaymentMethod(options); 50 51 function getPaymentFields(){ 52 if(!paymentFieldsUrl){ 53 return ""; 54 } 55 const post_data = { 56 order_id: checkoutData.order_id, 57 billing_first_name: checkoutData.billing_address.first_name, 58 billing_last_name: checkoutData.billing_address.last_name, 59 billing_company: checkoutData.billing_address.company, 60 billing_country: checkoutData.billing_address.country, 61 billing_address_1: checkoutData.billing_address.address1, 62 billing_address_2: checkoutData.billing_address.address2, 63 billing_postcode: checkoutData.billing_address.postcode, 64 billing_city: checkoutData.billing_address.city, 65 billing_state: checkoutData.billing_address.state, 66 billing_phone: checkoutData.billing_address.phone, 67 billing_email: checkoutData.billing_address.email, 68 } 69 70 var data = { 71 post_data: new URLSearchParams(post_data).toString() 72 }; 73 74 const full_url = paymentFieldsUrl + "?" + data.post_data; 75 if(!last_request[full_url]){ 76 var jqXHR = jQuery.ajax({ 77 type: 'POST', 78 url: paymentFieldsUrl, 79 data: data, 80 async: false, 81 }); 82 83 last_request[full_url] = jqXHR.status == 200 ? jqXHR.responseText : "" 84 } 85 86 return last_request[full_url]; 87 } 88})();
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.