PageSourceSearch

https://chris-auman.com/wp-content/plugins/woocommerce-payments/dist/express-checkout.js?ver=11.2.0

js chris-auman.com collected 2026-10-09 05:16:23 UTC 34,874 bytes, 1 lines download raw bytes

1(()=>{var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var o in a)e.o(a,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:a[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};(()=>{var t;globalThis.importScripts&&(t=globalThis.location+"");var a=globalThis.document;if(!t&&a&&(a.currentScript&&"SCRIPT"===a.currentScript.tagName.toUpperCase()&&(t=a.currentScript.src),!t)){var o=a.getElementsByTagName("script");if(o.length)for(var r=o.length-1;r>-1&&(!t||!/^http(s?):/.test(t));)t=o[r--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=t})(),e.p=window.wcpayAssets.url,(()=>{"use strict";const t=window.wp.i18n,a=window.wp.a11y,o=window.lodash,r=window.wp.hooks,n=e=>"undefined"!=typeof wcpayConfig&&void 0!==wcpayConfig[e]?wcpayConfig[e]:s(e),s=e=>{let t=null;if("undefined"!=typeof wcpay_upe_config)t=wcpay_upe_config;else{if("object"!=typeof wc||void 0===wc.wcSettings)return null;t=wc.wcSettings.getSetting("woocommerce_payments_data")||{}}return t[e]||null},i=e=>"object"==typeof wcpayExpressCheckoutParams&&wcpayExpressCheckoutParams.hasOwnProperty(e)?wcpayExpressCheckoutParams[e]:null;class c{constructor(e,t){this.options=e,this.stripe=null,this.stripePlatform=null,this.request=t}createStripe(e,t,a="",o=[]){const r={locale:t};return a&&(r.stripeAccount=a),o&&(r.betas=o),new Stripe(e,r)}async getStripeForUPE(e){return this.options.forceNetworkSavedCards=s("paymentMethodsConfig")[e].forceNetworkSavedCards,this.getStripe()}async getStripe(e=!1){let t=0;for(;!window.Stripe;)if(await new Promise(e=>setTimeout(e,100)),t+=100,t>6e5)throw new Error("Stripe object not found");return this.__getStripe(e)}__getStripe(e=!1){const{publishableKey:t,accountId:a,forceNetworkSavedCards:o,locale:r,isStripeLinkEnabled:n}=this.options;if(o&&!e)return this.stripePlatform||(this.stripePlatform=this.createStripe(t,r)),this.stripePlatform;if(!this.stripe){let e=["card_country_event_beta_1"];n&&(e=e.concat(["link_autofill_modal_beta_1"])),this.stripe=this.createStripe(t,r,a,e)}return this.stripe}
1async loadStripeForExpressCheckout(){try{return await this.getStripe(!0)}catch(e){return{error:e}}}confirmIntent(e,t=!1){const a=e.match(/#wcpay-confirm-(pi|si):([^:]+):([^:]+):([^:]+)(?::(.+))?$/);if(!a)return!0;const o="si"===a[1],r=a[2],s=a[3],c=a[4],p=a[5]||null;return(async()=>{const{locale:e,publishableKey:t}=this.options,a=n("accountIdForIntentConfirmation");if(o){const e=await this.getStripe(!0);return p?e.confirmSetup({clientSecret:s,confirmParams:{confirmation_token:p},redirect:"if_required"}):e.handleNextAction({clientSecret:s})}return a?this.createStripe(t,e,a).confirmCardPayment(s):(await this.getStripe(!0)).handleNextAction({clientSecret:s})})().then(e=>{let a=null;e.paymentIntent?.last_payment_error&&(a={message:e.paymentIntent.last_payment_error.message}),"requires_action"===e.paymentIntent?.status&&(a={message:"Payment requires additional action."});const o=e.paymentIntent&&e.paymentIntent.id||e.setupIntent&&e.setupIntent.id||e.error&&e.error.payment_intent&&e.error.payment_intent.id||e.error.setup_intent&&e.error.setup_intent.id,s=i("ajax_url")??n("ajaxUrl"),p=n("isChangingPayment");return[this.request(s,{action:"update_order_status",order_id:r,_ajax_nonce:c,intent_id:o,should_save_payment_method:t?"true":"false",is_changing_payment:p?"true":"false"}),a,e.error]}).then(([e,t,a])=>{if(a)throw a;return e.then(e=>{const a="string"==typeof e?JSON.parse(e):e;if(a.error)throw a.error;if(t)throw t;return a.return_url})})}async setupIntent(e,t=""){const a=await this.request(n("ajaxUrl"),{action:"create_setup_intent","wcpay-payment-method":e,_ajax_nonce:n("createSetupIntentNonce"),"wcpay-fraud-prevention-token":window.wcpayFraudPreventionToken??"","wcpay-fingerprint":t});if(!a.success)throw a.data.error;if("succeeded"===a.data.status)return a.data;
1const o=await this.getStripe(),r=await o.confirmCardSetup(a.data.client_secret),{setupIntent:s,error:i}=r;if(i)throw i;return s}expressCheckoutAddToCart(e){const t=n("wcAjaxUrl"),a=n("addToCartNonce");return this.request(((e,t,a="wcpay_")=>e.toString().replace("%%endpoint%%",a+t))(t,"add_to_cart"),{security:a,...e})}}jQuery(e=>{e("input[name=wc_deposit_option],input[name=wc_deposit_payment_plan]").on("change",()=>{(0,r.doAction)("wcpay.express-checkout.update-button-data")})}),(0,r.addFilter)("wcpay.express-checkout.cart-add-item","automattic/wcpay/express-checkout",e=>{const t={};return jQuery("input[name=wc_deposit_option]").length&&(t.wc_deposit_option=jQuery("input[name=wc_deposit_option]:checked").val()),jQuery("input[name=wc_deposit_payment_plan]").length&&(t.wc_deposit_payment_plan=jQuery("input[name=wc_deposit_payment_plan]:checked").val()),{...e,...t}});const p="wcpay-express-checkout__order-attribution-inputs",u=()=>{(()=>{if(document.getElementById(p))return;const e=document.createElement("wc-order-attribution-inputs");e.id=p,document.body.appendChild(e)})(),window?.wc_order_attribution?.setOrderTracking(window?.wc_order_attribution?.params?.allowTracking)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",u):u(),(0,r.addFilter)("wcpay.express-checkout.cart-place-order-extension-data","automattic/wcpay/express-checkout",e=>{const t=jQuery("#wcpay-express-checkout__order-attribution-inputs input");if(!t.length)return e;const a={};return t.each(function(){const e=jQuery(this).attr("name").replace("wc_order_attribution_",""),t=jQuery(this).val();e&&t&&(a[e]=t)}),{...e,"woocommerce/order-attribution":a}});let l=null,d=null;const m=()=>jQuery(d),y={init:({elementId:e,$separator:t})=>{d=e,l=t},getButtonSeparator:()=>l,isBlocked:()=>!!m().data("blockUI.isBlocked"),blockButton:()=>{y.isBlocked()||m().attr("aria-busy","true").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:()=>{m().removeAttr("aria-busy").unblock()},unblockButton:()=>{y.showContainer(),y.unblock()},renderButton:e=>{m()?.length&&e.mount(d)},hideContainer:()=>{m().removeClass("is-ready").hide()},showContainer:()=>{m().addClass("is-ready").show()}},_=y,h=(e,t,a=!1)=>{let o;return function(){const r=this,n=arguments,s=a&&!o;clearTimeout(o),o=setTimeout(()=>{o=null,a||t.apply(r,n)},e),s&&t.apply(r,n)}},w=e=>void 0!==window.wcpayExpressCheckoutParams?window.wcpayExpressCheckoutParams[e]??null:void 0!==window.wc?.wcSettings?window.wc.wcSettings.getSetting("ece_data")?.[e]??null:null,g=()=>document.querySelector(".single_add_to_cart_button")||document.querySelector('.wp-block-add-to-cart-with-options button[type="submit"]'),f=()=>{const e=document.querySelector(".single_add_to_cart_button");if(e?.value)return e.value;const t=document.querySelector('form.cart input[name="product_id"]');if(t?.value)return t.value;const a=document.querySelector('.wp-block-add-to-cart-with-options input[name="add-to-cart"]');return a?.value},b=()=>{const e=document.querySelector(".quantity .qty");return e&&parseFloat(e.value)||1},k=()=>!!document.querySelector(".wp-block-add-to-cart-with-options"),x=()=>document.querySelectorAll(".wp-block-add-to-cart-with-options .wp-block-woocommerce-a
1dd-to-cart-with-options-variation-selector-attribute"),v=()=>{const e=[];return x().forEach(t=>{let a;try{a=JSON.parse(t.dataset.wpContext)?.name}catch(e){a=void 0}if(!a)return;const o=t.querySelector("select"),r=o?o.value:t.querySelector('[aria-checked="true"]')?.value;r&&e.push({attribute:a,value:r})}),e},S=()=>{if(k()){const e=document.querySelector(".wp-block-add-to-cart-with-options");return!!e&&e.classList.contains("is-invalid")}const e=g();return!!e&&e.classList.contains("disabled")};jQuery(e=>{e(document.body).on("woocommerce_variation_has_changed",async()=>{(0,r.doAction)("wcpay.express-checkout.update-button-data")});const t=x();if(t.length){let e=null;const a=new MutationObserver(h(250,()=>{const t=JSON.stringify(v());t!==e&&(e=t,(0,r.doAction)("wcpay.express-checkout.update-button-data"))}));t.forEach(e=>a.observe(e,{subtree:!0,childList:!0,attributes:!0}))}}),jQuery(e=>{if("product"!==w("button_context"))return;const t=e(".quantity");t.on("input",".qty",()=>{_.blockButton()}),t.on("input",".qty",h(250,async()=>{(0,r.doAction)("wcpay.express-checkout.update-button-data")}))}),(0,r.addFilter)("wcpay.express-checkout.cart-add-item","automattic/wcpay/express-checkout",e=>{const t={...e},a=document.querySelector('.single_variation_wrap input[name="product_id"]');a&&(t.id=parseInt(a.value,10));const o=k()?v():(()=>{const e=document.querySelector(".variations_form");if(!e)return[];const t=[];return e.querySelectorAll(".variations select").forEach(e=>{const a=e.dataset.attribute_name||e.dataset.name;if(!a)return;const o=document.querySelector(`label[for="${a.replace("attribute_","")}"]`);o&&t.push({attribute:Array.from(o.childNodes)[0].textContent,value:e.value||""}),t.push({attribute:a,value:e.value||""})}),t})();return o.length&&(t.variation=[...e.variation,...o]),t}),(0,r.addFilter)("wcpay.express-checkout.map-line-items","automattic/wcpay/express-checkout",e=>({...e,items:e.items.filter(e=>!e.extensions?.bundles?.bundled_by)}));const C=window.wp.htmlEntities,P=(e,t)=>{const a=w("checkout")?.stripe_minor_unit??2,o=e*10**(a-t.currency_minor_unit);return a<t.currency_minor_unit?Math.round(o):o},I=e=>{const a=w("checkout").display_prices_with_tax,o=(0,r.applyFilters)("wcpay.express-checkout.map-line-items",e),n=o.items.map(e=>({amount:P(a&&e.totals?parseInt(e.totals.line_subtotal,10)+parseInt(e.totals.line_subtotal_tax,10):parseInt(e.totals?.line_subtotal||e.prices.price,10),e.totals||e.prices),name:[e.name,e.quantity>1&&`(x${e.quantity})`,e.variation&&e.variation.length>0&&"-",e.variation&&e.variation.map(e=>`${e.attribute}: ${e.value}`).join(", "),e.item_data&&e.item_data.length>0&&"-",e.item_data&&e.item_data.map(e=>`${e.name||e.key}: ${e.value}`).join(", ")].filter(Boolean).map(C.decodeEntities).join(" ")})),s=parseInt(o.totals.total_shipping||"0",10);s&&n.push({amount:P(a?s+parseInt(o.totals.total_shipping_tax||"0",10):s,o.totals),name:(0,t.__)("Shipping","woocommerce-payments")});const i=parseInt(o.totals.total_discount||"0",10);i&&n.push({amount:-P(a?i+parseInt(o.totals.total_discount_tax||"0",10):i,o.totals),name:(0,t.__)("Discount","woocommerce-payments")});const c=parseInt(o.totals.total_fees||"0",10);c&&n.push({amount:P(a?c+parseInt(o.totals.total_fees_tax||"0",10):c,o.totals),name:(0,t.__)("Fees","woocommerce-payments")});const p=parseInt(o.totals.total_tax||"0",10);p&&!a&&n.push({amount:P(p,o.totals),name:(0,t.__)("Tax","woocommerce-payments")});const u=parseInt(o.totals.total_refund||"0",10);return u&&n.push({amount:-P(u,o.totals),name:(0,t.__)("Refund","woocommerce-payments")}),P(parseInt(o.totals.total_price,10)-parseInt(o.totals.total_refund||0,10),o.totals)<n.reduce((e,{amount:t})=>e+t,0)?[]:n},E=e=>{const t=w("checkout").display_prices_with_tax,a=e.shipping_rates?.[0]?.shipping_rates||[],o=(0,r.applyFilters)("wcpay.express-checkout.shipping-rates",a,e);return o&&0!==o.length?o.sort((e,t)=>e.selected===t.selected?0:e.selected?-1:1).slice(0,9).map(e=>({id:e.rate_id,displayName:(0,C.decodeEntities)(e.name),amount:P(t?parseInt(e.price,10)+parseInt(e.taxes,10):parseInt(e.price,10),e),deliveryEstimate:[e.meta_data.find(e=>"pickup_address"===e.key)?.value,e.meta_data.find(e=>
1"pickup_details"===e.key)?.value].filter(Boolean).map(C.decodeEntities).join(" - ")})):[]},T=e=>{const t=e?.extensions?.subscriptions;return!!t&&t.trial_length>0},q=e=>{const t=e?.extensions?.subscriptions;if(!t||!Array.isArray(t))return null;for(const e of t){const t=e.shipping_rates?.[0]?.shipping_rates;if(t?.length>0)return t}return null},j=e=>!(!e?.items||!e?.extensions?.subscriptions)&&(!!e.items.some(T)&&(!(e.shipping_rates?.[0]?.shipping_rates?.length>0)&&null!==q(e))),A=e=>!(!e?.items||!e?.extensions?.subscriptions)&&e.items.some(T),F=e=>!!A(e)&&0===parseInt(e.totals?.total_price||"0",10),$=e=>{const t=e?.extensions?.subscriptions;if(!t||!Array.isArray(t))return null;let a=0,o=0,r=0,n=0,s=0,i=2;const c=[];if(t.forEach(e=>{if(!e.totals?.total_price)return;a+=parseInt(e.totals.total_price,10),o+=parseInt(e.totals.total_items||"0",10),r+=parseInt(e.totals.total_tax||"0",10);const t=e.shipping_rates?.[0]?.shipping_rates?.find(e=>e.selected);t?(n+=parseInt(t.price||"0",10),s+=parseInt(t.taxes||"0",10)):(n+=parseInt(e.totals.total_shipping||"0",10),s+=parseInt(e.totals.total_shipping_tax||"0",10)),i=e.totals.currency_minor_unit??i,e.totals.tax_lines&&c.push(...e.totals.tax_lines)}),0===a)return null;const p=t[0]?.totals||e.totals;return{amount:a,currencyMinorUnit:i,totals:{...p,total_price:String(a),total_items:String(o),total_tax:String(r),total_shipping:String(n),total_shipping_tax:String(s),tax_lines:c}}},B=e=>{const a=e.totals,o=parseInt(a.total_price,10),r=a.currency_minor_unit??2,n=a.currency_prefix??"",s=a.currency_suffix??"",i=a.currency_decimal_separator??".",c=a.currency_thousand_separator??",",p=(o/Math.pow(10,r)).toFixed(r).split("."),u=p[0].replace(/\B(?=(\d{3})+(?!\d))/g,c),l=`${n}${p[1]?`${u}${i}${p[1]}`:u}${s}`,d=(m=e.billing_period,(y=e.billing_interval??1)>1?{day:(0,t.sprintf)((0,t._n)("%d day","%d days",y,"woocommerce-payments"),y),week:(0,t.sprintf)((0,t._n)("%d week","%d weeks",y,"woocommerce-payments"),y),month:(0,t.sprintf)((0,t._n)("%d month","%d months",y,"woocommerce-payments"),y),year:(0,t.sprintf)((0,t._n)("%d year","%d years",y,"woocommerce-payments"),y)}[m]||`${y} ${m}s`:{day:(0,t.__)("day","woocommerce-payments"),week:(0,t.__)("week","woocommerce-payments"),month:(0,t.__)("month","woocommerce-payments"),year:(0,t.__)("year","woocommerce-payments")}[m]||m);var m,y;return(0,t.sprintf)((0,t.__)("%1$s / %2$s","woocommerce-payments"),l,d)};(0,r.addFilter)("wcpay.express-checkout.total-amount","automattic/wcpay/express-checkout/wc-subscriptions",(e,t)=>{if(!F(t))return e;const a=$(t);return a?P(a.amount,a.totals):e}),(0,r.addFilter)("wcpay.express-checkout.is-cart-eligible","automattic/wcpay/express-checkout/wc-subscriptions",(e,t)=>{if(e)return!0;if(F(t)){const e=$(t);return null!==e&&e.amount>0}return e}),(0,r.addFilter)("wcpay.express-checkout.shipping-rates","automattic/wcpay/express-checkout/wc-subscriptions",(e,t)=>e&&e.length>0?e:j(t)&&q(t)||e),(0,r.addFilter)("wcpay.express-checkout.shipping-package-id","automattic/wcpay/express-checkout/wc-subscriptions",(e,t,a)=>{if(!j(t))return e;const o=t?.extensions?.subscriptions;if(!o||!Array.isArray(o))return e;for(const e of o){const t=e.shipping_rates;if(t&&Array.isArray(t))for(const e of t){const t=e?.shipping_rates?.some(e=>e.rate_id===a);if(t&&e.package_id)return e.package_id}}return e}),(0,r.addFilter)("wcpay.express-checkout.map-line-items","automattic/wcpay/express-checkout/wc-subscriptions",e=>{if(!A(e))return e;const a=e?.extensions?.subscriptions;if(!a||!Array.isArray(a))return e;const o=0===parseInt(e.totals?.total_price||"0",10),r=[...e.items],n=(0,t.__)("Recurring total","woocommerce-payments");if(a.forEach(a=>{const s=e.items.filter(e=>e.extensions?.subscriptions?.billing_period===a.billing_period).length;if(0===s)return;const i=Math.round(parseInt(a.totals?.total_items||"0",10)/s);r.forEach((e,s)=>{const c=e.extensions?.subscriptions;c&&c.trial_length>0&&c.billing_period===a.billing_period&&((e.item_data||[]).some(e=>e.name===n)||(r[s]={...e,name:`${e.name} (${(0,t.__)("recurring","woocommerce-payments")})`,...o&&{totals:{...e.totals,line_subtotal:String(i),line_total:String(i)}},item_data:[...e.item_data||[],{name:(0,t.__)("Recurring total","woocommerce-payments"),value:(0,t.sprintf)((0,t.__)("%1$s on %2$s","woocommerce-payments"),B(a),a.next_payment_date)}]}))})}),!o)return{...e,items:r};const s=$(e);return s?{...e,items:r,totals:{...e.totals,total_price:String(s.amount),total_items:s.totals.total_items||"0",total_tax:s.totals.total_tax||"0",total_shipping:s.totals.total_shipping||"0",total_shipping_tax:s.totals.total_shipping_tax||"0",tax_lines:s.totals.tax_lines||[]}}:{...e,items:r}}),(0,r.addFilter)("wcpay.express-checkout.resolved-currency","automattic/wcpay/express-checkout/wcpbc",e=>"undefined"!=typeof wc_price_based_country_ajax_geo_params?(e=>new Promise(t=>{const a=jQuery(document.body),o=[],r=e=>
1{o.forEach(e=>e()),t(e)},n=(e,t)=>{t?.code&&r(String(t.code).toLowerCase())};a.on("wc_price_based_country_set_currency_params",n),o.push(()=>a.off("wc_price_based_country_set_currency_params",n));const s=setTimeout(()=>a.triggerHandler("wc_price_based_country_ajax_geolocation"),3e3);o.push(()=>clearTimeout(s));const i=setTimeout(async()=>r(await e),6e3);o.push(()=>clearTimeout(i))}))(e):e),(0,r.addFilter)("wcpay.express-checkout.resolved-currency","automattic/wcpay/express-checkout/mccy-async",e=>{if("undefined"==typeof wcpayAsyncPriceConfig)return e;const t=window.wcpayAsyncCurrency?.ready;return t&&"function"==typeof t.then?new Promise(a=>{const o=setTimeout(async()=>a(await e),6e3);t.then(t=>{clearTimeout(o),a(t?String(t).toLowerCase():e)})}):e});const R=e=>{let t="undefined"==typeof wcpaySettings?4:parseInt(window?.wcpaySettings?.defaultExpressCheckoutBorderRadius||4,10);const a=w("button");return t=a?.radius??t,void 0!==e&&(t=Number(e?.borderRadius)??t),{variables:{borderRadius:`${t}px`,spacingUnit:"6px"}}};let N=null;const M=e=>N||e;let U=null;const O=()=>U,L=()=>w("setup_future_usage")??null,Q=e=>{const t=e?.extensions,a=t?.wcpay;return a&&"setup_future_usage"in a?a.setup_future_usage??null:"pay_for_order"===w("button_context")?L():null};function z(){return w("flags")?.isEceUsingConfirmationTokens??!0}const D=e=>{if(!e)return"";const t=document.createElement("div");return t.innerHTML=e.trim(),t.firstChild?t.firstChild.textContent:""},H=(e,t,a)=>{const o=document.querySelector(`${e} [name="${t}"]`);if(o)if("SELECT"===o.tagName&&/country|state/.test(t)){const e=Array.from(o.options).find(e=>e.value===a||e.textContent.trim().toLowerCase()===a.toLowerCase());e&&(o.value=e.value,jQuery(o).trigger("change").trigger("close"))}else o.value=a,jQuery(o).trigger("change")};window.wp.domReady;const W=(e,t={})=>{if(!1===(n("isShopperTrackingEnabled")??i("is_shopper_tracking_enabled")))return;const a=n("platformTrackerNonce")??i("nonce")?.platform_tracker,o=n("ajaxUrl")??i("ajax_url"),r=new FormData;r.append("tracksNonce",a),r.append("action","platform_tracks"),r.append("tracksEventName",e),r.append("tracksEventProp",JSON.stringify(t)),fetch(o,{method:"post",body:r}).then(e=>e.json())},X=(0,o.debounce)(({source:e})=>{W("applepay_button_load",{source:e})},1e3),G=(0,o.debounce)(({source:e})=>{W("gpay_button_load",{source:e})},1e3),J=window.wp.apiFetch;var K=e.n(J);const V=window.wp.url;class Y{cartRequestHeaders={};async _request(e){const t=await K()({...e,parse:!1,path:(0,V.addQueryArgs)(e.path,{currency:M(w("checkout").currency_code).toUpperCase()}),headers:(0,o.omitBy)({Nonce:w("nonce").store_api_nonce,"X-WooPayments-Tokenized-Cart-Nonce":w("nonce").tokenized_cart_nonce,"X-WooPayments-Tokenized-Cart-Session-Nonce":"product"===w("button_context")?w("nonce").tokenized_cart_session_nonce:void 0,...this.cartRequestHeaders,...e.headers},o.isNil)});return this.cartRequestHeaders=(0,o.omitBy)({Nonce:t.headers.get("Nonce"),"X-WooPayments-Tokenized-Cart-Session":t.headers.get("X-WooPayments-Tokenized-Cart-Session")},o.isNil),t.json()}async placeOrder(e){const t=O();return await this._request({method:"POST",path:"/wc/store/v1/checkout",headers:{"X-WooPayments-Tokenized-Cart":!0,...t&&{"X-WooPayments-Payment-Currency":t},...this.cartRequestHeaders},data:e})}async getCart(){return await this._request({method:"GET",path:"/wc/store/v1/cart"})}useSeparateCart(){this.cartRequestHeaders={"X-WooPayments-Tokenized-Cart-Session":""}}deleteAfterRequest(){this.cartRequestHeaders={"X-WooPayments-Tokenized-Cart-Is-Ephemeral-Cart":"1"}}async updateCustomer(e){return await this._request({method:"POST",path:"/wc/store/v1/cart/update-customer",headers:{"X-WooPayments-Tokenized-Cart":!0,...this.cartRequestHeaders},data:e})}async selectShippingRate(e){return await this._request({method:"POST",path:"/wc/store/v1/cart/select-shipping-rate",data:e})}async addProductToCart(){const e={id:f(),quantity:b(),variation:[]};return await this._request({method:"POST",path:"/wc/store/v1/cart/add-item",data:(0,r.applyFilters)("wcpay.express-checkout.cart-add-item",e)})}async emptyCart(){try{let e=await this._request({method:"GET",path:"/wc/store/v1/cart"});for(;e.items.length>0;)e=await this._request({method:"POST",path:"/wc/store/v1/cart/remove-item",data:{key:e.items[0].key}})}catch(e){}}}const Z=(e,t)=>({first_name:e?.split(" ")?.slice(0,1)?.join(" ")??"",last_name:e?.split(" ")?.slice(1)?.join(" ")??"",company:t.organization??"",address_1:t.line1??"",address_2:t.line2??"",city:t.city??"",state:t.state??"",postcode:t.postal_code??"",country:t.country??""}),ee=(e,t,a=!0,o=[])=>{const r=e.billingDetails?.name||"",n=e.billingDetails?.address??{}
1,s=e.billingDetails?.phone?.replace(/[() -]/g,"")??e.payerPhone?.replace(/[() -]/g,"")??"";return{customer_note:e.order_comments,billing_address:{first_name:r.split(" ")?.slice(0,1)?.join(" ")??"",last_name:r.split(" ")?.slice(1)?.join(" ")||"-",company:n.organization??"",address_1:n.line1??"",address_2:n.line2??"",city:n.city??"",state:n.state??"",postcode:n.postal_code??"",country:n.country??"",email:e.billingDetails?.email??"",phone:s},shipping_address:e.shippingAddress?{...Z(e.shippingAddress.name||"",e.shippingAddress.address),phone:s}:void 0,payment_method:"woocommerce_payments",payment_data:[{key:"payment_method",value:"card"},{key:"wcpay-fraud-prevention-token",value:window.wcpayFraudPreventionToken??""},{key:a?"wcpay-confirmation-token":"wcpay-payment-method",value:t},{key:"express_payment_type",value:e.expressPaymentType},{key:"wcpay-express-payment-method-types",value:JSON.stringify(o)}]}};let te=null,ae=null,oe=new Y;const re=()=>oe,ne=e=>{const t=O(),a=e?.totals?.currency_code?.toLowerCase();return Boolean(t&&a&&t!==a)},se=e=>(0,t.sprintf)((0,t.__)("This express payment started in %1$s and cannot switch to %2$s for the address you selected. Choose a different shipping address, or use the regular checkout to pay in %2$s.","woocommerce-payments"),O().toUpperCase(),e.totals.currency_code.toUpperCase()),ie=e=>({amount:(0,r.applyFilters)("wcpay.express-checkout.total-amount",P(parseInt(e.totals.total_price,10)-parseInt(e.totals.total_refund||0,10),e.totals),e),...z()?{setupFutureUsage:Q(e)}:{}}),ce=()=>{jQuery.blockUI({message:null,overlayCSS:{background:"#fff",opacity:.6}})},pe=()=>{jQuery.unblockUI()},ue=["woocommerce_rest_invalid_billing_email","woocommerce_rest_invalid_order","woocommerce_rest_invalid_user","woocommerce_rest_invalid_address","woocommerce_rest_invalid_address_country"];class le{orderId;key;billingEmail="";cachedCartData={};constructor({orderId:e,key:t,billingEmail:a=""}){this.orderId=e,this.key=t,this.billingEmail=a}async placeOrder(e){const t=e.billing_address?.email,a=e.billing_address?.phone,o=this.cachedCartData.billing_address,r=this.cachedCartData.shipping_address,n=o&&{...o,email:o.email||t,phone:o.phone||a},s=r&&{...r,phone:r.phone||a},i=n?.email;try{const t=await K()({method:"POST",path:`/wc/store/v1/checkout/${this.orderId}`,headers:{Nonce:w("nonce").store_api_nonce},data:{...e,key:this.key,billing_email:this.billingEmail,billing_address:n,shipping_address:s}});return i&&(this.billingEmail=i),t}catch(e){throw i&&!ue.includes(e?.code)&&(this.billingEmail=i),e}}async getCart(){return this.cachedCartData=await K()({method:"GET",path:(0,V.addQueryArgs)(`/wc/store/v1/order/${this.orderId}`,{key:this.key,billing_email:this.billingEmail})})}}let de=null,me=0;const ye=(0,o.debounce)(()=>(0,a.speak)((0,t.__)("Updating payment details. Please try again in a moment.","woocommerce-payments"),"assertive"),1e3,{leading:!0,trailing:!1}),_e=async()=>{if("product"!==w("button_context"))return await re().getCart();const e=new Y;return e.useSeparateCart(),e.deleteAfterRequest(),await e.addProductToCart()},he=()=>de?(0,r.applyFilters)("wcpay.express-checkout.total-amount",P(parseInt(de.totals.total_price,10)-parseInt(de.totals.total_refund||0,10),de.totals),de):"product"===w("button_context")&&w("product")?w("product")?.total.amount:void 0;let we;jQuery(e=>{if(w("has_block")&&"pay_for_order"!==w("button_context"))return;const a=w("stripe").publishableKey;if(!a)return;const o=new c({publishableKey:a,accountId:w("stripe").accountId,locale:w("stripe").locale},(e,t)=>new Promise((a,o)=>{jQuery.post(e,t).then(a).fail(o)}));var s;"pay_for_order"===w("button_context")&&(s=new le({orderId:n("order_id"),key:n("key"),billingEmail:n("billing_email")}),oe=s),_.init({elementId:"#wcpay-express-checkout-element",$separator:jQuery("#wcpay-express-checkout-button-separator")});const i={abortPayment:t=>{pe(),e(".woocommerce-error").remove();const a=e(".woocommerce-notices-wrapper").first();a.length&&(a.append(e('<div class="woocommerce-error" />').text(t)),e("html, body").animate({scrollTop:a.find(".woocommerce-error").offset().top},600))},completePayment:e=>{ce(),window.location=e},startExpressCheckoutElement:async e=>{const{isSuperseded:a=()=>!1}=e;let n="",s=Promise.resolve();const c=await o.getStripe();if(a())return;const p=w("flags")?.isEceUsingConfirmationTokens??!0,u=w("is_manual_capture")??!1,{setupFutureUsage:l}=e,d=e.enabledMethods??w("enabled_methods")??[],m=[d.includes("payment_request")&&"card",d.includes("amazon_pay")&&"amazon_pay"].filter(
1Boolean);var y;we=c.elements({mode:"payment",amount:e.total,currency:(y=e.currency,U=y||null),...p?{paymentMethodTypes:m}:{paymentMethodCreation:"manual"},...p&&u?{captureMethod:"manual"}:{},...p&&l?{setupFutureUsage:l}:{},appearance:R(),locale:w("stripe")?.locale??"en"});const h=we.create("expressCheckout",(()=>{const e=w("button"),t=w("enabled_methods")??[],a=(e,t)=>{switch(t){case"dark":default:return"black";case"light":return"white";case"light-outline":return"googlePay"===e?"white":"white-outline"}},o="default"===e?.type?"plain":e?.type??"buy",r="default"===e?.type?"plain":e?.type??"plain",n=t.includes("payment_request");return{paymentMethods:{applePay:n?"always":"never",googlePay:n?"always":"never",amazonPay:t.includes("amazon_pay")?"auto":"never",link:"never",paypal:"never",klarna:"never"},layout:{overflow:"never"},buttonTheme:{googlePay:a("googlePay",e?.theme??"black"),applePay:a("applePay",e?.theme??"black")},buttonType:{googlePay:o,applePay:r},buttonHeight:Math.min(Math.max(parseInt(e?.height??"48",10),40),55)}})());_.renderButton(h),h.on("loaderror",()=>{document.getElementById("wcpay-woopay-button")||_.getButtonSeparator().hide()}),h.on("click",function(e){if(n="",w("login_confirmation"))return void(e=>{const t=w("login_confirmation");if(!t)return;let a=t.message;var o;a=a.replace(/\*\*.*?\*\*/,{apple_pay:"Apple Pay",google_pay:"Google Pay",amazon_pay:"Amazon Pay",paypal:"PayPal",link:"Link"}[e]),a=a.replace(/\*\*/g,""),confirm(a)&&(o=t.redirect_url,window.location.href=o)})(e.expressPaymentType);if(_.isBlocked())return e.reject(),void ye();const a=de?{shippingAddressRequired:"pay_for_order"!==w("button_context")&&de.needs_shipping,shippingRates:E(de),phoneNumberRequired:w("checkout")?.needs_payer_phone??!1,lineItems:I(de)}:"product"===w("button_context")&&w("product")?{shippingAddressRequired:w("product")?.needs_shipping??!1,phoneNumberRequired:w("checkout")?.needs_payer_phone??!1,lineItems:(w("product")?.displayItems??[]).map(({label:e,amount:t})=>({name:e,amount:t}))}:void 0;if(!a)return void e.reject();if("product"===w("button_context")){if(S())return void window.alert((()=>{if(k())return!1;const e=g();return!!e&&e.classList.contains("wc-variation-is-unavailable")})()?window?.wc_add_to_cart_variation_params?.i18n_unavailable_text||(0,t.__)("Sorry, this product is unavailable. Please choose a different combination.","woocommerce-payments"):(0,t.__)("Please select your product options before proceeding.","woocommerce-payments"));re().useSeparateCart(),s=re().addProductToCart(),s.catch(()=>{n=(0,t.__)("There was an error processing the product with this payment method. Please add the product to the cart, instead.","woocommerce-payments"),re().emptyCart(),h.unmount(),we=null,i.abortPayment(n),_.hideContainer(),_.getButtonSeparator().hide()}).finally(()=>{s=Promise.resolve()})}const o=a.shippingRates&&0!==a.shippingRates.length?a.shippingRates:[{id:"pending",displayName:(0,t.__)("Pending","woocommerce-payments"),amount:0}];(async function({expressPaymentType:e}){ce(),((e,t)=>{const a={google_pay:"gpay_button_click",apple_pay:"applepay_button_click"}[e];a&&W(a,{source:t})})(e,w("button_context"))})(e),e.resolve({business:{name:w("store_name")},emailRequired:!0,...a,shippingRates:a.shippingAddressRequired?o:void 0,allowedShippingCountries:w("checkout").allowed_shipping_countries})}),h.on("shippingaddresschange",async e=>(await s,n?e.resolve():(async(e,t,a)=>{te=e.address;try{const o=await oe.updateCustomer({shipping_address:Z(e.name,e.address)});if(ne(o))return a?.(se(o)),void e.reject();const r=E(o);if(0===r.length)return void e.reject();await t.update(ie(o)),ae=o,e.resolve({shippingRates:r,lineItems:I(o)})}catch(t){e.reject()}})(e,we,i.abortPayment))),h.on("shippingratechange",async e=>(async(e,t,a=null,o)=>{const n=ae||a;try{const a=await oe.selectShippingRate({package_id:(0,r.applyFilters)("wcpay.express-checkout.shipping-package-id",0,n,e.shippingRate.id),rate_id:e.shippingRate.id});if(ne(a))return o?.(se(a)),void e.reject();ae=a,await t.update(ie(a)),e.resolve({lineItems:I(a)})}catch(t){e.reject()}})(e,we,de,i.abortPayment)),h.on("confirm",async e=>{if(!n)return(async(e,a,o,n,s,i,c=[])=>{const{error:p}=await o.submit();if(p)return s(p.message);const u=z();let l;try{l=await async function(e,t,a){if(a){const{confirmationToken:a,error:o}=await e.createConfirmationToken({elements:t});if(o)throw o;return a.id}const{paymentMethod:o,error:r}=await e.createPaymentMethod({elements:t});if(r)throw r;return o.id}(a,o,u)}catch(e){return s(e.message)}try{const t=await oe.placeOrder({...ee(i,l,u,c),extensions:(0,r.applyFilters)("wcpay.express-checkout.cart-place-order-extension-data",{})});if("success"!==t.payment_result.payment_status)return s(D(t.message??t.payment_result?.payment_details.find(e=>"errorMessage"===e.key)?.value??""));let a=t.payment_result.redirect_url;if(!a){const e=t.payment_result.payment_details?.find(e=>"redirect"===e.key);a=e?.value||""}
1const o=e.confirmIntent(a);n(!0===o?a:await o)}catch(e){return e.json&&(e=await Promise.resolve(e.json())),s(D(e.message||e.payment_result?.payment_details.find(e=>"errorMessage"===e.key)?.value||(0,t.__)("There was a problem processing the order.","woocommerce-payments")))}})(o,c,we,i.completePayment,i.abortPayment,e,m);i.abortPayment(n)}),h.on("cancel",()=>{"product"===w("button_context")&&s.finally(()=>{re().emptyCart()}),te&&(e=>{const t=w("button_context"),a=w("has_block");var o;["cart","checkout"].includes(t)&&(a?wc?.blocksCheckout?.extensionCartUpdate({namespace:"woopayments/express-checkout/refresh-ui",data:{}}):(o=e.country,["CA","GB"].includes(o)||(e=>{const t=w("button_context"),a=(o=e,{first_name:o?.recipient?.split(" ")?.slice(0,1)?.join(" ")??"",last_name:o?.recipient?.split(" ")?.slice(1)?.join(" ")??"",company:"",address_1:o?.addressLine?.[0]??"",address_2:o?.addressLine?.[1]??"",city:o?.city??"",state:o?.state??"",country:o?.country??"",postcode:o?.postal_code??""});var o;const r=["country","state","city","postcode"];"cart"===t?(r.forEach(e=>{a[e]&&H("form.woocommerce-shipping-calculator",`calc_shipping_${e}`,a[e])}),document.querySelector('form.woocommerce-shipping-calculator [name="calc_shipping"]')?.click()):"checkout"===t&&r.forEach(e=>{a[e]&&H("form.woocommerce-checkout",`billing_${e}`,a[e])})})(e)))})(te),te=null,pe()}),h.on("ready",e=>{(async function({availablePaymentMethods:e}){e&&(({paymentMethods:e,source:t})=>{const a={googlePay:G,applePay:X};for(const o of e){const e=a[o];e&&e({source:t})}})({paymentMethods:Object.entries(e).filter(([e,t])=>t).map(([e,t])=>e),source:w("button_context")})})(e),e?.availablePaymentMethods&&Object.values(e.availablePaymentMethods).filter(Boolean).length&&(_.showContainer(),_.getButtonSeparator().show())})},init:async({refreshId:t=null}={})=>{const a=null!==t,o=()=>a&&t!==me;(0,r.removeAction)("wcpay.express-checkout.update-button-data","automattic/wcpay/express-checkout");const n="product"===w("button_context"),s=(w("product")?.currency||w("checkout")?.currency_code||"").toLowerCase();n&&await async function(e,t){const a=(e||"").toLowerCase(),o=(0,r.applyFilters)("wcpay.express-checkout.resolved-currency",Promise.resolve(a),t);let n=a;try{const e=await o;"string"==typeof e&&e&&(n=e.toLowerCase())}catch(e){}return N=n||null,n}(s,{buttonContext:"product"}),n&&"bundle"===w("product")?.product_type&&(wcpayExpressCheckoutParams.product=void 0);const c=n&&M(s)!==s;if((a||!de)&&(!w("product")||c))try{const e=await _e();if(o())return;de=e}catch(e){if(o())return;de=null}de&&(wcpayExpressCheckoutParams.product=void 0);const p=he(),u=(0,r.applyFilters)("wcpay.express-checkout.is-cart-eligible",p>0,de),l=de?.extensions?.wcpay?.express_checkout_methods;let d;Array.isArray(l)?d=(e=>{const t=w("methods_enabled_at_location")??[];return e.filter(e=>t.includes(e))})(l):c&&(d=(w("enabled_methods")??[]).includes("payment_request")?["payment_request"]:[]);const m=c&&Array.isArray(d)&&0===d.length;!u||m?(_.hideContainer(),_.getButtonSeparator().hide()):de?await i.startExpressCheckoutElement({total:p,currency:de.totals.currency_code.toLowerCase(),enabledMethods:d,setupFutureUsage:Q(de),isSuperseded:o}):n&&w("product")?await i.startExpressCheckoutElement({total:p,currency:M(s),enabledMethods:d,setupFutureUsage:L(),isSuperseded:o}):(_.hideContainer(),_.getButtonSeparator().hide()),(0,r.addAction)("wcpay.express-checkout.update-button-data","automattic/wcpay/express-checkout",async()=>{const t=++me,a=()=>t!==me;if("product"===w("button_context")&&S())_.unblockButton();else{e(".woocommerce-error").remove();try{_.blockButton();const e=he(),t=await _e();if(a())return;de=t,wcpayExpressCheckoutParams.product=null,_.unblockButton();const o=he(),n={...w("flags")?.isEceUsingConfirmationTokens??1?{setupFutureUsage:Q(de)}:{},...o!==e&&o>0?{amount:o}:{}};we?Object.keys(n).length&&await we.update(n):i.init(),(0,r.applyFilters)("wcpay.express-checkout.is-cart-eligible",o>0,de)?(_.showContainer(),_.getButtonSeparator().show()):(_.hideContainer(),_.getButtonSeparator().hide())}catch(e){if(a())return;de=null,_.hideContainer(),_.unblock()}}})}},p=async()=>{const e=++me;_.blockButton();try{await i.init({refreshId:e})}finally{e===me&&_.unblock()}};"checkout"===w("button_context")&&"pay_for_order"!==w("button_context")||i.init(),e(document.body).on("updated_cart_totals",()=>{p()}),e(document.body).on("updated_checkout",()=>{p()})})})()})();

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.