PageSourceSearch

https://www.thegreendoor.ca/cdn/shopifycloud/checkout-web/assets/c1/component-InstallmentsModal.BjrfKBhF.js

js thegreendoor.ca collected 2026-09-26 11:24:40 UTC 18,361 bytes, 1 lines download raw bytes

1import{A as B,q as F,h,k as P,a8 as be,T as Y,a9 as Ae,u as D,f as me}from"./esnext-vendor.B9Da21W6.js";import{f as Ee,eQ as Z,ae as Re,eR as fe,bh as pe,eS as Me,bf as Se,eT as Te,cM as Oe,eU as Ne,B as ke,k as De,m as Le,P as we,bu as xe}from"./hydrate.DZ4YTm7p.js";import{S as O,cW as re,bk as le,et as ze,B as Ue,aX as $e,bs as _e,a4 as ee,cX as ge,eu as Be,ay as Fe,bc as He,ev as Ve,ew as je,ex as qe,bv as he,ey as Ye,n as We,ez as Ge,eA as Je,bB as Xe}from"./addresses-is-address-empty.Bn2lNY_L.js";import{g as Ke}from"./shop-pay-installments-monorail.BAOukcZ1.js";import{O as Qe}from"./hooks-useShopPayProgressIntercepts.C0rljcs-.js";import{C as ce}from"./graphql-PaymentSessionMutation.CAXCwUvV.js";import{I as Ze}from"./PayButtonSection.C-faiTG_.js";import"./app.DbSrjjlA.js";import"./hooks-useShopPayExternalAppContext.DWwMuRnz.js";import"./hooks-useReplaceShopPayInHistory.DPpLejwu.js";import"./cvv-cvvBridge.B-VIACTq.js";import"./StickyPayButton-StickyPayButton.module.C7bJOHW4.js";import"./Switch.jEKUIqPZ.js";import"./hooks-useWalletsTimeout.CS-oFfve.js";import"./stopwatch.CfKlh48v.js";import"./PayButton-helpers.Cc_ffyKs.js";import"./cross-border-hooks.xPE4TSQ5.js";import"./shared-buyer-consent.B_gDyRCR.js";import"./useShopPayButtonClassName.FG1djxr9.js";import"./shared-shop-theme.DIHIQUEd.js";import"./hooks-useShowShopPayOptin.Br0M25ky.js";import"./AddressPresenter.BIgrto4P.js";import"./hooks-useShouldRevealCustomization.D_kH_Ics.js";import"./hooks-payment-button.CEm7ZXVs.js";import"./PaymentButtons.MV6WHZES.js";import"./styles-floating-layer.module.BCoSmdvP.js";import"./utils-useViolationsHandler.BE3Ij9oJ.js";import"./ShopPayLogo.C-Gy2CdB.js";import"./negotiated-findSelectedDeliveryMethod.DuEyfwut.js";import"./payment-usePaymentExemptionReason.B4VABxaE.js";const K=["PAYMENTS_UNACCEPTABLE_PAYMENT_AMOUNT","DELIVERY_DELIVERY_LINE_DETAIL_CHANGED","CARD_DECLINED","NAME_MISMATCH",Z.InvalidShippingAddress,le.InvalidExtensionState,le.InvalidCaptcha];function et(){const{source:e,checkout:t,shop:s,shopPay:r,observability:n,userEvents:l,embed:m}=O(),{installments:a,session:o}=r,p=r.user.installments,c=a.payment.value,f=t.latestReceipt.value,{progress:d}=Ee(),u=B(c),i=F(_=>{const v=tt(_);let g;nt(_)?(g=re.InstallmentsRetryError,p.unstable_setRetryable(!0),a.unstable_setModalCloseForRetry(!0)):(g=re.InstallmentsPermanentRejection,p.unstable_setRetryable(!1)),st(_)&&a.unstable_setAgreementError(Z.InvalidShippingAddress);const y=p.isRetryable.value,E=p.isRejected.value,U=a.agreementError.value;n.log("shop_pay_installments_error_occurred","[Installments] An error has occurred",{errors:v,eventType:g,installmentsRetryableSignal:y,installmentsRejectedSignal:E,installmentsAgreementErrorSignal:U}),l.monorailEvent({schemaId:"shopify_pay_payment_page_installments/1.4",payload:{...Ke(e,t,s,{embedPlatform:m?.platform,shopAppSurface:r.app.config.surface}),eventType:g,success:!1,errorMessage:v}}),p.unstable_setRejected(!0),o.unstable_setInternalProgressing(!1)},[n,l,a,p,e,t,s,o,m?.platform,r.app.config.surface]);return h(()=>{!c||u.current===c||(d("shop-pay-installments-error-handler",_=>{_.status!=="success"&&_.status!=="alreadyCompleted"&&(i(_),a.unstable_updatePayment(void 0))}),u.current=c)},[c,i,d,a]),h(()=>{f?.status==="failed"&&c&&(i(f),a.unstable_updatePayment(void 0))},[f]),{onInstallmentsError:i}}function tt(e){if(!e)return"no_result";if("errors"in e&&e.errors.length>0){const t=e.errors.map(s=>s.code).join(", ");if(t)return t}if("failure"in e&&e.failure)return`failed_receipt_${e.failure.type}`;if("status"in e&&e.status)return e.status==="invalid"?`error_result_invalid__${e.reasons.join("__")}`:`error_result_${e.status}`}function nt(e){if(!e)return!1;if("reasons"in e&&e.reasons)return e.reasons.some(t=>K.includes(t));if("failure"in e&&e.failure){const t=e.failure;return t.type==="payment"&&K.includes(t.code)}return"violations"in e?e.violations.some(({code:t})=>K.includes(t)):!1}function st(e){return e?.status==="agreement_invalid"&&e.violations.some(({code:t})=>t===Z.InvalidShippingAddress)}function at({rpc:e,iframe:t,accessToken:s,iframeSourceLoaded:r,open:n}){const{client:l,shopPay:m}=O(),{installments:a}=m,{enabled:o,log:p}=Re(),c=B({});h(()=>{c.current={shouldUseSessionToken:m.shouldUseAccessToken,userIdentified:m.userIdentified.value,hasSessionToken:!!s,rpcConnected:!!e,iframeMounted:!!t,iframeSourceLoaded:r===null?"pending":r,hasInstallmentsPayment:!!a.payment.value,open:n}});const f=F((d,u)=>{p(d,u,c.current)},[p]);return h(()=>{o&&p("ecp_spi_debug_cookie_snapshot","Cookie snapshot at installments flow init",{identifiedShopPayUserCookiePresent:!!l.cookies.get(ze),readableCookieCount:typeof document>"u"?0:document.cookie.split(";
1 ").filter(Boolean).length})},[l.cookies,o,p]),h(()=>{o&&e&&(s?f("ecp_spi_debug_authorization_sent","Shop Pay session token present; sending authorization to installments iframe"):f("ecp_spi_debug_authorization_skipped_no_token","RPC connected but no Shop Pay session token; authorization not sent to installments iframe"))},[o,e,s,f]),{logInitiationEvent:f}}var Q=(e=>(e.CheckoutOne="C1",e.Pay="PAY",e))(Q||{});const ot=["initializePay","pingPay","updateAuthorization","updateCheckout","updateCard","setInitialUserState"];class it extends Error{constructor(t,s){super(t),this.name="RPCConnectionTimeoutError",this.diagnostics=s}}const rt=1e3,lt=100,z={CONNECTION_INITIATED:"installments_rpc_connection_initiated",CONNECTION_ATTEMPT:"installments_rpc_connection_attempt",NOT_READY:"installments_rpc_not_ready",CONNECTED:"installments_rpc_connected",CONNECTION_ERROR:"installments_rpc_connection_error",CONNECTION_TIMEOUT:"installments_rpc_connection_timeout"};function ct({rpcEndpoint:e,initializer:t,connectionOptions:{timeout:s=rt,attemptDelay:r=lt}={},inAppRPCSessionCount:n}){const[l,m]=P(!1),a=fe(n),[o,p]=P(),c=B({attemptCount:0,initializerCalled:!1,startedAt:0}),f=e&&t&&!l&&!o;return h(()=>{a!==n&&m(!1)},[n,a]),h(()=>{let d=!1;c.current={attemptCount:0,initializerCalled:!1,startedAt:Date.now()};async function u(){if(!e||!t||!f)return;const{call:i,log:_,observabilityLog:v}=e;for(;;){c.current.attemptCount++;const g=c.current.attemptCount;try{_(`RPC channel ${n} opening...`),v(z.CONNECTION_ATTEMPT,`RPC channel ${n} opening (attempt ${g})`,{sessionCount:n,attemptNumber:g,elapsedMs:Date.now()-c.current.startedAt}),c.current.initializerCalled=!0;const y=await t(i);if(!y){if(_("RPC channel not ready yet"),v(z.NOT_READY,"RPC channel not ready yet, retrying",{sessionCount:n,attemptNumber:g,elapsedMs:Date.now()-c.current.startedAt}),await new Promise(E=>setTimeout(E,r)),d)break;continue}_("RPC channel opened",y),v(z.CONNECTED,"RPC channel opened successfully",{sessionCount:n,attemptNumber:g,elapsedMs:Date.now()-c.current.startedAt}),d||m(!0);break}catch(y){_("RPC connection failed",y),v(z.CONNECTION_ERROR,`RPC connection failed on attempt ${g}`,{sessionCount:n,attemptNumber:g,elapsedMs:Date.now()-c.current.startedAt,errorMessage:y instanceof Error?y.message:String(y),errorName:y instanceof Error?y.name:"unknown"}),d||p(y);break}}}return e&&t&&f&&(e.log("connection initiated"),e.observabilityLog(z.CONNECTION_INITIATED,"RPC connection initiated",{sessionCount:n,timeoutMs:s,attemptDelayMs:r}),u()),()=>{d=!0}},[r,f,t,e,n,s]),h(()=>{if(!e||!f)return;let d=!1;const{log:u,observabilityLog:i}=e,_=setTimeout(()=>{if(f){const v=c.current,g={attemptCount:v.attemptCount,elapsedMs:Date.now()-v.startedAt,timeoutMs:s,initializerCalled:v.initializerCalled,sessionCount:n},y=new it("RPC channel open timeout",g);u("RPC connection failed",y),i(z.CONNECTION_TIMEOUT,`RPC channel open timeout after ${g.attemptCount} attempt(s) over ${g.elapsedMs}ms`,g),d||p(y)}},s);return()=>{clearTimeout(_),d=!0}},[f,e,s,n]),h(()=>(e||m(!1),()=>{e&&e.terminate()}),[e]),{connected:l,error:o}}function dt(e,{logging:t,messenger:s,observability:r,...n}){return{...be(s,n),id:n.uuid(),log(l,...m){},observabilityLog(l,m,a){r&&r.log(l,`[${e}-RPC] ${m}`,a)}}}function ut(e,t,s){const[r,n]=P(!1),[l,m]=P(0),{observability:a}=O(),o=Y(()=>{if(!t)return;const d=dt(Q.CheckoutOne,{callable:ot,logging:!1,messenger:Ae(t,{terminate:!1}),uuid:Ue,observability:a});return d.log(`expose initializeC1 ${l}`),d.expose({initializeC1(){}}),d},[t,l,a]);h(()=>{if(!o){n(!1);return}const d={reset(){n(!1),m(i=>i+1)},closeModal(i,_){u("closeModal",arguments),e.onClose(i,_)},initializeC1(){return u("initializeC1",arguments),n(!0),{id:o.id,metadata:{timestamp:new Date().toISOString()}}},installmentsError(i){u("installmentsError",arguments),e.onError(i)},payAnotherWay(){u("payAnotherWay",arguments),e.onPayAnotherWay()},payWithInstallments(i){u("payWithInstallments",arguments),e.onComplete(i)},pingC1(i="interrogative",_){return u("pingC1",arguments),o.log(`PING: ${i} @ ${new Date().toISOString()}`),e.onPing(i,_),`PONG: ${Q.CheckoutOne}`},resizeModal(i){return u("resizeModal",arguments),e.setHeight(i),window.innerHeight},updateProgress(i,_){u("updateProgress",arguments),e.onUpdateProgress(i,_)}};o.log("expose handlers"),o.expose({...d});function u(i,_){o?.log(i,_)}},[e,o]);const p=F(d=>d.initializePay(),[]),{connected:c,error:f}=ct({rpcEndpoint:o,initializer:r?p:void 0,connectionOptions:s,inAppRPCSessionCount:l});if(f)throw f;if(!(!o||!r||!c))return o.call}function mt(e){return{lastUsedAt:"",name:"",preferred:!1,id:String(e.id),uuid:e.uuid??"",brand:e.brand,expired:e.expired,expiring:!1,expiryMonth:e.month,expiryYear:e.year,funding:e.funding,lastDigits:e.last_digits,supportsInstallmentsInterestLoan:e.supports_installments_interest_loan,supportsInstallmentsSplitPayLoan:e.supports_installments_split_pay_loan,installmentsSplitPayLoanNotSupportedReason:e.installments_split_pay_loan_not_supported_reason,installmentsInterestLoanNotSupportedReason:e.installments_interest_loan_not_supported_reason,billingAddress:{address:{firstName:e.billing_address.first_name,lastName:e.billing_address.last_name,company:e.billing_address.company,address1:e.billing_address.address1,address2:e.billing_address.address2,city:e.b
1illing_address.city,postalCode:e.billing_address.zip,phone:e.billing_address.phone,countryCode:e.billing_address.country_code,zoneCode:e.billing_address.zone_code}},billingAddressValid:e.address_valid,verified:!0}}function ft({open:e,lastKnownPayStepId:t,locale:s}){const{client:r,environment:{services:{shopServer:n}},shop:l,observability:m,source:a,shopPay:o}=O(),p=$e({source:a}),{config:c}=o,f=o.installments.triggerSource.value,d=o.deviceFingerprint.value,{tracking:u}=c,i=u.unique,_=u.visit,{myshopifyDomain:v,merchantPolicies:g,countryCode:y}=l,{checkoutSessionIdentifier:E}=a,U=o.session.selectedPaymentMethod.value,R=_e(U),N=Be,[b,S]=P(R?.id),[L,w]=P(d),{paymentMethods:W}=ee(),T=ge(W.value),C=T?.availableLoanTypes.join(",")||"",H=T?.supportedCountries.join(",")||y,$=T?.creditCardEnabledCountries.join(",")||"",I=!!E,A=!!b,M=!!T,k=C.length>0,V=$.length>0,x=!!L,te=(T?.supportedCountries.length??0)>0,ne=g.find(({handle:j})=>j==="refund-policy")?.url,G=pe().value,se=Me(),ae=Se({include:{shopId:!0,shopClientUuid:!0}}),oe=o.isExternal;h(()=>{!e&&R&&S(R.id)},[R,e]),h(()=>{e&&!b&&R&&S(R.id)},[e,b,R]),h(()=>{!e&&d!==null&&w(d)},[d,e]);const J=Y(()=>{if(!E||!b)return null;const j={checkout_version:p,checkout_token:E,locale:s,parent_page_load_id:N,selected_card_id:b,shopify_domain:v,last_known_step_i
1d:t,available_loan_types:C,refund_policy_url:ne,isPointOfSale:G,supported_countries:H,tracking_unique:i,tracking_visit:_,device_fingerprint:L??"",credit_card_enabled_countries:$,trigger_source:f},ye=Object.entries(G?{...j,...se}:j).map(([Ie,Pe=""])=>`${encodeURIComponent(Ie)}=${encodeURIComponent(Pe)}`).join("&"),ie=Fe(),ve=ie?"installments_iframe_inapp":"installments_iframe",q=new URL(`/pay/transactions/${ve}?${ye}`,n.url),Ce=new URLSearchParams(r.initialRequest.url.search);return ae(q.searchParams,Ce),ie&&oe&&(q.searchParams.set("origin",Te.PaymentRequest),q.searchParams.set("flow","payment_request")),q.href},[E,b,p,s,N,v,t,C,H,$,ne,G,i,_,L,se,r.initialRequest.url.search,ae,n.url,oe,f]),X=B(!1);return h(()=>{if(!e){X.current=!1;return}J||X.current||(X.current=!0,m.log("installments_iframe_source_missing","[Installments] Iframe source missing while modal open",{availableLoanTypesPresent:k,creditCardEnabledCountriesPresent:V,hasCheckoutToken:I,hasDeviceFingerprint:x,hasInitialSelectedCard:A,hasInstallmentsConfig:M,supportedCountriesPresent:te}))},[k,V,J,I,x,A,M,m,e,te]),J}const pt="IgLVV",_t="X587H",de={ConsolidatedPlanSelectionReviewTreatmentIframe:pt,ConsolidatedPlanSelectionReviewTreatmentAnimationIframe:_t},gt="shop-pay-affirm-iframe",ht="camera; microphone; gyroscope; accelerometer";function yt({checkoutDetails:e,open:t,onClose:s,onError:r,locale:n}){const{i18n:l,observability:m,shopPay:a}=O(),{installments:o}=a,p=He("taxes").value,c=Oe(),[f,d]=P(null),[u,i]=P(),[_,v]=P(),[g,y]=P(null),[E,U]=P(!1),R=F(I=>{c.current&&i(I)},[c]),N=B(),b=o.payment.value,S=_e(a.session.selectedPaymentMethod.value),L=a.user.creditCards,w=a.accessToken.value,W=Y(()=>({onClose(I,A){v(A),g||y(I),s()},setHeight(I){u&&(u.style.height=`${I}px`)},onComplete(I){m.log("installments_payment_created","[Installments] Installments payment created"),o.unstable_updatePayment(I)},onError:r,onPayAnotherWay(){try{a.session.unstable_updatePaymentMethodOption({type:"wallet",name:"SHOP_PAY"}),N.current=void 0,v(void 0),y(null)}catch{s();return}s()},onUpdateProgress(I,A){N.current=I;const M=A?L.value.find(x=>Number(x.id)===A?.id):null,k=M&&A?.id!==Number(S?.id),V=!M&&A;if(k)a.session.selectPaymentMethod(Ve(M));else if(V){const x=a.user.addCreditCard(mt(A));a.session.selectPaymentMethod(x)}},onPing(I,A){if(I==="installments_iframe_loaded"){const M=A?.consolidatedPlanSelectionReviewVariant,k=M==="treatment";u?.classList.toggle(de.ConsolidatedPlanSelectionReviewTreatmentIframe,M==="copy_and_visual_only"||k),u?.classList.toggle(de.ConsolidatedPlanSelectionReviewTreatmentAnimationIframe,k),d(!0)}}}),[r,g,s,u,m,o,L.value,S?.id,a.session,a.user]),T=ft({open:t,lastKnownPayStepId:_,locale:n}),C=ut(W,u),{logInitiationEvent:H}=at({rpc:C,iframe:u,accessToken:w,iframeSourceLoaded:f,open:t});Ne({enabled:!!u,onTimeout:()=>{f||(H("ecp_spi_debug_initiation_failed","Installments iframe did not load within timeout; initiation failed"),r(),d(!1))},timeout:6e3}),h(()=>{(e||!b)&&(m.log("installments_progress_reset","[Installments] Installments progress reset",{reason:b?"checkoutDetails":"installmentsPayment"}),N.current=void 0)},[e,b,m]),h(()=>{C&&w&&C.updateAuthorization({accessToken:w})},[C,w]),h(()=>{const I=!p&&e?.installmentsProposalData?.taxAmount!==void 0;C&&t&&e&&I&&!b&&(m.log("installments_proposal_data_passed_to_iframe","[Installments] Proposal data passed to iframe"),C.updateCheckout(e,N.current))},[e,b,t,C,p,m]),h(()=>{C&&S?.id&&C.updateCard(S.id)},[C,S?.id]),h(()=>{C&&g&&C.setInitialUserState(g)},[C,g]);const $=()=>{U(!1),s()};return f===!1?D(xe,{open:E,size:"large",onHide:$,accessibilityLabel:l.translate("installments.pay_in_installments_error_title"),children:D(ke,{blockAlignment:"center",minBlockSize:"200px",children:D(De,{alignItems:"center",gap:"base",children:[D(Le,{level:2,textAlign:"center",children:l.translate("installments.pay_in_installments_error_title")}),D(we,{textAlign:"center",children:l.translate("installments.pay_in_installments_error_description")})]})})}):T?D(Qe,{accessibilityLabel:l.translate("installments.pay_in_installments_title"),allow:ht,blocking:!0,iframeId:gt,iframeRef:R,open:t,source:T}):null}function vt(e){const t=ee().customAttributes;return me(()=>{if(!e.value)return;const s=je(qe,t.value),r=s?JSON.parse(s.value):void 0;if(r)return{...r,zoneCode:r.provinceCode,postalCode:r.zip}})}function ue(e){if(!e)return"";const t=e.shippingAddress?{countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode}:void 0,s=e.merchandiseLines.map((n,l)=>({id:n.stableId??n.id??`__idx_${l}`,quantity:n.quantity,totalPrice:n.totalPrice})).sort((n,l)=>n.id<l.id?-1:n.id>l.id?1:0),r=e.storeAddress?{key:e.storeAddress.key,value:e.storeAddress.value}:void 0;return JSON.stringify({sellerId:e.sellerId,channel:e.channel,deliveryMethod:e.deliveryMethod,merchandiseLines:s,shippingAddress:t,shippingAmount:e.shippingAmount,storeAddress:r,taxAmount:e.taxAmount,total:e.total})}function Ct(){const[e,t]=P(),[s,r]=P(!1),{value:n}=he(),l=It().value,m=fe(e),{locale:a}=O().i18n;return h(()=>
1{if(!n||!l){t(void 0);return}const o={format:"${{amount}}",decimal_mark:".",thousands_separator:","};if(!e){t({currencyFormat:o,installmentsProposalData:l,paymentDue:n,locale:a});return}const p=ue(l)!==ue(e.installmentsProposalData);p&&t({currencyFormat:o,installmentsProposalData:l,paymentDue:n,locale:a}),r(p)},[e,l,n,a]),Y(()=>({checkoutProposal:e,previousCheckoutProposal:m,hasChanged:s}),[e,m,s])}function It(){const{shopPay:e,checkout:t}=O(),s=pe(),{merchandiseLines:r,taxes:n,paymentMethods:l}=ee(),m=Ye("ONE_TIME_PURCHASE"),a=vt(s),o=he();return me(()=>{const p=r.value?.lines.filter(({quantity:_})=>_>0);if(!p)return;const c=s.value,f=We(m.value),d=e.session.selectedShippingAddress.value,u=Ge(c,f),i=Pt(n.value);return{sellerId:ge(l.value)?.sellerId,merchandiseLines:p,shippingAddress:t.isShippingRequired.value?d?.address:void 0,shippingAmount:f?.costAfterDiscounts,taxAmount:i,total:o.value,channel:c?ce.RetailPos:ce.Online,deliveryMethod:u,storeAddress:a.value}})}function Pt(e){switch(e?.status){case"available_total":return e.totalTax;case"available_total_included":return e.totalIncludedInTarget;default:return}}function en(){const{i18n:e,shopPay:t,observability:s}=O(),{locale:r}=e,n=Ct(),l=Je(n,200),{onInstallmentsError:m}=et(),{countryCode:a,defaultLocale:o,checkoutLocaleSupported:p}=Xe(Ze),c=t.installments,f=c.isModalOpen.value,d=c.isModalClosedForRetry.value,u=a.value?`${o.value}-${a.value}`:o.value,i=F(()=>{s.log("installments_modal_closed","[Installments] Modal closed"),c.unstable_setModalOpen(!1)},[s,c]);return h(()=>{n?.hasChanged&&f&&(s.log("installments_checkout_details_changed_while_modal_open","[Installments] Checkout details changed while modal open"),i())},[n?.hasChanged,f,i,s]),h(()=>{d&&(s.log("installments_modal_closed_for_retry","[Installments] Modal closed for retry"),c.unstable_setModalCloseForRetry(!1),i())},[d,c,i,s]),D(yt,{checkoutDetails:l?.checkoutProposal,open:f,onClose:i,onError:m,locale:p.value?r:u})}export{en as InstallmentsModal};

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.