PageSourceSearch

https://event.zapconnect.com/static/SpreedlyPaymentForm-CQ_r4AwY.js

js zapconnect.com collected 2026-10-01 16:02:26 UTC 12,894 bytes, 1 lines download raw bytes

1import{r as d,R as a}from"./vendor-react-nj2ukvvY.js";import{T as Ie,c6 as Le,c7 as qe,G as oe,L as E,I as h,a3 as q,a4 as He}from"./index-CvtoAcCz.js";import{g as De}from"./index-rVlZNmZf.js";import"./vendor-apollo-AvuNUkOJ.js";import"./vendor-moment-CqZOA61p.js";import"./vendor-lodash-CuICpPff.js";const H=new Set(["AE","AG","AO","AW","BF","BI","BJ","BO","BS","BW","BZ","CD","CF","CG","CI","CK","CM","DJ","DM","ER","FJ","GA","GD","GH","GM","GN","GQ","GY","HK","JM","KE","KI","KM","KN","KP","LC","ML","MO","MR","MS","MU","MW","NR","NU","PA","QA","RW","SB","SC","SL","SO","SR","ST","SY","TF","TG","TK","TL","TO","TT","TV","TZ","UG","VU","YE","ZW"]);let p=!1,y=!1;const Ke=({spreedlyPaymentFormResponse:D,cardHolderEmail:ie,gatewayEnvKey:ue,hideCardForm:me=!1,onRef:O,showConfirmationMsg:ve=!1,paymentInfoAdded:G})=>{var Q,Y,j,R,X,Z,P,ee,te,ae,re,ne;const[ye,fe]=d.useState(!1),l=d.useContext(Ie),f=d.useRef(""),c=d.useRef(""),s=d.useRef(""),o=d.useRef(""),m=d.useRef(""),Ee=Le(),g=qe(t=>{var e;return(e=t==null?void 0:t.event)==null?void 0:e.data}),he=(g==null?void 0:g.eventUrl)||(g==null?void 0:g.eventURL),[T,C]=d.useState(!1),[F,S]=d.useState(""),[M,B]=d.useState(""),[k,V]=d.useState(""),[x,N]=d.useState(""),[A,I]=d.useState(""),z={error:"Please enter a valid card details."},be=!H.has(m.current),_=()=>{var r;const t=(r=f.current)==null?void 0:r.value,e=t;e?/\d+/.test(e)?N("The card holder name must not contain numeric value"):e.length<=2||e.length>70?N("The card holder name must be between 2 and less than 70 characters long"):N(e!==t?"The card holder name cannot start or end with whitespace":""):N("The card holder name is required")},U=()=>{var r;const t=(r=c==null?void 0:c.current)==null?void 0:r.value,e=t==null?void 0:t.trim();e?(e==null?void 0:e.length)<3&&(/^\d{2}$/.test(e)?parseInt(e,10)<1||parseInt(e,10)>12?V("Month must be between 01 and 12"):V(""):V("Month must be a two-digit number")):V("Month is required")},K=()=>{var n;const t=(n=s==null?void 0:s.current)==null?void 0:n.value,e=t==null?void 0:t.trim(),r=new Date().getFullYear();e?(e==null?void 0:e.length)<5&&(/^\d{4}$/.test(e)?parseInt(e,10)<r?B("Year must be greater than or equal to the current year"):B(""):B("Year must be a four-digit number")):B("The expiration year is required")},W=()=>{var r;if(H.has(m.current)){S("");return}const t=(r=o==null?void 0:o.current)==null?void 0:r.value,e=t==null?void 0:t.trim();e?(e==null?void 0:e.length)<3||(e==null?void 0:e.length)>10?S("Zip code must be between 3 to 10 characters long."):S(""):S("Zip code is required.")},pe=()=>{m.current?I(""):I("Country is required.")},L=t=>{window.document.getElementById(t).innerText=""},ge=()=>{L("holder-name"),_(),C(!T)},Ce=t=>{var r;const e=(r=t==null?void 0:t.target)==null?void 0:r.value;L("month"),!(e.length>2)&&(e>12||(U(),C(!T)))},Se=t=>{var r;const e=(r=t==null?void 0:t.target)==null?void 0:r.value;L("year"),!(e.length>4)&&(K(),C(!T))},Ne=t=>{var r;const e=(r=t==null?void 0:t.target)==null?void 0:r.value;L("zip"),!((e==null?void 0:e.length)>10)&&(W(),C(!T))},we=t=>{m.current=t,I(t?"":"Country is required."),H.has(t)&&S(""),C(e=>!e)},v=(t,e)=>{t&&(e==="ADD"?t.classList.add("spreedly-valid-input-border"):t.classList.remove("spreedly-valid-input-border"))},J=()=>{W(),U(),_(),K(),pe()},$=()=>{var w,le,se,de,ce;const t=(w=f.current)==null?void 0:w.value,e=(le=c==null?void 0:c.current)==null?void 0:le.value,r=(se=s==null?void 0:s.current)==null?void 0:se.value,n=(de=o==null?void 0:o.current)==null?void 0:de.value,i=!!H.has(m.current)||!!(n!=null&&n.trim()),b=(t==null?void 0:t.trim())&&(e==null?void 0:e.trim())&&(r==null?void 0:r.trim())&&((ce=m.current)==null?void 0:ce.trim())&&i;return p||(window.document.getElementById("spreedly-number").classList.add("spreedly-error-input-border","has-error"),window.document.getElementById("number").innerText="Please enter a valid credit card number."),y||(window.document.getElementById("spreedly-cvv").classList.add("spreedly-error-input-border","has-error"),window.document.getElementById("cvv").innerText="Please enter a valid CVV."),!(F&&M&&x&&k&&A)&&b&&p&&y},Te=t=>{var r;if(t.preventDefault(),J(),$()){const n={full_name:document.getElementById("full_name").value,month:document.getElementById("card-month").value,year:document.getElementById("card-year").value,zip:((r=document.getElementById("zip-code"))==null?void 0:r.value)||"",country:m.current,email:ie};Spreedly.tokenizeCreditCard(n)}else D(z)},Be=()=>{f.current.value="",c.current.value="",s.current.value="",o.current.value="",p=!1,y=!1,C(!1),S(""),B(""),V(""),N(""),m.current="",I(""),Spreedly==null||Spreedly.reload()},Ve=()=>(J(),$()||!1),Fe=()=>{Spreedly.on("fieldEvent",(t,e,r,n)=>{const u=window.document.getElementById("spreedly-number"),i=window.document.getElementById("spreedly-cvv"),b=window.document.getElementById("number"),w=window.document.getElementById("cvv");e==="focus"&&(t==="number"&&v(u,"ADD"),t==="cvv"&&v(i,"ADD")),e==="blur"&&(v(u,"REMOVE"),v(i,"REMOVE")),e==="input"&&(r==="number"&&(!n.validNumber&&(n==null?void 0:n.numberLength)>0?(v(u,"REMOVE"),u.classList.add("spreedly-error-input-border","has-error"),b.innerText="Please enter a valid credit card number.",p=!1):n.validNumber&&(n==null?void 0:n.numberLength)>0&&(v(u,"ADD"),u.classList.remove("spreedly-error-input-border","has-error"),b.innerText="",p=!0,!y&&(n!=null&&n.val
1idCvv)&&(n==null?void 0:n.cvvLength)>0&&(v(i,"REMOVE"),i.classList.remove("spreedly-error-input-border","has-error"),w.innerText="",y=!0))),r==="cvv"&&(!n.validCvv&&(n==null?void 0:n.cvvLength)>0?(v(i,"REMOVE"),i.classList.add("spreedly-error-input-border","has-error"),w.innerText="Please enter a valid CVV.",y=!1):n.validCvv&&(n==null?void 0:n.cvvLength)>0&&(v(i,"ADD"),i.classList.remove("spreedly-error-input-border","has-error"),w.innerText="",y=!0)))})},Me=()=>{Spreedly.setFieldType("number","text"),Spreedly.setNumberFormat("prettyFormat"),Spreedly.setPlaceholder("number","1234 1234 1234 1234"),Spreedly.setPlaceholder("cvv","CVC"),Spreedly.setStyle("number","font-size: 16px; font-family: Courier New, sans-serif; color:#404255"),Spreedly.setStyle("cvv","font-size: 16px; font-family: Courier New, sans-serif; color:#404255"),Spreedly.setStyle("placeholder","font-family: Courier New, sans-serif; font-weight: 300; color: #404255;"),Fe(),Spreedly.on("errors",t=>{t&&(console.error("Error fetching spreedly:",t),D(z),t.forEach(e=>{var n,u,i,b;const r=window.document.getElementById(e==null?void 0:e.attribute);["first_name","last_name"].includes(e==null?void 0:e.attribute)?window.document.getElementById("holder-name").innerText="Card holder name is not valid.":r&&((e==null?void 0:e.attribute)==="year"?(u=(n=s==null?void 0:s.current)==null?void 0:n.classList)==null||u.add("error-input"):(e==null?void 0:e.attribute)==="month"&&((b=(i=s==null?void 0:s.current)==null?void 0:i.classList)==null||b.add("error-input")),r.innerText=e==null?void 0:e.message)}))}),Spreedly.on("paymentMethod",(t,e)=>{e&&D(e)})},ke=async t=>{try{const e=await Ee(De(t));if(!e||e.errorMessage){console.error("Failed to fetch signature:",(e==null?void 0:e.errorMessage)||"Unknown error");return}if(!(e!=null&&e.nonce)||!(e!=null&&e.timeStamp)||!(e!=null&&e.certificateToken)||!(e!=null&&e.signature)){console.error("Missing required signature data");return}const r=document.createElement("script");return r.src="https://core.spreedly.com/iframe/iframe-v1.min.js",r.async=!0,r.onload=()=>{Spreedly.init(ue,{numberEl:"spreedly-number",cvvEl:"spreedly-cvv",nonce:e.nonce,timestamp:e.timeStamp,certificateToken:e.certificateToken,signature:e.signature}),Spreedly.on("ready",()=>{fe(!0),Me()})},r.onerror=()=>{console.error("Failed to load Spreedly script")},document.body.appendChild(r),O&&O({resetSpreedly:Be,validateCardDetails:Ve}),()=>{Spreedly.removeHandlers(),document.body.removeChild(r)}}catch(e){console.error("Error in getPaymentGatewayGenerateSignature:",e)}};return d.useEffect(()=>{ke(he)},[]),d.useEffect(()=>{var t,e,r,n;((t=f.current)!=null&&t.value||(e=c==null?void 0:c.current)!=null&&e.value||(r=s==null?void 0:s.current)!=null&&r.value||(n=o==null?void 0:o.current)!=null&&n.value||y||p)&&G&&typeof G=="function"&&G()},[T,y,p]),a.createElement("div",{className:oe("spreedly-payment-form",me?"hide":"")},a.createElement("form",{id:"payment-form",onSubmit:Te},a.createElement("input",{type:"hidden",name:"payment_method_token",id:"payment_method_token"}),a.createElement(E,{variant:"body2",color:(Q=h[l==null?void 0:l.theme])==null?void 0:Q.neutral850},"Card Holder Name",a.createElement("span",{className:"stripe-required red"},"*")),a.createElement("div",{className:"d-flex flex-direction-column m-b-10"},a.createElement(q,{type:"text",id:"full_name",placeHolder:"Card Holder Name",onChange:ge,autoComplete:"off",valid:!x,value:f==null?void 0:f.current.value,isFeedBackShow:!!x,feedBackText:x,isCheckoutCardHolder:!0,"aria-required":!0,inputRef:f}),a.createElement("span",{id:"holder-name",className:"red m-t-2"})),a.createElement("div",{className:"spreedly-payment-fields"},a.createElement("div",{className:"fields-container"},a.createElement("div",{className:"m-3"},a.createElement(E,{variant:"body2",color:(Y=h[l==null?void 0:l.theme])==null?void 0:Y.neutral850},"Credit Card Number",a.createElement("span",{className:"stripe-required red"},"*")),a.createElement("div",{className:"d-flex flex-direction-column"},a.createElement("div",{id:"spreedly-number",placeholder:"1234 1234 1234 1234",className:"input-icon-box curs
1or input spreedly-input m-b-5"}),a.createElement("span",{id:"number",className:"red"}))),a.createElement("div",{className:"m-3"},a.createElement(E,{variant:"body2",color:(j=h[l==null?void 0:l.theme])==null?void 0:j.neutral850},"Expiration Month",a.createElement("span",{className:"stripe-required red"},"*")),a.createElement("div",{className:"d-flex flex-direction-column"},a.createElement(q,{type:"number",id:"card-month",name:"month",placeHolder:"MM",max:12,onChange:Ce,autoComplete:"off",valid:!k,value:(R=c==null?void 0:c.current)==null?void 0:R.value,isFeedBackShow:!!k,feedBackText:k,isCheckoutCardHolder:!0,"aria-required":!0,inputRef:c}),a.createElement("span",{id:"month",className:"red"}))),a.createElement("div",{className:"m-3"},a.createElement(E,{variant:"body2",color:(X=h[l==null?void 0:l.theme])==null?void 0:X.neutral850},"Expiration Year",a.createElement("span",{className:"stripe-required red"},"*")),a.createElement("div",{className:"d-flex flex-direction-column"},a.createElement(q,{type:"number",id:"card-year",name:"year",placeHolder:"YYYY",onChange:Se,autoComplete:"off",valid:!M,value:(Z=s==null?void 0:s.current)==null?void 0:Z.value,isFeedBackShow:!!M,feedBackText:M,isCheckoutCardHolder:!0,"aria-required":!0,inputRef:s}),a.createElement("span",{id:"year",className:"red"}))),a.createElement("div",{className:"m-3"},a.createElement(E,{variant:"body2",color:(P=h[l==null?void 0:l.theme])==null?void 0:P.neutral850},"Security Code",a.createElement("span",{className:"stripe-required red"},"*")),a.createElement("div",{className:"d-flex flex-direction-column"},a.createElement("div",{id:"spreedly-cvv",className:"input-icon-box cursor input spreedly-input"}),a.createElement("span",{id:"cvv",className:"red"}))),a.createElement("div",{className:"m-3"},a.createElement(E,{variant:"body2",color:(ee=h[l==null?void 0:l.theme])==null?void 0:ee.neutral850},"Country",a.createElement("span",{className:"stripe-required red"},"*")),a.createElement("div",{className:"d-flex flex-direction-column"},a.createElement(He,{value:m.current,valueType:"short",id:"card-country",classes:oe("spreedly-country-dropdown",{"spreedly-error-input-border":!!A}),onChange:we,"aria-label":"Country","aria-required":!0,defaultOptionLabel:"Select Country"}),a.createElement("span",{id:"country",className:"red m-t-2"},A))),be&&a.createElement("div",{className:"m-3"},a.createElement(E,{variant:"body2",color:(te=h[l==null?void 0:l.theme])==null?void 0:te.neutral850},"Zip Code",a.createElement("span",{className:"stripe-required red"},"*")),a.createElement("div",{className:"d-flex flex-direction-column"},a.createElement(q,{type:"text",id:"zip-code",name:"zip-code",placeHolder:"Zip code",onChange:Ne,autoComplete:"off",valid:!F,value:(ae=o==null?void 0:o.current)==null?void 0:ae.value,isFeedBackShow:!!F,feedBackText:F,isCheckoutCardHolder:!0,"aria-required":!0,inputRef:o}),a.createElement("span",{id:"zip",className:"red m-t-2"})))),ve&&a.createElement(E,{className:"terms-and-condition-label",header:`By providing your card information, you allow ${(re=window==null?void 0:window.location)==null?void 0:re.hostname} to charge your card for future payments in accordance with their terms.`,variant:"captions",color:(ne=h[l==null?void 0:l.theme])==null?void 0:ne.blueCoral})),a.createElement("button",{id:"spreedly-payment-form-submit",hidden:!0,type:"submit",disabled:!ye},"Pay Now")))};export{Ke 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.