PageSourceSearch

https://www.elite.se/dist/client/assets/gift-payment-page.component-DsndO76a.js

js elite.se collected 2026-10-02 03:45:54 UTC 3,002 bytes, 1 lines download raw bytes

1import{r as e}from"./chunk-BtN6Uazr.js";import{t}from"./react-B5sKNx7D.js";import{G as n,In as r,Kt as i}from"./entry-client-DrEVLKbw.js";import{t as a}from"./useAppDispatch-j4Ju7O7A.js";import{t as o}from"./useAppSelector-tBVwsT2U.js";import{t as s}from"./ApiBase-JGqbe2rI.js";import{t as c}from"./modal.component-BrwWPyAC.js";import{a as l,i as u,n as d,r as f,t as p}from"./adyen-CD8fRSUf.js";var m=e(t()),h=class extends s{async postSessions(e,t){let n=`${this.endpoints.giftVoucher.sessions}?${new URLSearchParams({lang:t})}`;return this.fetchWithAntiforgery(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({orderId:e})},`GiftVoucher postSessions`)}},g=r(),_=({data:e,translations:t,totalPrice:r,currency:s})=>{let _=(0,m.useRef)(void 0),{endpoints:v,jwtToken:y,antiforgeryToken:b,language:x,sharedI18n:S}=o(e=>e.shared),C=a(),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(!1),O=(0,m.useMemo)(()=>new i,[]),k=(0,m.useMemo)(()=>new h(v,y,b,e=>C(n(e))),[v,y,b,C]),A=(0,m.useMemo)(()=>({useKlarnaWidget:!0}),[]),j=(0,m.useMemo)(()=>({card:{hasHolderName:!0,holderNameRequired:!0,billingAddressRequired:!1},klarna:A,klarna_account:A,klarna_paynow:A}),[A]),M=(0,m.useMemo)(()=>[l,u,f],[]),N=e.environment;(0,m.useEffect)(()=>{e.isPaymentAlreadyDone?T(!0):P(e.orderId).then()},[e,b]);async function P(e){try{let t=await F(await k.postSessions(e,x)),n=document.getElementById(`payment`);n&&new d(t,{paymentMethodsConfiguration:j,paymentMethodComponents:M}).mount(n)}catch(e){D(!0),console.error(`Error during Gift Voucher checkout:`,e)}}async function F(t){return p({clientKey:e.clientKey,locale:`sv_SE`,environment:N,session:t,showPayButton:!0,beforeSubmit:(e,t,n
1)=>(_.current=e.paymentMethod?.type,n.resolve(e)),onPaymentCompleted:(e,t)=>{I(e,t)},onPaymentFailed:(e,t)=>{e&&I(e,t)},onError:(e,t)=>{console.error(`onError`),console.error(e.name,e.message,e.stack,t),I(e,t)}})}function I(t,n){let i=()=>{if(!e.redirectUrl)return console.error(`Redirect URL is not defined.`),null;let t=new URL(e.redirectUrl,window.location.origin);return _.current?.trim()&&t.searchParams.append(`gatewayMethod`,_.current),t.toString()},a=()=>{typeof window>`u`||(window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:`gift_card_purchase`,value:r,currency:s}))};if(`resultCode`in t)switch(t.resultCode){case`Authorised`:console.info(`Order has been successfully placed.`),a(),O.clear(),setTimeout(()=>{if(typeof window>`u`)return;let e=i();e&&(window.location.href=e)},2e3);break;default:console.info(`Order has been received! Payment completion pending.`);break}}return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{className:`payment-information`,children:w&&t.paymentCompleted}),E&&(0,g.jsx)(c,{onHandleClose:()=>{D(!1)},isVisible:E,closeButtonVisible:!0,closeButtonText:S.sharedResource.closeButton,content:(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h2`,{children:t.errorHeader}),(0,g.jsx)(`p`,{children:t.errorUnableToStartPaymentSession})]})})]})};export{_ 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.