straumur-web-component 2.0.0-alpha.2 → 2.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
`);var Ne=require("preact/hooks"),ye=({children:e,content:t})=>{let[r,o]=(0,Ne.useState)(!1),a=(0,Ne.useRef)(null);return(0,Be.h)("div",{style:{position:"relative"}},(0,Be.h)("div",{ref:a,onMouseEnter:()=>{o(!0)},onMouseLeave:()=>{o(!1)}},e),r&&a&&(0,Be.h)("div",{className:"straumur__tooltip__content"},t))};var He=require("preact/hooks");function pt(e){let t=()=>window.matchMedia(e).matches,[r,o]=(0,He.useState)(t);return(0,He.useEffect)(()=>{let a=window.matchMedia(e),n=i=>o(i.matches);return o(a.matches),a.addEventListener("change",n),()=>{a.removeEventListener("change",n)}},[e]),r}function Ue({brands:e,brandHidden:t=[],limit:r=3}){let o=pt("(max-width: 380px)"),n=pt("(max-width: 335px)")?1:o?2:r,i=e.filter(l=>{let{brand:m}=l;return!t.some(v=>v.brand===m)});return(0,M.h)(M.Fragment,null,i.map(({brand:l},m)=>m>=Math.min(r,n)?m===Math.min(r,n)?(0,M.h)(ye,{content:(0,M.h)("span",{style:{display:"flex",gap:"4px",overflow:"visible"}},i.slice(Math.min(r,n)).map(({brand:d})=>(0,M.h)(Le,{key:d,brand:d})))},(0,M.h)("span",{key:l,className:"straumur__render-brand-icons__overflow"},"+",i.length-Math.min(r,n))):null:(0,M.h)(Le,{key:l,brand:l})))}var Le=({brand:e,defaultToBrandName:t=!0})=>{switch(e){case"visa":return(0,M.h)(Ht,null);case"mc":return(0,M.h)(Nt,null);case"maestro":return(0,M.h)(Lt,null);case"amex":return(0,M.h)(Ut,null);case"jcb":return(0,M.h)(Zt,null);case"diners":return(0,M.h)(Ot,null);case"discover":return(0,M.h)(Gt,null);case"cup":return(0,M.h)(Vt,null);default:return t?(0,M.h)("span",null,e):(0,M.h)(M.Fragment,null)}};var u=require("preact"),A=require("preact/hooks");var Ke=require("@adyen/adyen-web");var te=require("preact"),Or=()=>(0,te.h)("svg",{width:"21",height:"20",viewBox:"0 0 21 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,te.h)("g",{"clip-path":"url(#clip0_10626_39119)"},(0,te.h)("path",{d:"M10.6641 7.5C11.3543 7.5 11.9141 6.94023 11.9141 6.25C11.9141 5.55977 11.3543 5 10.6641 5C9.97383 5 9.41406 5.55859 9.41406 6.25C9.41406 6.94141 9.97266 7.5 10.6641 7.5ZM12.2266 13.125H11.6016V9.6875C11.6016 9.17188 11.1836 8.75 10.6641 8.75H9.41406C8.89844 8.75 8.47656 9.17188 8.47656 9.6875C8.47656 10.2031 8.89844 10.625 9.41406 10.625H9.72656V13.125H9.10156C8.58594 13.125 8.16406 13.5469 8.16406 14.0625C8.16406 14.5781 8.58594 15 9.10156 15H12.2266C12.7441 15 13.1641 14.5801 13.1641 14.0625C13.1641 13.5449 12.7461 13.125 12.2266 13.125Z",fill:"currentColor"}),(0,te.h)("path",{opacity:"0.4",d:"M10.6641 0C5.14062 0 0.664062 4.47656 0.664062 10C0.664062 15.5234 5.14062 20 10.6641 20C16.1875 20 20.6641 15.5234 20.6641 10C20.6641 4.47656 16.1875 0 10.6641 0ZM10.6641 5C11.3543 5 11.9141 5.55977 11.9141 6.25C11.9141 6.94023 11.3543 7.5 10.6641 7.5C9.97383 7.5 9.41406 6.94141 9.41406 6.25C9.41406 5.55859 9.97266 5 10.6641 5ZM12.2266 15H9.10156C8.58594 15 8.16406 14.582 8.16406 14.0625C8.16406 13.543 8.58398 13.125 9.10156 13.125H9.72656V10.625H9.41406C8.89648 10.625 8.47656 10.2051 8.47656 9.6875C8.47656 9.16992 8.89844 8.75 9.41406 8.75H10.6641C11.1816 8.75 11.6016 9.16992 11.6016 9.6875V13.125H12.2266C12.7441 13.125 13.1641 13.5449 13.1641 14.0625C13.1641 14.5801 12.7461 15 12.2266 15Z",fill:"currentColor"})),(0,te.h)("defs",null,(0,te.h)("clipPath",{id:"clip0_10626_39119"},(0,te.h)("rect",{width:"20",height:"20",fill:"white",transform:"translate(0.664062)"})))),Ze=Or;var de=require("preact"),Gr=()=>(0,de.h)("svg",{width:"40",height:"40",viewBox:"0 0 40 40",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor"},(0,de.h)("g",{fill:"none","fill-rule":"evenodd"},(0,de.h)("g",{transform:"translate(2 2)","stroke-width":"4"},(0,de.h)("circle",{"stroke-opacity":".3",cx:"18",cy:"18",r:"18"}),(0,de.h)("path",{d:"M36 18c0-9.94-8.06-18-18-18"},(0,de.h)("animateTransform",{attributeName:"transform",type:"rotate",from:"0 18 18",to:"360 18 18",dur:"1s",repeatCount:"indefinite"}))))),re=Gr;var ht=require("preact"),Vr=({color:e="var(--straumur__color-primary)"})=>(0,ht.h)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"13",viewBox:"0 0 16 13",fill:"none"},(0,ht.h)("path",{d:"M2 7L6 11L14 2",stroke:e,"stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round"})),Oe=Vr;var oe=require("preact");function Wt({brand:e,brandName:t,isSelected:r,onBrandClick:o}){let a=n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),n.currentTarget.click())};return(0,oe.h)("span",{className:"straumur__card-component__dual-branding--logo"+(r?" straumur__card-component__dual-branding--logo--selected":""),title:e,"data-value":e,onClick:o,onKeyDown:a,role:"radio","aria-checked":r,"aria-label":t??e,tabIndex:0},(0,oe.h)("div",{className:"straumur__card-component__dual-branding--logo--item"},(0,oe.h)(Le,{brand:e,defaultToBrandName:!1}),"\xA0",t??""),r&&(0,oe.h)(Oe,{color:"var(--straumur__color-neon-green-zeta)"}))}function jt({dualBrandConfiguration:e,selectedBrand:t,onBrandClick:r}){return(0,oe.h)("div",{className:"straumur__card-component__dual-branding",role:"radiogroup","aria-label":"Card brand"},(0,oe.h)(Wt,{brand:e.brand1,brandName:e.brand1Name,isSelected:t===e.brand1,onBrandClick:r}),(0,oe.h)(Wt,{brand:e.brand2,brandName:e.brand2Name,isSelected:t===e.brand2,onBrandClick:r}))}var Wr=["AuthenticationFinished","AuthenticationNotRequired","Authorised","Cancelled","ChallengeShopper","Error","IdentifyShopper","PartiallyAuthorised","Pending","PresentToShopper","Received","RedirectShopper","Refused"];function ft(e){return e&&Wr.includes(e)?e:"Error"}var F=class extends Error{messageKey;messageText;constructor(t,r){super(r??t),this.messageKey=t,this.messageText=r}};function we(e,t){return e instanceof F?e.messageText?{text:e.messageText}:{key:e.messageKey}:{key:t}}function Kt(e,t){return{async submitPayment(r){let o={...r,sessionId:t},a=await St(e,o);if(!a.ok)throw new F("error.failedToSubmitPayment");let n=await a.json();if(!n.resultCode)throw new F("error.paymentFailed");return{resultCode:n.resultCode,action:n.action}},async submitAdditionalDetails(r){let o={...r,sessionId:t},a=await xt(e,o);if(!a.ok)throw new F("error.failedToSubmitPaymentDetails");let n=await a.json();if(!n.resultCode)throw new F("error.paymentDetailsFailed");return{resultCode:n.resultCode,action:n.action}},async disableToken(r){let a=await wt(e,{storedPaymentMethodId:r,sessionId:t});if(!a.ok)throw new F("error.failedToSubmitRemoveStoredPaymentCard");if(!(await a.json()).success)throw new F("error.failedToRemoveStoredPaymentCard")}}}function Jt(e){function t(a,n,i,l){let m=d=>i(d instanceof F?d:new F(l));try{Promise.resolve(a(n,i)).catch(m)}catch(d){m(d)}}let r={submitPayment(a){return new Promise((n,i)=>{t((l,m)=>e.onSubmit({data:a},{resolve:l,reject:d=>m(new F("error.failedToSubmitPayment",d))}),n,i,"error.failedToSubmitPayment")})},submitAdditionalDetails(a){return new Promise((n,i)=>{t((l,m)=>e.onAdditionalDetails({data:a},{resolve:l,reject:d=>m(new F("error.failedToSubmitPaymentDetails",d))}),n,i,"error.failedToSubmitPaymentDetails")})},beforeSubmit:e.onBeforeSubmit},{onDisableToken:o}=e;return o&&(r.disableToken=a=>new Promise((n,i)=>{t((l,m)=>o({storedPaymentMethodId:a},{resolve:()=>l(),reject:()=>m(new F("error.failedToRemoveStoredPaymentCard"))}),n,i,"error.failedToSubmitRemoveStoredPaymentCard")})),r}async function yt(e){let{beforeSubmit:t}=e;return!t||await t()}async function Ge(e,t){t()&&await yt(e)&&t()?.submit()}function vt(e){return(t,r)=>{let{beforeSubmit:o}=e;if(!o){t();return}let a=o();if(a instanceof Promise){a.then(n=>n?t():r()).catch(()=>r());return}if(a){t();return}r()}}var jr=["Refused","Cancelled","Error"];function ae(e){let{configuration:t,handleSuccess:r,handleError:o,setThreeDSecureActive:a,enrichSubmitData:n,onSubmitStart:i,dispatchResultFromAdditionalDetails:l}=e,m;function d(){return m?{text:m}:{key:"error.paymentUnsuccessful"}}function v(g){g==="Authorised"?r({key:"success.paymentAuthorized"}):o(d()),jr.includes(g)?t.onPaymentFailed?.({resultCode:g}):t.onPaymentCompleted?.({resultCode:g})}async function y(g,R,T){i?.();let{paymentFlow:E}=t;if(!await yt(E)){T.reject();return}try{let z=n?n(g.data):g.data,{resultCode:p,action:j,errorMessage:N}=await E.submitPayment(z);m=N,(p==="ChallengeShopper"||p==="IdentifyShopper")&&a(!0),T.resolve({resultCode:p,action:j})}catch(z){T.reject(),o(we(z,"error.failedToSubmitPayment"))}}async function P(g,R,T){try{let{resultCode:E,action:z,errorMessage:p}=await t.paymentFlow.submitAdditionalDetails(g.data);m=p,T.resolve({resultCode:E,action:z}),l&&v(E)}catch(E){T.reject(),o(we(E,"error.failedToSubmitPaymentDetails")),l&&t.onPaymentFailed?.({resultCode:"Error"})}}function k(g,R){v(ft(g.resultCode))}function B(g,R){v(g?ft(g.resultCode):"Error")}return{handleOnSubmit:y,handleOnSubmitAdditionalData:P,handlePaymentCompleted:k,handlePaymentFailed:B}}var $t=require("preact/hooks");function ve(e,t,r){(0,$t.useEffect)(()=>{t()&&r()},[e])}var Xt=require("preact/hooks");function Ve(e,t){(0,Xt.useEffect)(()=>{t&&e.current?.focus()},[t,e])}var We=require("preact/hooks"),qt="(prefers-color-scheme: dark)";function Kr(){return typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(qt).matches:!1}function _e(e){let[t,r]=(0,We.useState)(Kr);return(0,We.useEffect)(()=>{if(e!=="system"||typeof window>"u"||typeof window.matchMedia!="function")return;let o=window.matchMedia(qt),a=n=>r(n.matches);return r(o.matches),o.addEventListener("change",a),()=>o.removeEventListener("change",a)},[e]),e==="system"?t?"dark":"light":e}function je(e){return e==="dark"?{base:{color:"#e8edf2"},placeholder:{color:"#9aa7b5"},error:{color:"#e08a8a"}}:{base:{color:"#00112c"},placeholder:{color:"#72889d"},error:{color:"#d96666"}}}function Jr({configuration:e,paymentMethods:t,onBrandHidden:r}){let o=(0,A.useRef)(null),a=(0,A.useRef)(),n=(0,A.useRef)(),{i18n:i}=G(),[l,m]=(0,A.useState)(!0),[d,v]=(0,A.useState)("required"),[y,P]=(0,A.useState)(!1),[k,B]=(0,A.useState)(!1),[g,R]=(0,A.useState)(null),[T,E]=(0,A.useState)(null),z=(0,A.useRef)(!1),[p,j]=(0,A.useState)({encryptedCardNumber:{visible:!1},encryptedExpiryDate:{visible:!1},encryptedSecurityCode:{visible:!1}}),{activePaymentMethod:N,isPaymentMethodInitialized:D,updatePaymentMethodInitialization:Y,handleSuccess:H,handleError:V,setThreeDSecureActive:Q,threeDSecureActive:K,isObscuredByThreeDS:O,hasCard:pe,registerSubmitHandler:b,unregisterSubmitHandler:ee}=x(),ie=_e(e.theme);async function Pe(){await Ge(e.paymentFlow,()=>n.current)}(0,A.useEffect)(()=>{if(!(N==="card"&&D.card)){e.onCardValidityChanged?.(!1,!1);return}return b(Pe),()=>{ee(Pe),e.onCardValidityChanged?.(!1,!1)}},[N,D.card,b,ee]);let Se=t.paymentMethods?.paymentMethods?.find(h=>h.type==="scheme")?.brands??[],{handleOnSubmit:st,handleOnSubmitAdditionalData:Ie,handlePaymentCompleted:it,handlePaymentFailed:lt}=ae({configuration:e,handleSuccess:H,handleError:V,setThreeDSecureActive:Q,enrichSubmitData:h=>({...h,storePaymentMethod:z.current})});function mt(h,C){V({key:"error.unknownError"})}let Ee=async()=>{n.current?.remove(),a.current=await(0,Ke.AdyenCheckout)({clientKey:t.clientKey,environment:e.environment,locale:e.locale,countryCode:e.countryCode,paymentMethodsResponse:t.paymentMethods,amount:{value:t.minorUnitsAmount,currency:t.currency},onSubmit:st,onAdditionalDetails:Ie,onError:mt,onPaymentCompleted:it,onPaymentFailed:lt}),n.current=new Ke.CustomCard(a.current,{brands:Se,placeholders:e.placeholders,styles:je(ie),challengeWindowSize:"05",onBinLookup:h=>{h.supportedBrandsRaw&&h.supportedBrandsRaw.length>1&&(B(!0),R({brand1:h.supportedBrandsRaw[0].brand,brand1Name:h.supportedBrandsRaw[0].localeBrand,brand1ImageUrl:h.supportedBrandsRaw[0].brandImageUrl,brand2:h.supportedBrandsRaw[1].brand,brand2Name:h.supportedBrandsRaw[1].localeBrand,brand2ImageUrl:h.supportedBrandsRaw[1].brandImageUrl}))},onBrand:h=>{if(v(h.cvcPolicy),h.brand==="card"){r([]),E(null);return}let C=Se.filter(S=>S!==h.brand).map(S=>({brand:S}));r(C),Se.filter(S=>S===h.brand).map(S=>({brand:S})).length===1&&E(h.brand)},onConfigSuccess(){Y("card",!0)},onValidationError:h=>{let C={encryptedCardNumber:{visible:!1,message:void 0},encryptedExpiryDate:{visible:!1,message:void 0},encryptedSecurityCode:{visible:!1,message:void 0}};h.filter(S=>S.error).forEach(S=>{C[S.fieldType].visible=!0,C[S.fieldType].message=S.errorI18n}),j(C)},onAllValid:h=>{m(!h.allValid),e.onCardValidityChanged?.(h.allValid,!0)}}),o.current&&n.current.mount(o.current)};(0,A.useEffect)(()=>{pe&&N==="card"&&!D.card&&Ee()},[e,N]),ve(e,()=>!!(n.current&&D.card),()=>{Ee(),j({encryptedCardNumber:{visible:!1,message:void 0},encryptedExpiryDate:{visible:!1,message:void 0},encryptedSecurityCode:{visible:!1,message:void 0}})}),(0,A.useEffect)(()=>{z.current=y},[y]);function Ct(h){n.current.dualBrandingChangeHandler(h)}function dt(h){P(h.currentTarget.checked)}return Ve(o,K&&N==="card"),!pe||O("card")||t.paymentMethods?.paymentMethods?.length===0?null:(0,u.h)("div",{className:"straumur__card-component__expandable",ref:o,tabIndex:-1,style:{height:K?"600px":"auto",minWidth:K?"350px":"auto"}},!D.card&&(0,u.h)("div",{className:"straumur__card-component__loading-text"},(0,u.h)(re,null)),(0,u.h)("div",{className:"straumur__card-component__form",style:{opacity:D.card&&!K?1:0,position:D.card&&!K?"relative":"absolute",transition:"opacity 0.3s ease-in-out"}},(0,u.h)("div",{className:"straumur__card-component__form--wrapper"},(0,u.h)("label",{className:`straumur__card-component__form--wrapper--label ${p.encryptedCardNumber.visible?"straumur__card-component__form--wrapper--label--error":""}`},i.t("cards.cardNumber")),(0,u.h)("span",{className:`straumur__card-component__form--wrapper--input ${p.encryptedCardNumber.visible?"straumur__card-component__form--wrapper--input--error":""}`,"data-cse":"encryptedCardNumber",role:"group","aria-label":i.t("cards.cardNumber")}),p.encryptedCardNumber.visible&&(0,u.h)("span",{className:"straumur__card-component__form--wrapper--error"},p.encryptedCardNumber.message)),(0,u.h)("div",{className:"straumur__card-component__form--field-wrapper"},(0,u.h)("div",{className:"straumur__card-component__form--wrapper"},(0,u.h)("label",{className:`straumur__card-component__form--wrapper--label ${p.encryptedExpiryDate.visible?"straumur__card-component__form--wrapper--label--error":""}`},i.t("cards.expiryDate")),(0,u.h)("span",{className:`straumur__card-component__form--wrapper--input ${p.encryptedExpiryDate.visible?"straumur__card-component__form--wrapper--input--error":""}`,"data-cse":"encryptedExpiryDate",role:"group","aria-label":i.t("cards.expiryDate")}),p.encryptedExpiryDate.visible&&(0,u.h)("span",{className:"straumur__card-component__form--wrapper--error"},p.encryptedExpiryDate.message)),(0,u.h)("div",{className:"straumur__card-component__form--wrapper"},(d==="optional"||d==="required")&&(0,u.h)(u.Fragment,null,(0,u.h)("label",{className:`straumur__card-component__form--wrapper--label ${p.encryptedSecurityCode.visible?"straumur__card-component__form--wrapper--label--error":""}`},d==="optional"?i.t("cards.securityCode3DigitsOptional"):i.t("cards.securityCode3Digits")),(0,u.h)("span",{className:`straumur__card-component__form--wrapper--input ${p.encryptedSecurityCode.visible?"straumur__card-component__form--wrapper--input--error":""}`,"data-cse":"encryptedSecurityCode",role:"group","aria-label":i.t("cards.securityCode3Digits")}),p.encryptedSecurityCode.visible&&(0,u.h)("span",{className:"straumur__card-component__form--wrapper--error"},p.encryptedSecurityCode.message),(0,u.h)("div",{className:"straumur__card-component__form--wrapper--label--info"},(0,u.h)(ye,{content:(0,u.h)("span",null,i.t("cards.securityCode3DigitsInfo"))},(0,u.h)(Ze,null)))))),k&&g&&(0,u.h)(jt,{dualBrandConfiguration:g,selectedBrand:T,onBrandClick:Ct}),t.enableStoreDetails==="AskForConsent"&&(0,u.h)("label",{className:"straumur__card-component__form--wrapper--label-checkbox"},(0,u.h)("div",{className:`straumur__card-component__form--wrapper--label-checkbox--checkmark ${y?"straumur__card-component__form--wrapper--label-checkbox--checkmark--checked":""}`},(0,u.h)("div",{className:`straumur__card-component__form--wrapper--label-checkbox--checkmark--icon ${y?"straumur__card-component__form--wrapper--label-checkbox--checkmark--icon--checked":""}`},(0,u.h)(Oe,null))),(0,u.h)("input",{type:"checkbox",className:"straumur__card-component__form--wrapper--label-checkbox--checkbox",checked:y,onChange:dt}),i.t("cards.storePaymentMethod")),!e.hideSubmitButton&&(0,u.h)("button",{className:"straumur__card-component__submit-button",disabled:l,onClick:Pe},t.minorUnitsAmount===0?i.t("cards.saveCardDetails"):t.formattedAmount)))}var Yt=Jr;var ce=require("preact");_(`.straumur__payment-method-item{position:relative;cursor:pointer;background:var(--straumur__color-white);border-radius:var(--straumur__border-radius-lg);transition:all .3s ease;padding:var(--straumur__space-xxlg) var(--straumur__space-5xlg)}.straumur__payment-method-item--sole{cursor:default}.straumur__payment-method-item:has(.straumur__payment-method-item__radio-selector:checked){cursor:default}.straumur__payment-method-item__radio-selector{position:absolute;opacity:0;cursor:pointer}.straumur__payment-method-item__content{display:flex;align-items:center;gap:var(--straumur__space-lg);transition:background-color .3s ease}.straumur__payment-method-item__radio-selector:checked+.straumur__payment-method-item__content{padding-bottom:var(--straumur__space-xxlg)}.straumur__payment-method-item__content--expanded{padding-bottom:var(--straumur__space-xxlg)}.straumur__payment-method-item--circle{width:var(--straumur__space-5xlg);height:var(--straumur__space-5xlg);border:1px solid var(--straumur__color-cosmos-blue-gamma);background:var(--straumur__color-secondary-gamma);border-radius:50%;position:relative;transition:all .3s ease;flex-shrink:0}.straumur__payment-method-item__content:hover .straumur__payment-method-item--circle{border:1px solid var(--straumur__color-cosmos-blue-delta)}.straumur__payment-method-item--circle:after{content:"";position:absolute;width:100%;height:100%;border-radius:50%;top:50%;left:50%;transform:translate(-50%,-50%) scale(0);transition:transform .2s ease}.straumur__payment-method-item__radio-selector:checked+.straumur__payment-method-item__content .straumur__payment-method-item--circle{background:var(--straumur__color-blue-beta);border-color:var(--straumur__color-transparent)}.straumur__payment-method-item__radio-selector:checked+.straumur__payment-method-item__content .straumur__payment-method-item--circle:after{transform:translate(-50%,-50%) scale(1);background:var(--straumur__color-primary);height:var(--straumur__space-md);width:var(--straumur__space-md)}.straumur__payment-method-item--title{color:var(--straumur__color-text);font-size:16px;user-select:none}.straumur__payment-method-item__expandable{background:var(--straumur__color-white);max-height:0;overflow:hidden;transition:all .3s ease;opacity:0}.straumur__payment-method-item__radio-selector:checked~.straumur__payment-method-item__expandable{max-height:600px;opacity:1}.straumur__payment-method-item__expandable--visible{max-height:600px;opacity:1}
|
|
5
5
|
`);function $r({icon:e,title:t,isActive:r,isSole:o,onChange:a,children:n,headerRight:i,confirmSection:l}){return(0,ce.h)("label",{className:`straumur__payment-method-item${o?" straumur__payment-method-item--sole":""}`},!o&&(0,ce.h)("input",{type:"radio",className:"straumur__payment-method-item__radio-selector",checked:r,onChange:a}),(0,ce.h)("span",{className:`straumur__payment-method-item__content${o?" straumur__payment-method-item__content--expanded":""}`},!o&&(0,ce.h)("span",{className:"straumur__payment-method-item--circle"}),e,(0,ce.h)("span",{className:"straumur__payment-method-item--title"},t),i),l,(0,ce.h)("div",{className:`straumur__payment-method-item__expandable${o?" straumur__payment-method-item__expandable--visible":""}`},n))}var ne=$r;function Xr({configuration:e,paymentMethods:t}){let{i18n:r}=G(),[o,a]=(0,Qt.useState)([]),{activePaymentMethod:n,setActivePaymentMethod:i,isObscuredByThreeDS:l,isSolePaymentMethod:m,hasCard:d}=x();if(!d||l("card"))return null;let y=t.paymentMethods.paymentMethods.find(P=>P.type==="scheme").brands.map(P=>({brand:P,brandFullName:P}));return(0,ge.h)(ne,{icon:(0,ge.h)(Bt,null),title:r.t("cards.title"),isActive:n==="card",isSole:m,onChange:()=>i("card"),headerRight:(0,ge.h)("span",{className:"straumur__card-component--brands"},(0,ge.h)(Ue,{brands:y,brandHidden:o}))},(0,ge.h)(Yt,{configuration:e,paymentMethods:t,onBrandHidden:a}))}var er=Xr;var Xe=require("preact"),ar=require("preact/hooks");_(`.adyen-checkout__paywithgoogle{height:var(--straumur__space-8xlg)}
|
|
6
6
|
`);var $=require("preact"),qr=()=>(0,$.h)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"26",fill:"none",viewBox:"0 0 40 26"},(0,$.h)("path",{fill:"#fff",d:"M29.13 2.41H10.87C5.17 2.41.5 7.18.5 13.01a10.5 10.5 0 0 0 10.37 10.58h18.26c5.7 0 10.37-4.76 10.37-10.59 0-5.82-4.67-10.59-10.37-10.59Z"}),(0,$.h)("path",{fill:"#3C4043",d:"M29.13 3.27c1.28 0 2.52.26 3.7.77a9.6 9.6 0 0 1 5.08 5.19 9.78 9.78 0 0 1 0 7.55 9.83 9.83 0 0 1-5.08 5.18 9.26 9.26 0 0 1-3.7.77H10.87a9.24 9.24 0 0 1-3.7-.77 9.6 9.6 0 0 1-5.08-5.18 9.78 9.78 0 0 1 0-7.55 9.83 9.83 0 0 1 5.08-5.19 9.24 9.24 0 0 1 3.7-.77h18.26Zm0-.86H10.87C5.17 2.41.5 7.18.5 13.01a10.5 10.5 0 0 0 10.37 10.58h18.26c5.7 0 10.37-4.76 10.37-10.59 0-5.82-4.67-10.59-10.37-10.59Z"}),(0,$.h)("path",{fill:"#3C4043",d:"M19.1 13.75v3.2h-1v-7.9h2.64c.67 0 1.24.23 1.7.68.49.46.72 1.01.72 1.67a2.2 2.2 0 0 1-.71 1.68c-.46.45-1.03.67-1.7.67H19.1Zm0-3.73v2.76h1.66c.4 0 .73-.14.99-.4.26-.28.4-.6.4-.98 0-.36-.14-.68-.4-.95a1.28 1.28 0 0 0-.99-.42H19.1Zm6.67 1.35c.73 0 1.31.2 1.74.6.42.4.64.95.64 1.65v3.34h-.95v-.76h-.04a1.9 1.9 0 0 1-1.65.93 2.1 2.1 0 0 1-1.46-.53c-.4-.35-.6-.8-.6-1.32 0-.56.21-1 .63-1.34.41-.33.97-.5 1.66-.5.59 0 1.07.12 1.45.34v-.23c0-.36-.13-.65-.4-.9a1.4 1.4 0 0 0-.97-.37c-.56 0-1 .24-1.32.72l-.88-.56a2.42 2.42 0 0 1 2.15-1.07Zm-1.29 3.92c0 .27.11.5.33.67.22.17.48.26.78.26.42 0 .79-.16 1.12-.48.32-.31.49-.68.49-1.11a2.02 2.02 0 0 0-1.3-.38c-.4 0-.74.1-1.01.3a.9.9 0 0 0-.4.74Zm9.08-3.75-3.32 7.8h-1.02l1.23-2.73-2.19-5.07h1.09l1.57 3.89h.02l1.54-3.89h1.08Z"}),(0,$.h)("path",{fill:"#4285F4",d:"M15.14 13.1c0-.32-.03-.64-.09-.95h-4.17v1.75h2.4a2.1 2.1 0 0 1-.89 1.4v1.14h1.43a4.49 4.49 0 0 0 1.32-3.33Z"}),(0,$.h)("path",{fill:"#34A853",d:"M12.4 15.3a2.66 2.66 0 0 1-4-1.44H6.9v1.18a4.43 4.43 0 0 0 6.91 1.4l-1.43-1.13Z"}),(0,$.h)("path",{fill:"#FABB05",d:"M8.25 13c0-.3.05-.59.14-.86v-1.17H6.9a4.59 4.59 0 0 0 0 4.07l1.48-1.17a2.79 2.79 0 0 1-.14-.86Z"}),(0,$.h)("path",{fill:"#E94235",d:"M10.88 10.27c.66 0 1.24.23 1.7.68l1.27-1.3a4.22 4.22 0 0 0-2.97-1.18 4.44 4.44 0 0 0-3.97 2.5l1.48 1.17a2.66 2.66 0 0 1 2.5-1.87Z"})),tr=qr;_(`.straumur__google-pay-button__loading{display:flex;justify-content:center}
|
|
7
|
-
`);var or=require("preact");var ue=require("preact"),be=require("preact/hooks"),Ce=require("@adyen/adyen-web");var rr="CANCEL";var Yr={applepay:{loadingClassName:"straumur__apple-pay-button__loading",createElement(e,{configuration:t,paymentMethods:r,walletConfig:o,handleOnSubmit:a}){let n={amount:{value:r.minorUnitsAmount,currency:r.currency},environment:t.environment,onSubmit:a,onClick:vt(t.paymentFlow),configuration:{...o,merchantName:r.merchantName}};return new Ce.ApplePay(e,n)}},googlepay:{loadingClassName:"straumur__google-pay-button__loading",createElement(e,{configuration:t,paymentMethods:r,walletConfig:o,handleOnSubmit:a}){let n={amount:{value:r.minorUnitsAmount,currency:r.currency},challengeWindowSize:"05",countryCode:t.countryCode,environment:t.environment,onSubmit:a,onClick:vt(t.paymentFlow),buttonSizeMode:"fill",configuration:{...o,merchantName:r.merchantName}};return new Ce.GooglePay(e,n)}}};function Qr({method:e,configuration:t,paymentMethods:r,isInstantPayment:o,onUnavailable:a}){let n=Yr[e],i=(0,be.useRef)(null),l=(0,be.useRef)(),m=(0,be.useRef)(),{isPaymentMethodInitialized:d,updatePaymentMethodInitialization:v,handleSuccess:y,handleError:P,setThreeDSecureActive:k,threeDSecureActive:B,isObscuredByThreeDS:g,setActivePaymentMethod:R,activePaymentMethod:T}=x(),{handleOnSubmit:E,handleOnSubmitAdditionalData:z,handlePaymentCompleted:p,handlePaymentFailed:j}=ae({configuration:t,handleSuccess:y,handleError:P,setThreeDSecureActive:k,onSubmitStart:()=>{o&&R(e)}});function N(H,V){H.name!==rr&&P({key:"error.unknownError"})}function D(){v(e,!0),T===e&&R(null),a?.()}let Y=async()=>{l.current=await(0,Ce.AdyenCheckout)({clientKey:r.clientKey,environment:t.environment,locale:t.locale,countryCode:t.countryCode,paymentMethodsResponse:r.paymentMethods,amount:{value:r.minorUnitsAmount,currency:r.currency},onError:N,onAdditionalDetails:z,onPaymentCompleted:p,onPaymentFailed:j});let V=r.paymentMethods.paymentMethods?.find(Q=>Q.type===e)?.configuration;if(!V){D();return}m.current=n.createElement(l.current,{configuration:t,paymentMethods:r,walletConfig:V,handleOnSubmit:E}),m.current.isAvailable().then(()=>{m.current.mount(i.current),v(e,!0)}).catch(()=>{D()})};return(0,be.useEffect)(()=>{d[e]||Y()},[t]),ve(t,()=>!!(m.current&&d[e]),()=>{m.current.remove(),Y()}),g(e)?null:(0,ue.h)(ue.Fragment,null,d[e]===!1&&(0,ue.h)("div",{className:n.loadingClassName},(0,ue.h)(re,null)),(0,ue.h)("div",{ref:i,style:{height:B?"600px":"auto",minWidth:B?"350px":"auto",position:d[e]?"static":"absolute"}}))}var Je=Qr;function eo(e){return(0,or.h)(Je,{method:"googlepay",...e})}var $e=eo;function to({configuration:e,paymentMethods:t}){let{i18n:r}=G(),{activePaymentMethod:o,setActivePaymentMethod:a,isObscuredByThreeDS:n,isSolePaymentMethod:i,hasGooglePay:l}=x(),[m,d]=(0,ar.useState)(!1);return!l||m||e.instantPayments&&e.instantPayments.some(v=>v==="googlepay")||n("googlepay")?null:(0,Xe.h)(ne,{icon:(0,Xe.h)(tr,null),title:r.t("googlePay.title"),isActive:o==="googlepay",isSole:i,onChange:()=>a("googlepay")},(0,Xe.h)($e,{configuration:e,paymentMethods:t,isInstantPayment:!1,onUnavailable:()=>d(!0)}))}var nr=to;var Ye=require("preact"),lr=require("preact/hooks");_("");var Me=require("preact"),ro=()=>(0,Me.h)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"26",fill:"none",viewBox:"0 0 40 26"},(0,Me.h)("path",{fill:"#000",d:"M36.42 0H3.58a69.25 69.25 0 0 0-.75 0c-.25.01-.5.03-.76.07a2.51 2.51 0 0 0-1.32.7A2.43 2.43 0 0 0 .07 2.1 5.14 5.14 0 0 0 0 3.22v19.91c.01.25.03.51.07.76a2.6 2.6 0 0 0 .68 1.35 2.39 2.39 0 0 0 1.32.69 4.98 4.98 0 0 0 1.1.07h34a5 5 0 0 0 .76-.07 2.5 2.5 0 0 0 1.32-.7 2.44 2.44 0 0 0 .68-1.34 5.13 5.13 0 0 0 .07-1.11V2.87a6.5 6.5 0 0 0-.07-.76 2.58 2.58 0 0 0-.68-1.35 2.4 2.4 0 0 0-1.32-.69 4.96 4.96 0 0 0-1.1-.07h-.41Z"}),(0,Me.h)("path",{fill:"#fff",d:"M36.42.87h.73c.2 0 .42.02.62.06a1.67 1.67 0 0 1 .88.44 1.58 1.58 0 0 1 .44.89 4.38 4.38 0 0 1 .06.97v19.55a14.67 14.67 0 0 1-.06.96 1.7 1.7 0 0 1-.44.89 1.54 1.54 0 0 1-.87.44 4.27 4.27 0 0 1-.96.06H2.85a3.7 3.7 0 0 1-.63-.06 1.66 1.66 0 0 1-.87-.45 1.56 1.56 0 0 1-.44-.88 4.35 4.35 0 0 1-.06-.97V2.9c.01-.2.02-.42.06-.63.03-.18.08-.34.16-.49A1.56 1.56 0 0 1 2.22.93a4.2 4.2 0 0 1 .96-.06h33.24"}),(0,Me.h)("path",{fill:"#000",d:"M10.92 8.61c.34-.43.57-1 .51-1.59a2.21 2.21 0 0 0-1.99 2.3c.56.04 1.12-.3 1.48-.7Zm.51.81c-.82-.05-1.52.46-1.9.46-.4 0-1-.43-1.64-.42-.84 0-1.62.48-2.05 1.24-.88 1.52-.23 3.76.62 5 .42.6.92 1.27 1.58 1.25.62-.02.86-.4 1.62-.4.75 0 .97.4 1.63.39.69-.01 1.11-.61 1.53-1.22.47-.7.67-1.37.68-1.4-.01-.02-1.32-.52-1.33-2.02-.01-1.26 1.03-1.85 1.07-1.9a2.34 2.34 0 0 0-1.81-.98Zm7.11-1.7a2.87 2.87 0 0 1 3.02 3c0 1.8-1.27 3.03-3.06 3.03h-1.97v3.12h-1.42V7.72h3.43Zm-2 4.83h1.62c1.24 0 1.94-.66 1.94-1.82 0-1.15-.7-1.81-1.93-1.81h-1.64v3.63Zm5.39 2.43c0-1.17.9-1.89 2.48-1.98l1.83-.1v-.52c0-.74-.5-1.18-1.34-1.18-.8 0-1.3.38-1.41.97h-1.3c.08-1.2 1.1-2.09 2.76-2.09 1.62 0 2.65.86 2.65 2.2v4.6h-1.31v-1.1h-.04a2.38 2.38 0 0 1-2.1 1.2c-1.3 0-2.22-.8-2.22-2Zm4.3-.6v-.53l-1.64.1c-.82.06-1.28.42-1.28.99 0 .58.48.96 1.22.96.96 0 1.7-.66 1.7-1.52Zm2.61 4.95v-1.11c.1.03.33.03.44.03.64 0 .98-.27 1.19-.96l.12-.4-2.41-6.69h1.48l1.7 5.43h.02l1.69-5.43h1.44l-2.5 7.02c-.57 1.62-1.23 2.14-2.61 2.14a5.3 5.3 0 0 1-.56-.03Z"})),sr=ro;_(`.straumur__apple-pay-button__loading{display:flex;justify-content:center}
|
|
7
|
+
`);var or=require("preact");var ue=require("preact"),be=require("preact/hooks"),Ce=require("@adyen/adyen-web");var rr="CANCEL";var Yr={applepay:{loadingClassName:"straumur__apple-pay-button__loading",createElement(e,{configuration:t,paymentMethods:r,walletConfig:o,handleOnSubmit:a}){let n={amount:{value:r.minorUnitsAmount,currency:r.currency},environment:t.environment,onSubmit:a,onClick:vt(t.paymentFlow),configuration:{...o,merchantName:r.merchantName}};return new Ce.ApplePay(e,n)}},googlepay:{loadingClassName:"straumur__google-pay-button__loading",createElement(e,{configuration:t,paymentMethods:r,walletConfig:o,handleOnSubmit:a}){let n={amount:{value:r.minorUnitsAmount,currency:r.currency},challengeWindowSize:"05",countryCode:t.countryCode,environment:t.environment,onSubmit:a,onClick:vt(t.paymentFlow),buttonSizeMode:"fill",buttonRadius:8,configuration:{...o,merchantName:r.merchantName}};return new Ce.GooglePay(e,n)}}};function Qr({method:e,configuration:t,paymentMethods:r,isInstantPayment:o,onUnavailable:a}){let n=Yr[e],i=(0,be.useRef)(null),l=(0,be.useRef)(),m=(0,be.useRef)(),{isPaymentMethodInitialized:d,updatePaymentMethodInitialization:v,handleSuccess:y,handleError:P,setThreeDSecureActive:k,threeDSecureActive:B,isObscuredByThreeDS:g,setActivePaymentMethod:R,activePaymentMethod:T}=x(),{handleOnSubmit:E,handleOnSubmitAdditionalData:z,handlePaymentCompleted:p,handlePaymentFailed:j}=ae({configuration:t,handleSuccess:y,handleError:P,setThreeDSecureActive:k,onSubmitStart:()=>{o&&R(e)}});function N(H,V){H.name!==rr&&P({key:"error.unknownError"})}function D(){v(e,!0),T===e&&R(null),a?.()}let Y=async()=>{l.current=await(0,Ce.AdyenCheckout)({clientKey:r.clientKey,environment:t.environment,locale:t.locale,countryCode:t.countryCode,paymentMethodsResponse:r.paymentMethods,amount:{value:r.minorUnitsAmount,currency:r.currency},onError:N,onAdditionalDetails:z,onPaymentCompleted:p,onPaymentFailed:j});let V=r.paymentMethods.paymentMethods?.find(Q=>Q.type===e)?.configuration;if(!V){D();return}m.current=n.createElement(l.current,{configuration:t,paymentMethods:r,walletConfig:V,handleOnSubmit:E}),m.current.isAvailable().then(()=>{m.current.mount(i.current),v(e,!0)}).catch(()=>{D()})};return(0,be.useEffect)(()=>{d[e]||Y()},[t]),ve(t,()=>!!(m.current&&d[e]),()=>{m.current.remove(),Y()}),g(e)?null:(0,ue.h)(ue.Fragment,null,d[e]===!1&&(0,ue.h)("div",{className:n.loadingClassName},(0,ue.h)(re,null)),(0,ue.h)("div",{ref:i,style:{height:B?"600px":"auto",minWidth:B?"350px":"auto",position:d[e]?"static":"absolute"}}))}var Je=Qr;function eo(e){return(0,or.h)(Je,{method:"googlepay",...e})}var $e=eo;function to({configuration:e,paymentMethods:t}){let{i18n:r}=G(),{activePaymentMethod:o,setActivePaymentMethod:a,isObscuredByThreeDS:n,isSolePaymentMethod:i,hasGooglePay:l}=x(),[m,d]=(0,ar.useState)(!1);return!l||m||e.instantPayments&&e.instantPayments.some(v=>v==="googlepay")||n("googlepay")?null:(0,Xe.h)(ne,{icon:(0,Xe.h)(tr,null),title:r.t("googlePay.title"),isActive:o==="googlepay",isSole:i,onChange:()=>a("googlepay")},(0,Xe.h)($e,{configuration:e,paymentMethods:t,isInstantPayment:!1,onUnavailable:()=>d(!0)}))}var nr=to;var Ye=require("preact"),lr=require("preact/hooks");_("");var Me=require("preact"),ro=()=>(0,Me.h)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40",height:"26",fill:"none",viewBox:"0 0 40 26"},(0,Me.h)("path",{fill:"#000",d:"M36.42 0H3.58a69.25 69.25 0 0 0-.75 0c-.25.01-.5.03-.76.07a2.51 2.51 0 0 0-1.32.7A2.43 2.43 0 0 0 .07 2.1 5.14 5.14 0 0 0 0 3.22v19.91c.01.25.03.51.07.76a2.6 2.6 0 0 0 .68 1.35 2.39 2.39 0 0 0 1.32.69 4.98 4.98 0 0 0 1.1.07h34a5 5 0 0 0 .76-.07 2.5 2.5 0 0 0 1.32-.7 2.44 2.44 0 0 0 .68-1.34 5.13 5.13 0 0 0 .07-1.11V2.87a6.5 6.5 0 0 0-.07-.76 2.58 2.58 0 0 0-.68-1.35 2.4 2.4 0 0 0-1.32-.69 4.96 4.96 0 0 0-1.1-.07h-.41Z"}),(0,Me.h)("path",{fill:"#fff",d:"M36.42.87h.73c.2 0 .42.02.62.06a1.67 1.67 0 0 1 .88.44 1.58 1.58 0 0 1 .44.89 4.38 4.38 0 0 1 .06.97v19.55a14.67 14.67 0 0 1-.06.96 1.7 1.7 0 0 1-.44.89 1.54 1.54 0 0 1-.87.44 4.27 4.27 0 0 1-.96.06H2.85a3.7 3.7 0 0 1-.63-.06 1.66 1.66 0 0 1-.87-.45 1.56 1.56 0 0 1-.44-.88 4.35 4.35 0 0 1-.06-.97V2.9c.01-.2.02-.42.06-.63.03-.18.08-.34.16-.49A1.56 1.56 0 0 1 2.22.93a4.2 4.2 0 0 1 .96-.06h33.24"}),(0,Me.h)("path",{fill:"#000",d:"M10.92 8.61c.34-.43.57-1 .51-1.59a2.21 2.21 0 0 0-1.99 2.3c.56.04 1.12-.3 1.48-.7Zm.51.81c-.82-.05-1.52.46-1.9.46-.4 0-1-.43-1.64-.42-.84 0-1.62.48-2.05 1.24-.88 1.52-.23 3.76.62 5 .42.6.92 1.27 1.58 1.25.62-.02.86-.4 1.62-.4.75 0 .97.4 1.63.39.69-.01 1.11-.61 1.53-1.22.47-.7.67-1.37.68-1.4-.01-.02-1.32-.52-1.33-2.02-.01-1.26 1.03-1.85 1.07-1.9a2.34 2.34 0 0 0-1.81-.98Zm7.11-1.7a2.87 2.87 0 0 1 3.02 3c0 1.8-1.27 3.03-3.06 3.03h-1.97v3.12h-1.42V7.72h3.43Zm-2 4.83h1.62c1.24 0 1.94-.66 1.94-1.82 0-1.15-.7-1.81-1.93-1.81h-1.64v3.63Zm5.39 2.43c0-1.17.9-1.89 2.48-1.98l1.83-.1v-.52c0-.74-.5-1.18-1.34-1.18-.8 0-1.3.38-1.41.97h-1.3c.08-1.2 1.1-2.09 2.76-2.09 1.62 0 2.65.86 2.65 2.2v4.6h-1.31v-1.1h-.04a2.38 2.38 0 0 1-2.1 1.2c-1.3 0-2.22-.8-2.22-2Zm4.3-.6v-.53l-1.64.1c-.82.06-1.28.42-1.28.99 0 .58.48.96 1.22.96.96 0 1.7-.66 1.7-1.52Zm2.61 4.95v-1.11c.1.03.33.03.44.03.64 0 .98-.27 1.19-.96l.12-.4-2.41-6.69h1.48l1.7 5.43h.02l1.69-5.43h1.44l-2.5 7.02c-.57 1.62-1.23 2.14-2.61 2.14a5.3 5.3 0 0 1-.56-.03Z"})),sr=ro;_(`.straumur__apple-pay-button__loading{display:flex;justify-content:center}
|
|
8
8
|
`);var ir=require("preact");function oo(e){return(0,ir.h)(Je,{method:"applepay",...e})}var qe=oo;function ao({configuration:e,paymentMethods:t}){let{i18n:r}=G(),{activePaymentMethod:o,setActivePaymentMethod:a,isObscuredByThreeDS:n,isSolePaymentMethod:i,hasApplePay:l}=x(),[m,d]=(0,lr.useState)(!1);return!l||m||e.instantPayments&&e.instantPayments.some(v=>v==="applepay")||n("applepay")?null:(0,Ye.h)(ne,{icon:(0,Ye.h)(sr,null),title:r.t("applePay.title"),isActive:o==="applepay",isSole:i,onChange:()=>a("applepay")},(0,Ye.h)(qe,{configuration:e,paymentMethods:t,isInstantPayment:!1,onUnavailable:()=>d(!0)}))}var mr=ao;var ke=require("preact");var f=require("preact"),L=require("preact/hooks");_(`.straumur__stored-card-component__remove-stored-card-button{margin-left:auto}.straumur__stored-card-component__remove-stored-card-button--text{color:var(--straumur__color-danger-text);text-decoration:none;background:none;border:none;cursor:pointer;transition:all .2s ease}.straumur__stored-card-component__remove-stored-card-button--text:disabled{cursor:not-allowed;color:var(--straumur__color-secondary)}.straumur__stored-card-component__confirm-remove-stored-card{background-color:var(--straumur__color-warning-bg);border-radius:var(--straumur__border-radius-s);max-height:0;overflow:hidden;transition:all .3s ease;opacity:0}.straumur__stored-card-component__confirm-remove-stored-card--expanded{padding:var(--straumur__space-xxlg);max-height:600px;opacity:1}.straumur__stored-card-component__confirm-remove-stored-card--header{display:flex;align-items:center;gap:var(--straumur__space-lg);color:var(--straumur__color-text);padding-bottom:var(--straumur__space-xxlg)}.straumur__stored-card-component__confirm-remove-stored-card--actions{display:flex;gap:var(--straumur__space-lg);justify-content:end}.straumur__stored-card-component__confirm-remove-stored-card--actions--button{color:var(--straumur__color-warning-text);background:none;border:none;cursor:pointer;text-decoration:none;font-weight:700}.straumur__stored-card-component__loading-text{display:flex;justify-content:center}.straumur__stored-card-component__form{display:flex;padding-top:var(--straumur__space-xxlg);flex-direction:column;gap:var(--straumur__space-5xlg)}.straumur__stored-card-component__form--wrapper{display:flex;flex-direction:column;justify-items:start;position:relative;width:100%}.straumur__stored-card-component__form--wrapper--error{color:var(--straumur__color-red-beta);font-size:12px}.straumur__stored-card-component__form--wrapper--label{transform:translate(10px) translateY(-50%);z-index:1;background:linear-gradient(to top,var(--straumur__color-secondary-gamma) 53%,var(--straumur__color-transparent) 50%);position:absolute;font-weight:500;font-size:14px;padding:0 var(--straumur__space-xxs)}.straumur__stored-card-component__form--wrapper--label--readonly{background:linear-gradient(to top,var(--straumur__color-gray-epsilon) 53%,var(--straumur__color-transparent) 50%)}.straumur__stored-card-component__form--wrapper--label--error{color:var(--straumur__color-red-beta);background:linear-gradient(to top,var(--straumur__color-red-gamma) 53%,var(--straumur__color-transparent) 50%);font-size:13px;font-weight:500}.straumur__stored-card-component__form--wrapper--label--info{position:absolute;top:33%;right:var(--straumur__space-md)}.straumur__stored-card-component__form--wrapper--input{background:var(--straumur__color-secondary-gamma);color:var(--straumur__color-text);display:flex;align-items:center;border:1px solid var(--straumur__color-transparent);border-radius:var(--straumur__border-radius-s);font-size:16px;height:48px;outline:none;padding-left:var(--straumur__space-lg);transition:border .2s ease-out,box-shadow .2s ease-out;position:relative}.straumur__stored-card-component__form--wrapper--input--readonly{background-color:var(--straumur__color-gray-epsilon)}.straumur__stored-card-component__form--wrapper--input:hover{border:1px solid var(--straumur__color-cosmos-blue-delta)}.straumur__stored-card-component__form--wrapper--input--readonly:hover{border:1px solid var(--straumur__color-transparent)}.straumur__stored-card-component__form--wrapper--input--error{background:var(--straumur__color-red-gamma);border:1px solid var(--straumur__color-red-beta)}.straumur__stored-card-component__form--wrapper--input--error:hover{border:1px solid var(--straumur__color-red-beta)}.straumur__stored-card-component__form--field-wrapper{display:flex;width:100%;gap:var(--straumur__space-lg)}.straumur__stored-card-component__submit-button{background:var(--straumur__color-primary);border:none;border-radius:var(--straumur__border-radius-s);color:var(--straumur__color-white);cursor:pointer;font-size:16px;height:40px;outline:none;padding:0 var(--straumur__space-xxlg);transition:background .2s ease-out;width:100%}.straumur__stored-card-component__submit-button:hover{background:var(--straumur__color-primary);border:1px solid var(--straumur__color-border)}.straumur__stored-card-component__submit-button:disabled{background:var(--straumur__color-secondary);border:1px solid var(--straumur__color-border);cursor:not-allowed}
|
|
9
9
|
`);var Qe=require("@adyen/adyen-web");var se=require("preact"),no=()=>(0,se.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,se.h)("g",{"clip-path":"url(#clip0_10650_34968)"},(0,se.h)("path",{d:"M12.0011 15C12.6245 15 13.1261 14.4984 13.1261 13.875V7.875C13.1261 7.25391 12.6222 6.75 12.0433 6.75C11.4644 6.75 10.8761 7.25625 10.8761 7.875V13.875C10.8761 14.4984 11.3823 15 12.0011 15ZM12.0011 16.5516C11.1873 16.5516 10.5273 17.2116 10.5273 18.0253C10.5292 18.8391 11.1855 19.5 12.0011 19.5C12.8167 19.5 13.4748 18.84 13.4748 18.0262C13.473 17.2125 12.8167 16.5516 12.0011 16.5516Z",fill:"#DFAE00"}),(0,se.h)("path",{opacity:"0.4",d:"M23.7312 19.5469L13.7328 2.48438C12.9673 1.17188 11.0356 1.17188 10.2649 2.48438L0.271188 19.5469C-0.49803 20.8547 0.460048 22.5 2.00181 22.5H21.9987C23.5343 22.5 24.4953 20.8594 23.7312 19.5469ZM10.8734 7.875C10.8734 7.25391 11.3773 6.75 11.9984 6.75C12.6195 6.75 13.1234 7.25625 13.1234 7.875V13.875C13.1234 14.4961 12.6195 15 12.0406 15C11.4617 15 10.8734 14.4984 10.8734 13.875V7.875ZM11.9984 19.5C11.1846 19.5 10.5246 18.84 10.5246 18.0262C10.5246 17.2125 11.1842 16.5525 11.9984 16.5525C12.8126 16.5525 13.4721 17.2125 13.4721 18.0262C13.4703 18.8391 12.814 19.5 11.9984 19.5Z",fill:"#DFAE00"})),(0,se.h)("defs",null,(0,se.h)("clipPath",{id:"clip0_10650_34968"},(0,se.h)("rect",{width:"24",height:"24",fill:"white"})))),dr=no;function so({configuration:e,paymentMethods:t,storedPaymentMethod:r,onStoredCardRemoved:o}){let a=(0,L.useRef)(null),n=(0,L.useRef)(),i=(0,L.useRef)(),{i18n:l}=G(),[m,d]=(0,L.useState)(!0),[v,y]=(0,L.useState)("required"),[P,k]=(0,L.useState)(!1),[B,g]=(0,L.useState)({encryptedSecurityCode:{visible:!1}}),{activePaymentMethod:R,setActivePaymentMethod:T,activeStoredPaymentMethodId:E,setActiveStoredPaymentMethodId:z,isStoredCardInitialized:p,updateStoredCardInitialization:j,handleSuccess:N,handleError:D,setThreeDSecureActive:Y,threeDSecureActive:H,isSolePaymentMethod:V,registerSubmitHandler:Q,unregisterSubmitHandler:K}=x(),O=V?R==="storedcard":R==="storedcard"&&E===r.id,pe=_e(e.theme);async function b(){await Ge(e.paymentFlow,()=>i.current)}(0,L.useEffect)(()=>{if(!(O&&p[r.id])){e.onCardValidityChanged?.(!1,!1);return}return Q(b),()=>{K(b),e.onCardValidityChanged?.(!1,!1)}},[O,p[r.id],Q,K]);let{handleOnSubmit:ee,handleOnSubmitAdditionalData:ie,handlePaymentCompleted:Pe,handlePaymentFailed:Se}=ae({configuration:e,handleSuccess:N,handleError:D,setThreeDSecureActive:Y,enrichSubmitData:C=>({...C,paymentMethod:{...C.paymentMethod,storedPaymentMethodId:r.id}})});function st(C,S){D({key:"error.unknownError"})}let Ie=async()=>{n.current=await(0,Qe.AdyenCheckout)({clientKey:t.clientKey,environment:e.environment,locale:e.locale,countryCode:e.countryCode,amount:{value:t.minorUnitsAmount,currency:t.currency},paymentMethodsResponse:t.paymentMethods,onError:st,onAdditionalDetails:ie,onPaymentCompleted:Pe,onPaymentFailed:Se}),i.current=new Qe.CustomCard(n.current,{brands:[r.brand],styles:je(pe),onSubmit:ee,onConfigSuccess(){j(r.id,!0)},onBrand:C=>{y(C.cvcPolicy)},onValidationError:C=>{let S={encryptedSecurityCode:{visible:!1,message:void 0}};C.filter(xe=>xe.error).forEach(xe=>{S[xe.fieldType].visible=!0,S[xe.fieldType].message=xe.errorI18n}),g(S)},onAllValid:C=>{d(!C.allValid),e.onCardValidityChanged?.(C.allValid,!0)},placeholders:e.placeholders,challengeWindowSize:"05"}),a.current&&i.current.mount(a.current)};if((0,L.useEffect)(()=>{O&&!p[r.id]&&Ie()},[e,O]),ve(e,()=>!!(i.current&&p[E]),()=>{Ie(),g({encryptedSecurityCode:{visible:!1,message:void 0}})}),(0,L.useEffect)(()=>{k(!1)},[R,E]),Ve(a,H&&O),H&&!O)return null;function it(){T("storedcard"),z(r.id)}function lt(){k(!0)}function mt(){k(!1)}async function Ee(){let{disableToken:C}=e.paymentFlow;if(C)try{await C(r.id),o(r.id)}catch(S){D(we(S,"error.failedToSubmitRemoveStoredPaymentCard"))}}let dt=e.paymentFlow.disableToken!==void 0&&O&&p[r.id]?(0,f.h)("div",{className:"straumur__stored-card-component__remove-stored-card-button"},(0,f.h)("button",{onClick:lt,className:"straumur__stored-card-component__remove-stored-card-button--text",disabled:P},l.t("stored-cards.removeStoredCard"))):null,h=(0,f.h)("div",{className:`straumur__stored-card-component__confirm-remove-stored-card ${P?"straumur__stored-card-component__confirm-remove-stored-card--expanded":""}`},(0,f.h)("div",{className:"straumur__stored-card-component__confirm-remove-stored-card--header"},(0,f.h)(dr,null),(0,f.h)("span",{className:"straumur__stored-card-component__confirm-remove-stored-card--header--title"},l.t("stored-cards.removeStoredCardQuestion"))),(0,f.h)("div",{className:"straumur__stored-card-component__confirm-remove-stored-card--actions"},(0,f.h)("button",{className:"straumur__stored-card-component__confirm-remove-stored-card--actions--button",onClick:Ee},l.t("stored-cards.removeStoredCardQuestionYesRemove")),(0,f.h)("button",{className:"straumur__stored-card-component__confirm-remove-stored-card--actions--button",onClick:mt},l.t("stored-cards.removeStoredCardQuestionCancel"))));return(0,f.h)(ne,{icon:(0,f.h)(Ue,{brands:[{brand:r.brand,brandFullName:r.name}]}),title:`\u2022\u2022\u2022\u2022 ${r.lastFour}`,isActive:O,isSole:V,onChange:it,headerRight:dt,confirmSection:h},(0,f.h)("div",{ref:a,tabIndex:-1,style:{height:H?"600px":"auto",minWidth:H?"350px":"auto"}},!p[r.id]&&(0,f.h)("div",{className:"straumur__stored-card-component__loading-text"},(0,f.h)(re,null)),(0,f.h)("div",{className:"straumur__stored-card-component__form",style:{opacity:p[r.id]&&!H?1:0,position:p[r.id]&&!H?"relative":"absolute",transition:"opacity 0.3s ease-in-out"}},(0,f.h)("div",{className:"straumur__stored-card-component__form--field-wrapper"},(0,f.h)("div",{className:"straumur__stored-card-component__form--wrapper"},(0,f.h)("label",{className:"straumur__stored-card-component__form--wrapper--label straumur__stored-card-component__form--wrapper--label--readonly"},l.t("stored-cards.expiryDate")),(0,f.h)("span",{className:"straumur__stored-card-component__form--wrapper--input straumur__stored-card-component__form--wrapper--input--readonly"},r.expiryMonth,"/",r.expiryYear)),(0,f.h)("div",{className:"straumur__stored-card-component__form--wrapper"},(v==="optional"||v==="required")&&(0,f.h)(f.Fragment,null,(0,f.h)("label",{className:`straumur__stored-card-component__form--wrapper--label ${B.encryptedSecurityCode.visible?"straumur__stored-card-component__form--wrapper--label--error":""}`},v==="optional"?l.t("stored-cards.securityCode3DigitsOptional"):l.t("stored-cards.securityCode3Digits")),(0,f.h)("span",{className:`straumur__stored-card-component__form--wrapper--input ${B.encryptedSecurityCode.visible?"straumur__stored-card-component__form--wrapper--input--error":""}`,"data-cse":"encryptedSecurityCode",role:"group","aria-label":l.t("stored-cards.securityCode3Digits")},(0,f.h)("div",{className:"straumur__stored-card-component__form--wrapper--label--info"},(0,f.h)(ye,{content:l.t("stored-cards.securityCode3DigitsInfo")},(0,f.h)(Ze,null))))),B.encryptedSecurityCode.visible&&(0,f.h)("span",{className:"straumur__stored-card-component__form--wrapper--error"},B.encryptedSecurityCode.message))),!e.hideSubmitButton&&(0,f.h)("button",{className:"straumur__stored-card-component__submit-button",disabled:m,onClick:b},t.minorUnitsAmount===0?l.t("stored-cards.saveCardDetails"):t.formattedAmount))))}var cr=so;var ur=require("preact/hooks");function io({configuration:e,paymentMethods:t}){let[r,o]=(0,ur.useState)(t.paymentMethods.storedPaymentMethods??[]),{isObscuredByThreeDS:a,hasStoredPaymentMethods:n}=x();if(!n||a("storedcard"))return null;function i(l){o(m=>m.filter(d=>d.id!==l))}return(0,ke.h)(ke.Fragment,null,r?.map(l=>(0,ke.h)(cr,{key:l.id,configuration:e,storedPaymentMethod:l,paymentMethods:t,onStoredCardRemoved:i})))}var pr=io;var _t=require("preact");_(`.straumur__payment-method-group{display:flex;flex-direction:column;gap:var(--straumur__space-xxlg);width:100%}
|
|
10
10
|
`);function lo({children:e,initialValue:t,isSolePaymentMethod:r,hasCard:o,hasGooglePay:a,hasApplePay:n,hasStoredPaymentMethods:i,onSubmitApiReady:l}){return(0,_t.h)(At,{initialValue:t,isSolePaymentMethod:r,hasCard:o,hasGooglePay:a,hasApplePay:n,hasStoredPaymentMethods:i,onSubmitApiReady:l},(0,_t.h)("div",{className:"straumur__payment-method-group"},e))}var hr=lo;var U=require("preact");_(`.straumur__result-component{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;min-height:300px;background-color:var(--straumur__color-white);border-radius:var(--straumur__border-radius-xxlg)}
|