1import{g as e}from"./adyen-2xVWhjfd.js";import{G as t,o as a,k as o,e as s,w as i,f as n,y as r,a4 as d,a5 as l,m as h}from"./vendor-CV6ISSGl.js";import{_ as c,w as g,O as y,b as p,S as m,R as u,h as D,E as P}from"./index-B_XXSZdw.js";import{D as f,g as A,v as I,a as v,b as S}from"./walletHelpers-T7MGzJUs.js";const C={name:"DigitalWalletGoogle",components:{Overlay:p,OverlaySubmitLoader:y,DigitalWalletAddressOverlay:f},mixins:[g],props:{configData:{type:Object,required:!0},orderData:{type:Object,required:!0},shippingData:{type:Object,required:!0}},data(){return{isFormOverlayVisible:!1,showLoader:!1,isAddressVerificationWasCalled:!0,processedPaymentData:null,showGooglePay:!0,show3dsOverlay:!1,googlePayButton:null,baseRequest:{apiVersion:this.configData.google.apiVersion,apiVersionMinor:this.configData.google.apiVersionMinor},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:this.configData.google.gateway,gatewayMerchantId:this.configData.google.gatewayMerchantId}},baseCardPaymentMethod:{type:"CARD",parameters:{allowedAuthMethods:d(this.configData.google.allowedAuthMethods),allowedCardNetworks:d(this.configData.google.allowedCardNetworks)}}}},computed:{cardPaymentMethod(){return{...d(this.baseCardPaymentMethod),tokenizationSpecification:d(this.tokenizationSpecification)}},...h("delivery",["deliveryFormConfiguration","deliveryAddress","selectedDeliveryModeId"]),...h("cart",["deliveryMode"]),...h("payments",["adyen"]),...h("consent",["isAgeConsentAccepted","ageConsent"]),adyenCoreConfiguration(){return{locale:this.getDefaultConfig("localeId"),environment:this.adyen.environment,clientKey:this.adyen.clientKey,onAdditionalDetails:this.handleOnAdditionalDetails}}},mounted(){const e=document.createElement("script");e.setAttribute("src","https://pay.google.com/gp/p/js/pay.js"),e.addEventListener("load",()=>{this.onGooglePayLoaded()}),e.addEventListener("error",()=>{this.onGooglePayLoadError()}),document.head.append(e)},methods:{async handle3dsAuth(t){const a=await e(this.adyenCoreConfiguration);if("threeDS2"===t.type){const e={challengeWindowSize:window.innerWidth>960||window.innerWidth>=518&&window.innerWidth<=700?"03":"01"};this.show3dsOverlay=!0,await l(),a.createFromAction(t,e).mount(this.$refs.adyenEl)}else a.createFromAction(t).mount(this.$refs.adyenEl2)},handleOnAdditionalDetails(e){e?.data?.details?.threeDSResult?(localStorage.setItem("threeDSResult",e?.data?.details?.threeDSResult),window.location.href=`${this.getDefaultConfig("orderConfirmationUrl")}?threeDSResult=token`):this.$store.dispatch("notification/updateErrorNotifications",{text:this.i18n("checkoutoverview.payment.failed.title")},{root:!0})},getGoogleIsReadyToPayRequest(){return{...d(this.baseRequest),allowedPaymentMethods:[d(this.baseCardPaymentMethod)]}},getGooglePaymentDataRequest(){const e={...d(this.baseRequest)};return e.allowedPaymentMethods=[d(this.cardPaymentMethod)],e.transactionInfo=this.getGoogleTransactionInfo(),e.merchantInfo=this.getGoogleMerchantInfo(),e.callbackIntents=["SHIPPING_ADDRESS","SHIPPING_OPTION","PAYMENT_AUTHORIZATION"],e.emailRequired=!0,e.shippingAddressRequired=!0,e.shippingAddressParameters=this.getGoogleShippingAddressParameters(),e.shippingOptionRequired=!0,e},getGooglePaymentsClient(){return new google.payments.api.PaymentsClient({environment:this.configData.google.environment,paymentDataCallbacks:{onPaymentAuthorized:this.onPaymentAuthorized,onPaymentDataChanged:this.onPaymentDataChanged}})},onPaymentAuthorized(e){return new Promise(t=>{this.processPayment(e).then(e=>{const a=this.generateSubmitOrderData(e,"GooglePay");this.isAddressVerificationWasCalled?(this.isAddressVerificationWasCalled=!1,S(a,this.deliveryFormConfiguration,"delivery").then(e=>e.status===m.SUCCESS?this.submitOrderData({orderData:a,resolve:t}):e.type===P.OVERLAY?(this.isFormOverlayVisible=!0,t({transactionState:"SUCCESS"})):t({transactionState:"ERROR",error:{intent:"SHIPPING_ADDRESS",message:this.i18n(e.message),reason:"SHIPPING_ADDRESS_INVALID"}}))):this.submitOrderData({orderData:a,resolve:t})}).catch(e=>{console.error(e),t({transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:this.i18n("cartoverview.payment-data-error"),reason:"PAYMENT_DATA_INVALID"}})})})},async submitOrderFromOverlay(){this.isFormOverlayVisible=!1,this.showLoader=!0,this.processedPaymentData.data.attributes.deliveryAddress=v(this.deliveryAddress);try{await this.submitOrderData({orderData:this.processedPaymentData,fromOverlay:!0})}finally{this.showLoader=!1}},submitOrderData({orderData:e,resolve:t,fromOverlay:a}){return this.$store.dispatch("delivery/submitOrder",e).then(e=>{this.handleInlinePaymentResponse(t,e)}).catch(e=>{D.call(this,e,a),a||t({transactionState:"SUCCESS"})})},handleInlinePaymentResponse(e,t={}){const{inlinePaymentResponse:a}=t.attributes||{},{resultCodeGroup:o,resultCode:s}=a,i=s?.toUpperCase();if("UNAUTHORIZED"===o||"UNAUTHORISED"===o){if(u[i]){const{message:t,code:a}=u[i];return void e({transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:`${this.i18n(t)} (${a})`,reason:"PAYMENT_DATA_INVALID"}})}}else if("PENDING"===o||"IN_PROGRESS"===o||"PENDING"===s){const e=a?.action||{};this.handle3dsAuth(e)}else{if("AUTHORIZED"===o||"AUTHORISED"===o)return void(window.location.href=`${this.configData.orderConfirmationUrl}?callbackType=success&authResult=${a.resultCode}&merchantReference=${a.merchantReference}&pspReference=${a.pspReference}&paymentMethod=${a.additionalData.paymentMethod}`);console.warn("No order ID is provided in the response")}e({transactionState:"SUCCESS"})},onPaymentDataChanged(e){return new Promise(t=>{const a=e.shippingAddress,o=e.shippingOptionData;let s={},i={};["INITIALIZE","SHIPPING_ADDRESS"].includes(e.callbackTrigger)?(i=I(a,this.configData),i.status===m.FAILURE?(s.error={reason:"SHIPPING_ADDRESS_UNSERVICEABLE",message:this.i18n(i.message),intent:"SHIPPING_ADDRESS"},t(s)):this.configData.net&&a.administrativeArea&&a.postalCode?this.$store.dispatch("tax/getEstimatedTax",{zipCode:a.postalCode,state:a.administrativeArea,paymentMethod:"googlePay"}).then(()=>{s=this.setPaymentDataRequestUpdate(s),t(s)}).catch(e=>{const{data:{errors:t=[{}]}}=e.response;this.trackGoogleAnalyticsError(t,"estimateTax")}):(s=this.setPaymentDataRequestUpdate(s),t(s))):"SHIPPING_OPTION"===e.callbackTrigger&&this.$store.dispatch("delivery/updateDeliveryMode",{deliveryMode:o.id}).then(()=>{s.newTransactionInfo=this.calculateNewTransactionInfo(),t(s)})})},setPaymentDataRequestUpdate(e){return e.newShippingOptionParameters=this.getShippingData(),e.newTransactionInfo=this.calculateNewTransactionInfo(),e},calculateNewTransactionInfo(){return this.getGoogleTransactionInfo()},addGooglePayButton(){const e=this.getGooglePaymentsClient();this.googlePayButton=e.createButton({onClick:this.onGooglePaymentButtonClicked,buttonSizeMode:"fill",buttonLocale:this.configData.language}),this.$refs.googlePayContainer.append(this.googlePayButton)},onGooglePayLoaded(){this.getGooglePaymentsClient().isReadyToPay(this.getGoogleIsReadyToPayRequest()).then(e=>{e.result&&this.addGooglePayButton()}).catch(function(e){console.error(e)})},onGooglePayLoadError(){this.showGooglePay=!1},getGoogleTransactionInfo(){return{displayItems:this.orderData.displayItems,countryCode:this.configData.countryCode,currencyCode:this.orderData.total.amount.currency,totalPriceStatus:"FINAL",totalPrice:this.orderData.total.amount.value.toString(),totalPriceLabel:this.i18n("cartoverview.total")}},getGoogleMerchantInfo(){return{merchantId:this.configData.google.merchantId,merchantName:this.configData.google.merchantName}},getShippingData(){const e=structuredClone(this.shippingData);this.selectedDeliveryModeId&&(e.defaultSelectedOptionId=this.selectedDeliveryModeId);for(const t of e.shippingOptions)delete t.price;return e},getGoogleShippingAddressParameters(){return{allowedCountryCodes:[this.configData.countryCode],phoneNumberRequired:this.configData.phoneRequired}},onGooglePaymentButtonClicked(){if(this.ageConsent&&!this.isAgeConsentAccepted)this.$store.commit("consent/updateShowAgeConsent",!0),this.$store.commit("consent/updateIsAgeConsentAccepted",!1);else{this.deliveryMode.id!==this.shippingData.shippingOptions[0].id&&this.$store.dispatch("delivery/updateDeliveryMode",{deliveryMode:this.shippingData.shippingOptions[0].id});const e=this.getGooglePaymentsClient(),t=this.getGooglePaymentDataRequest();e.loadPaymentData(t).catch(e=>{console.error(e)})}},processPayment(e){return new Promise(t=>{const a=this.getWalletShippingName(e.shippingAddress.name);e.shippingAddress={...e.shippingAddress,...a,country:{isocode:this.deliveryAddress.isoCode,name:this.deliveryAddress.country}},this.updateDeliveryAddress(e),t(e)})},updateDeliveryAddress(e){const t=this.generateSubmitOrderData(e,"GooglePay"),a=A(t);this.processedPaymentData={...a},this.$store.dispatch("delivery/updateDeliveryAddress",a.data.attributes.deliveryAddress)},closeOverlay(){this.isFormOverlayVisible=!1,this.googlePayButton.querySelector("button").click()}}},w={key:0,ref:"googlePayContainer",class:"digital-wallet__google-pay"},R={ref:"adyenEl"},O={ref:"adyenEl2"};const E=c(C,[["render",function(e,d,l,h,c,g){const y=t("overlay"),p=t("digital-wallet-address-overlay"),m=t("overlay-submit-loader");return c.showGooglePay?(a(),o("section",w,[c.show3dsOverlay?(a(),s(y,{key:0,"show-header":!1},{description:i(()=>[n("div",R,null,512)]),_:1})):r("",!0),n("div",O,null,512),c.isFormOverlayVisible?(a(),s(p,{key:1,"wallet-type":"Google Pay","close-overlay":g.closeOverlay,"submit-order":g.submitOrderFromOverlay},null,8,["close-overlay","submit-order"])):r("",!0),c.showLoader?(a(),s(m,{key:2})):r("",!0)],512)):r("",!0)}]]);export{E as default};
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.