PageSourceSearch

https://www.geekompc.com/wp-content/cache/min/1/wp-content/plugins…/legacy/paypal-minicart.js?ver=1789992593

js geekompc.com collected 2026-09-24 22:06:27 UTC 12,093 bytes, 1 lines download raw bytes

1(()=>{"use strict";var e={n:t=>{var i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},d:(t,i)=>{for(var n in i)e.o(i,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.jQuery;var i=e.n(t);const n=window.wp.apiFetch;var s=e.n(n);const a=window.wp.hooks,r=window.wcPPCP.utils,o=window.lodash,l=class{constructor({id:e,context:t,actions:i,container:n=null}){this.id=e,this.actions=i,this.buttons={},this.buttonActions={},this.context=t,this.settings=(0,r.getSetting)(`${e}_data`),this.container=n||`li.payment_method_${e}`,this.order_field_key=`${this.id}_paypal_order_id`,this.billing_token_key=`${this.id}_billing_token`}initialize(){this.loadPayPalScript().then(()=>{this.initializeEvents(),this.createButton()})}initializeEvents(){}isActive(){return null!==this.getData()}loadPayPalScript(){return new Promise((e,t)=>{(0,r.loadPayPalSdk)(this.getPayPalSDKArgs()).then(t=>{this.paypal=t,e()}).catch(e=>{console.log(e),e?.code&&this.submitError((0,r.getErrorMessage)(e)),t()})})}getPayPalSDKArgs(){return(0,r.getPayPalQueryParams)()}getClientId(){let{clientId:e=null,environment:t}=(0,r.getSetting)("generalData");return e||"sandbox"!=t||(e="sb"),e}getData(){return i()(`${this.container}`).find(".wc-ppcp-payment-method-data").data("payment-method-data")||null}setData(e){i()(`${this.container}`).find(".wc-ppcp-payment-method-data").data("payment-method-data",e)}setOption(e,t){const i=this.getData();i&&(i[e]=t,this.setData(i))}setVariable(e,t){(0,r.getSetting)(`${this.id}_data`)[e]=t}getVariable(e,t=null){const i=(0,r.getSetting)(`${this.id}_data`);return i.hasOwnProperty(e)?i[e]:(t&&this.setVariable(e,t),t)}getOption(e,t=null){const i=this.getData();return i.hasOwnProperty(e)?i[e]:(t&&this.setOption(e,t),t)}createButton(){const e=this.getButtonContainer();e&&!i()(e).find(".paypal-buttons").length&&(this.getSortedFunding(this.getFunding()).forEach(t=>{const i=this.paypal.Buttons(this.getButtonOptions(t));if(this.buttons[t]=i,i.isEligible())if(e instanceof NodeList)for(const t of e)i.render(t);else i.render(e)}),this.$button=i()(e),a.defaultHooks.doAction("wcPPCPButtonCreated",this))}getButton(){return this.$button}destroyButtons(){Object.keys(this.buttons).forEach(e=>{this.buttons[e].close&&this.buttons[e].close()})}disableButtons(){Object.keys(this.buttonActions).forEach(e=>{this.buttonActions[e].disable()})}enableButtons(){Object.keys(this.buttonActions).forEach(e=>{this.buttonActions[e].enable()})}getFunding(){const e=[],t=this.settings?.funding||[];return this.settings?.paypal_sections?.includes(this.getPage())&&e.push(paypal.FUNDING.PAYPAL),t.includes("paylater")&&this.settings?.paylater_sections?.includes(this.getPage())&&this.isCheckoutFlow()&&e.push(paypal.FUNDING.PAYLATER),t.includes("card")&&this.settings?.credit_card_sections?.includes(this.getPage())&&e.push(paypal.FUNDING.CARD),e}isFundingActive(e){return this.settings?.funding?.includes(e)}isSectionEnabled(e,t){const i=`${e}_sections`;return this.settings?.[i]?.includes(t)}getSortedFunding(e){const t=this.settings.buttons_order||[];return e.sort((e,i)=>t.indexOf(e)<t.indexOf(i)?-1:1),e}getButtonContainer(){return null}getButtonOptions(e){const t={fundingSource:e,style:this.getButtonStyle(e),onInit:(...t)=>{this.onInit(e,...t),i()(document.body).triggerHandler("wc_ppcp_on_init",[this,e])},onClick:(...t)=>{this.onClick(...t),i()(document.body).triggerHandler("wc_ppcp_on_click",[this,e])},onApprove:(t,n)=>{this.onApprove(t,n),i()(document.body).triggerHandler("wc_ppcp_on_approve",[this,e])},onCancel:t=>{this.orderId=t.orderID,i()(document.body).triggerHandler("wc_ppcp_on_cancel",[this,e,t])},onError:t=>{this.currentError?(this.submitError(this.currentError),this.currentError=null):this.submitError(t),i()(document.body).triggerHandler("wc_ppcp_on_error",[this,e,t])},onDestroy:()=>{i()(document.body).triggerHandler("wc_ppcp_on_destroy",[this,e])}};return this.isCheckoutFlow()?(t.createOrder=(e,t)=>this.createOrder(e,t),this.needsShipping()&&e!==paypal.FUNDING.VENMO&&!this.settings.serverSideShippingCallback&&(t.onShippingChange=(...e)=>this.onShippingChange(...e))):t.createBillingAgreement=(...e)=>this.createBillingAgreement(...e),t}needsShipping(){return this.getOption("needsShipping",!1)}isCheckoutFlow(){return"true"!==(0,r.getPayPalQueryParams)()?.vault}getTotal(){return this.getOption("total",0)}getButtonStyle(e){let t=null;switch(e){case paypal.FUNDING.PAYPAL:t=this.settings?.buttons?.payp
1al;break;case paypal.FUNDING.PAYLATER:t=this.settings?.buttons?.paylater;break;case paypal.FUNDING.CARD:t={...this.settings?.buttons?.card},t.tagline?(delete t.tagline,t.layout="vertical"):t.layout="horizontal";break;case paypal.FUNDING.VENMO:const{color:e="",label:i="",...n}=this.settings?.buttons?.paypal;t=n}return t?.height&&(t.height=parseInt(t.height)),t}onApprove(e,t){if((0,r.setFieldValue)(this.order_field_key,e.orderID,""),e.billingToken)return(0,r.setFieldValue)(this.billing_token_key,e.billingToken,""),this.fetchBillingToken(e.billingToken).then(t=>{this.handleBillingToken(t,e)}).catch(e=>this.submitError(e?.message));t.order.get().then(t=>{this.handleOnApproveResponse(e,t)}).catch(e=>this.submitError(e))}handleOnApproveResponse(e,t){this.populateCheckoutFields(t),this.processCartCheckout()}fetchBillingToken(e){return s()({method:"GET",path:`/wc-ppcp/v1/billing-agreement/token/${e}`})}handleBillingToken(e,t){if((0,o.isEmpty)(e.payer_info.billing_address)||this.populateBillingAddressFields((0,r.convertPayPalAddressToCart)(e.payer_info.billing_address)),e?.payer_info?.first_name&&((0,r.isValid)("billing_first_name")||(0,r.setFieldValue)("first_name",e.payer_info.first_name,"billing")),e?.payer_info?.last_name&&((0,r.isValid)("billing_last_name")||(0,r.setFieldValue)("last_name",e.payer_info.last_name,"billing")),e?.payer_info?.email&&((0,r.isValid)("billing_email")||(0,r.setFieldValue)("billing_email",e.payer_info.email)),e?.payer_info?.phone&&((0,r.isValid)("billing_phone")||(0,r.setFieldValue)("billing_phone",e.payer_info.phone)),this.needsShipping()&&e.shipping_address&&!(0,o.isEmpty)(e.shipping_address)){var i;let t=(0,r.convertPayPalAddressToCart)(e.shipping_address);var n;if(this.populateNameFields((0,r.extractFullName)(null!==(i=e.shipping_address.recipient_name)&&void 0!==i?i:""),"shipping"),this.populateShippingAddressFields(t),!(0,r.isValidAddress)(this.getCartFullAddress("billing"),["phone","email"]))(0,r.isValidFieldValue)((0,r.getFieldValue)("billing_first_name"))||(0,r.isValidFieldValue)((0,r.getFieldValue)("billing_last_name"))||this.populateNameFields(null!==(n=e.shipping_address.recipient_name)&&void 0!==n?n:"","billing"),this.populateBillingAddressFields(t)}}createOrder(e,t){return t.order.create(args)}async createBillingAgreement(e,t,i=null){return s()({method:"POST",url:(0,r.getRestPath)("/wc-ppcp/v1/billing-agreement/token"),data:await this.actions.applyFiltersAsync("create_billing_agreement_data",{payment_method:this.id,c
1ontext:this.getPage(),...i})}).then(e=>e).catch(e=>{this.currentError=e})}onShippingChange(e,t,i={}){const n=(0,r.convertPayPalAddressToCart)(e?.shipping_address||{},!0),a=e?.selected_shipping_option?.id||"";return s()({method:"POST",url:(0,r.getRestRoute)("cart/shipping"),data:{order_id:e.orderID,address:n,shipping_method:a,payment_method:this.id,...i}}).then(e=>e.code?t.reject():t.resolve()).catch(e=>t.reject())}submitError(e){}getShippingPrefix(){return"shipping"}getCartAddress(e){return{address_1:(0,r.getFieldValue)("address_1",e),address_2:(0,r.getFieldValue)("address_2",e),state:(0,r.getFieldValue)("state",e),city:(0,r.getFieldValue)("city",e),postcode:(0,r.getFieldValue)("postcode",e),country:(0,r.getFieldValue)("country",e)}}getCartFullAddress(e){return{first_name:(0,r.getFieldValue)("first_name",e),last_name:(0,r.getFieldValue)("last_name",e),address_1:(0,r.getFieldValue)("address_1",e),address_2:(0,r.getFieldValue)("address_2",e),state:(0,r.getFieldValue)("state",e),city:(0,r.getFieldValue)("city",e),postcode:(0,r.getFieldValue)("postcode",e),country:(0,r.getFieldValue)("country",e)}}onInit(e,t,i){this.buttonActions[e]=i}onClick(e,t){}isPage(e){return this.getPage()===e}getPage(){let e=(0,r.getSetting)("generalData")?.page;return"cart"==e&&i()(document.body).is(".woocommerce-checkout")&&(e="checkout"),e}populateShippingAddressFields(e){for(let t in e)(0,r.setFieldValue)(t,e[t],"shipping")}populateBillingAddressFields(e){for(let t in e)(0,r.setFieldValue)(t,e[t],"billing")}populateNameFields(e,t=""){let i,n;Array.isArray(e)?[i,n]=e:({given_name:i,surname:n}=e),(0,r.setFieldValue)("first_name",i,t),(0,r.setFieldValue)("last_name",n,t)}populateCheckoutFields(e){if(!(0,o.isEmpty)(e?.payer?.address)){let t=(0,r.convertPayPalAddressToCart)(e.payer.address);this.populateBillingAddressFields(t)}if(e?.payer?.name&&this.populateNameFields(e.payer.name,"billing"),e?.payer?.email_address&&(0,r.setFieldValue)("billing_email",e.payer.email_address),e?.payer?.phone?.phone_number?.national_number&&((0,r.setFieldValue)("billing_phone",e.payer.phone.phone_number.national_number),(0,r.setFieldValue)("shipping_phone",e.payer.phone.phone_number.national_number)),this.needsShipping()&&e?.purchase_units?.[0]?.shipping){const t=(0,r.convertPayPalAddressToCart)(e.purchase_units[0].shipping.address);if(this.populateShippingAddressFields(t),e.purchase_units[0].shipping?.name?.full_name){const t=(0,r.extractFullName)(e.purchase_units[0].shipping.name.full_name);this.populateNameFields(t,"shipping")}(0,r.isValidAddress)(this.getCartFullAddress("billing"),["phone","email"])||this.populateBillingAddressFields(t)}}processCartCheckout(){return this.showProcessing(),s()({method:"POST",url:(0,r.getRestRoute)("cart/checkout"),data:this.getCartCheckoutData()}).then(e=>{if(e.result&&"success"==e.result)window.location=e.redirect;else if(e.messages)return this.submitError(e.messages)}).catch(e=>{e.code&&this.submitError(e.message)})}
1getCartCheckoutData(){return{payment_method:this.id,context:this.getPage(),...(0,r.fieldsToJson)()}}getProcessingSelector(){return"body"}showProcessing(){i()(this.getProcessingSelector())?.block({message:this.getProcessingMessage(),overlayCSS:{background:"#fff",opacity:.6}})}hideProcessing(){i()(this.getProcessingSelector())?.unblock()}getProcessingMessage(){return'<div class="wc-ppcp-loader">\n                        <div></div>\n                        <div></div>\n                        <div></div>\n                      </div>'}getFullName(e){const t=[(0,r.getFieldValue)("first_name",e),(0,r.getFieldValue)("last_name",e)].filter(Boolean);return 0==t.length?null:1==t.length?t[0]:`${t[0]} ${t[1]}`}};class d extends l{constructor(e,t){super(t),this.cart=e,this.retryCount=0,this.initialize()}initialize(){this.actions.addAction("fragments_changed",this.onFragmentsChanged.bind(this)),this.actions.addAction("mini_cart_ready",this.onMiniCartReady.bind(this)),this.actions.addAction("mini_cart_updated",this.onMiniCartReady.bind(this)),i()(document.body).on("wc_ppcp_on_destroy",this.createButton.bind(this)),super.initialize()}onMiniCartReady(){this.createButton(),i()(this.getButtonContainer()).show()}needsShipping(){return this.cart.needsShipping()}createButton(){if(!this.getButtonContainer()&&this.retryCount<10)return this.retryCount+=1,setTimeout(this.createButton.bind(this),500);super.createButton()}getButtonContainer(){const e=document.querySelectorAll(`.wc-ppcp-minicart-${this.id}`);return e&&e.length>0?e:(i()(".woocommerce-mini-cart__buttons").append(`<a id="wc-ppcp-minicart-${this.id}"></a>`),document.getElementById(`wc-ppcp-minicart-${this.id}`))}getPage(){return"minicart"}handleBillingToken(e){super.handleBillingToken(e),this.processCartCheckout()}createOrder(e,t){return this.cart.createOrder({payment_method:this.id}).then(e=>e)}onFragmentsChanged(){this.cart.isEmpty()||super.initialize()}}const h=window.wcPPCP.cart;var p=e.n(h);const c=window.wcPPCP.actions;var u=e.n(c);new class extends d{}(p(),{id:"ppcp",actions:new(u()),context:"cart"}),(this.wcPPCP=this.wcPPCP||{}).paypalMinicart={}})()

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.