PageSourceSearch

https://scaphander.fr/wp-content/plugins/pymntpl-paypal-woocommerc…/googlepay-cart.js?ver=06f7b54e9b1bc463ab1f

js scaphander.fr collected 2026-10-09 22:37:53 UTC 10,988 bytes, 2 lines download raw bytes

1(()=>{"use strict";var t={n:e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return t.d(i,{a:i}),i},d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=window.wcPPCP.cart;var i=t.n(e);const n=window.wcPPCP.utils,s=window.wcPPCP.controllers,a=window.wcPPCP.context;var o=t.n(a);const r=window.jQuery;var l=t.n(r);const d=window.wp.i18n,p=window.wcPPCP.actions;var c=t.n(p);const h=class{constructor({id:t,settings:e,controller:i}){this.id=t,this.settings=e,this.controller=i,this.paypal=null,this.capabilities=[],"payment_method"===this.settings.buttonPlacement&&this.capabilities.push("place_order_button"),this.actions=new(c())}initialize(){}setController(t){this.controller=t}setPayPal(t){this.paypal=t}async canMakePayment(){return!0}shouldCreateElement(t){return!0}async createPaymentElement(t){throw new Error("Must implement createPaymentElement()")}getOrderFieldKey(){return`${this.id}_paypal_order_id`}getTokenFieldKey(){return`${this.id}_payment_token`}enablePaymentElement(){}disablePaymentElement(){}destroyPaymentElement(){}validatePaymentElement(){return!0}supports(t){return this.capabilities.includes(t)}},u=class extends h{static BASE_REQUEST={allowedPaymentMethods:[]};constructor(t){super(t),this.paymentsClient=null,this.googlePayConfig=null,this.capabilities.push("form_validation"),this.isReady=null,this.$button=null,this.promises=[]}async canMakePayment(){if(!this.paypal?.Googlepay)return!1;if(!this.settings.supported_currencies.includes(this.controller.getCurrency()))return!1;if(!this.paymentsClient)try{await this.createPaymentsClient()}catch(t){if("GOOGLEPAY_CONFIG_ERROR"===t?.errorName)throw new n.ConfigurationError(t.message);throw new n.ConfigurationError(t.message)}return await this.isReadyToPay()}shouldCreateElement(t){return!l()(t).find("button.wc-ppcp_googlepay-button").length}async createPaymentElement(t){try{if(this.paymentsClient||await this.createPaymentsClient(),await this.isReadyToPay()){const e=this.paymentsClient.createButton({onClick:this.onButtonClick.bind(this),...this.getButtonOptions()});
1return this.controller.context.isCheckout()&&e.addEventListener("click",this.validateCheckout.bind(this),!0),l()(e).find("button").addClass(`wc-ppcp_googlepay-button ${this.controller.context.getPage()}-context`).attr("id",`gpay-button-online-api-id-${this.controller.context.getPage()}`).css({height:this.settings.button.buttonHeight}),t.appendChild(e),this.$button=l()(e),t}}catch(t){return console.error("Failed to create Google Pay button:",t),null}}async validateCheckout(t){if(this.$button.is(".skip-validation"))return void this.$button.removeClass("skip-validation");t.stopPropagation(),t.preventDefault(),l()(t.target).prop("disabled",!0);const e=await this.controller.validate();l()(t.target).prop("disabled",!1),e&&(this.$button.addClass("skip-validation"),l()(t.target).trigger("click"))}async createPaymentsClient(){try{await this.initializeConfig(),this.paymentsClient=new google.payments.api.PaymentsClient(this.buildPaymentsClientRequest())}catch(t){throw t}}async initializeConfig(){this.googlePayConfig||(this.googlePayConfig=await this.paypal.Googlepay().config())}buildPaymentsClientRequest(){const{merchantInfo:t}=this.googlePayConfig,e=this.controller.needsShipping()&&!this.controller.context.
1isCheckout();return{environment:(0,n.isProduction)()?"PRODUCTION":"TEST",merchantInfo:{...t},paymentDataCallbacks:{onPaymentAuthorized:async t=>this.onPaymentAuthorized(t),...e&&{onPaymentDataChanged:t=>this.onPaymentDataChanged(t)}}}}async isReadyToPay(){if(null!==this.isReady)return this.isReady;const{apiVersion:t,apiVersionMinor:e,allowedPaymentMethods:i}=this.googlePayConfig,n=await this.paymentsClient.isReadyToPay({apiVersion:t,apiVersionMinor:e,allowedPaymentMethods:i,existingPaymentMethodRequired:!1});return this.isReady=!!n.result,this.isReady}async onButtonClick(t){try{if(this.controller.onClick(),await this.createPaymentsClient(),this.controller.context.isProduct()&&(this.promises.push(this.controller.addToCart()),!this.controller.needsShipping()))try{this.disablePaymentElement(),await Promise.all(this.promises)}catch(t){console.log("Error adding item to cart. ",t)}finally{this.enablePaymentElement()}const t=await this.paymentsClient.loadPaymentData(this.buildPaymentDataRequest());"PAYER_ACTION_REQUIRED"===this.confirmOrderResponse?.status&&await this.initiatePayerAction(this.confirmOrderResponse.orderId);const e=this.extractStandardizedCheckoutData(t);this.controller.submit(e)}catch(t){if("CANCELED"===t?.statusCode)return void this.controller.onCancel();this.controller.submitError(t?.statusMessage||t)}finally{this.promises=[]}}async onPaymentAuthorized(t){try{if(this.settings.needsSetupToken)return{transactionState:"SUCCESS"};const e=await this.controller.createOrder();let i=await this.paypal.Googlepay().confirmOrder({orderId:e,paymentMethodData:t.paymentMethodData});return this.confirmOrderResponse={status:i.status,orderId:e},["APPROVED","PAYER_ACTION_REQUIRED"].includes(i.status)?((0,n.setFieldValue)(this.getOrderFieldKey(),e,null),{transactionState:"SUCCESS"}):{transactionState:"error",error:{intent:"PAYMENT_AUTHORIZATION",message:""}}}catch(t){return"validation_errors"===t?.code?{transactionState:"error",error:{intent:"PAYMENT_AUTHORIZATION",message:t.data.sanitized_errors.join(" ")}}:{transactionState:"error",error:{intent:"PAYMENT_AUTHORIZATION",message:t?.message}}}}async onPaymentDataChanged(t){try{this.promises.length&&(await Promise.all(this.promises),this.promises=[]);const e=this.formatShippingAddress(t.shippingAddress);let i=t.shippingOptionData?.id;"shipping_option_unselected"===i&&(i=null);const n=await this.controller.onShippingChange({address:e,shipping_method:i});return this.formatPaymentDataResponse(n)}catch(t){return t?.data?.error?{error:{reason:t.data.error.reason||"SHIPPING_ADDRESS_INVALID",message:t.data.error.message||t.message,intent:t.data.error.intent||"SHIPPING_ADDRESS"}}:{error:{reason:"OTHER_ERROR",message:t?.message||"Unable to calculate shipping for this address",intent:"SHIPPING_ADDRESS"}}}}async initiatePayerAction(t){return this.paypal.Googlepay().initiatePayerAction({orderId:t})}formatShippingAddress(t){return{postcode:t.postalCode,city:t.locality,state:t.administrativeArea,country:t.countryCode}}formatPaymentDataResponse(t){return{newTransactionInfo:{totalPrice:t.total,totalPriceStatus:"FINAL",countryCode:t.countryCode,currencyCode:t.currency,displayItems:this.mapLineItemsToGooglePay(t.lineItems||[])},...t.shippingOptions&&{newShippingOptionParameters:{shippingOptions:this.mapShippingOptionsToGooglePay(t.shippingOptions),...t.selectedShippingMethod&&{defaultSelectedOptionId:t.selectedShippingMethod}}}}}
1hasValidShippingAddress(){if(!this.controller.context.isCheckout())return!1;const t={first_name:(0,n.getFieldValue)("shipping_first_name"),last_name:(0,n.getFieldValue)("shipping_last_name"),address_1:(0,n.getFieldValue)("shipping_address_1"),address_2:(0,n.getFieldValue)("shipping_address_2"),city:(0,n.getFieldValue)("shipping_city"),state:(0,n.getFieldValue)("shipping_state"),postcode:(0,n.getFieldValue)("shipping_postcode"),country:(0,n.getFieldValue)("shipping_country")};return(0,n.isValidAddress)(t)}buildPaymentDataRequest(){const{merchantInfo:t,apiVersion:e,apiVersionMinor:i,allowedPaymentMethods:s}=this.googlePayConfig,a=this.controller.context;a.isCheckout()&&s[0]?.parameters?.billingAddressRequired&&(s[0].parameters.billingAddressRequired=!1),s[0]?.parameters?.billingAddressParameters&&(s[0].parameters.billingAddressParameters.phoneNumberRequired=(0,n.isFieldRequired)("billing_phone"));const o=this.controller.needsShipping()&&!a.isCheckout(),r={...this.constructor.BASE_REQUEST,merchantInfo:{...t},apiVersion:e,apiVersionMinor:i,allowedPaymentMethods:s,transactionInfo:{countryCode:this.settings.country_code,currencyCode:this.controller.getCurrency(),totalPriceStatus:"FINAL",totalPrice:this.controller.getTotal(),displayItems:this.mapLineItemsToGooglePay(this.controller.getLineItems()),totalPriceLabel:this.settings.i18n.total_price_label},emailRequired:(0,n.isFieldRequired)("billing_email"),...o&&{shippingAddressParameters:{},shippingAddressRequired:!0,shippingOptionRequired:!0,...this.controller.getShippingOptions().length>0&&{shippingOptionParameters:{shippingOptions:this.mapShippingOptionsToGooglePay(this.controller.getShippingOptions()),...this.controller.getSelectedShippingMethod()&&{defaultSelectedOptionId:this.controller.getSelectedShippingMethod()}}}},callbackIntents:["PAYMENT_AUTHORIZATION",...o?["SHIPPING_ADDRESS","SHIPPING_OPTION"]:[]]};return this.actions.applyFilters("googlepay_payment_request",r,this)}
1disablePaymentElement(){this.controller.context.isOrderPay()||(this.$button?.find("button").prop("disabled",!0),this.$button?.addClass("disabled"))}enablePaymentElement(){this.$button?.find("button").prop("disabled",!1),this.$button?.removeClass("disabled")}destroyPaymentElement(){this.$button?.remove()}extractStandardizedCheckoutData(t){const e={};if(t?.paymentMethodData?.info){const i={},n=t.paymentMethodData.info;if(n.billingAddress){const t=n.billingAddress;i.first_name=t.name?.split(" ")[0]||"",i.last_name=t.name?.split(" ").slice(1).join(" ")||"",i.address_1=t.address1||"",i.address_2=t.address2||"",i.city=t.locality||"",i.state=t.administrativeArea||"",i.postcode=t.postalCode||"",i.country=t.countryCode||"",i.phone=t.phoneNumber||""}t.email&&(i.email=t.email),e.billing=i}if(t?.shippingAddress){const i={},n=t.shippingAddress;i.first_name=n.name?.split(" ")[0]||"",i.last_name=n.name?.split(" ").slice(1).join(" ")||"",i.address_1=n.address1||"",i.address_2=n.address2||"",i.city=n.locality||"",i.state=n.administrativeArea||"",i.postcode=n.postalCode||"",i.country=n.countryCode||"",n.phoneNumber&&(i.phone=n.phoneNumber),e.shipping=i}return e}getButtonOptions(){return{buttonBorderType:this.settings.button.buttonBorderType,buttonColor:this.settings.button.buttonColor,buttonType:this.settings.button.buttonType,buttonRadius:this.settings.button.buttonRadius,buttonLocale:this.settings.button.buttonLocale,buttonSizeMode:this.settings.button.buttonSizeMode,...this.controller.context.
1isExpressCheckout()&&{buttonSizeMode:"fill"}}}mapLineItemsToGooglePay(t){return t.map(t=>{let e="LINE_ITEM";return e="tax"===t.type?"TAX":"SUBTOTAL",{label:t.label,type:e,price:t.amount}})}mapShippingOptionsToGooglePay(t){return t.sort((t,e)=>parseFloat(t.amount)-parseFloat(e.amount)).map(t=>({id:t.id,label:(0,d.sprintf)("%s: %s %s",t.label,t.amount,this.controller.getCurrency()),description:t.description||""}))}},g=(0,n.getSetting)("ppcp_googlepay_data"),{disabled:y=!1}=g;if(!y){const t=new u({id:"ppcp_googlepay",cart:i(),settings:g}),e=new(o())("cart");new s.CartController({id:"ppcp_googlepay",cart:i(),context:e,gateway:t,settings:g}).initialize()}(this.wcPPCP=this.wcPPCP||{}).googlepayCart={}})();
2//# sourceMappingURL=googlepay-cart.js.map

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.