1import{j as e,M as y,u as k,r as p,b6 as G,q as U,f as P,ao as V,aO as W,a9 as J,p as L,S as D,h as X,z as K,I as Z,a3 as F,v as B,X as Q,D as ee,e as se,b$ as te,a as ne,Y as re,Z as ae,_ as ie,c0 as R}from"./index-BPR3l8qa.js";function q({interval_unit:s,interval_count:r}){switch(s){case"MONTH":return e.jsx(y,{id:"recurring_plan_monthly",values:{num:r}});case"YEAR":return e.jsx(y,{id:"recurring_plan_yearly",values:{num:r}});case"WEEK":return e.jsx(y,{id:"recurring_plan_weekly",values:{num:r}});case"DAY":return e.jsx(y,{id:"recurring_plan_daily",values:{num:r}});default:return null}}function A(s,r,u,f,t,a,d=null,o="/checkout"){const c=new URLSearchParams;c.append("note","Goaffpro memberships"),c.append("attributes[Membership Affiliate ID]",u),c.append("attributes[Membership Plan ID]",f);const x=[{variantId:r,quantity:1,selling_plan_id:t},...(a||[]).map(l=>({variantId:l,quantity:1}))];for(let l=0;l<x.length;l++){const{variantId:n,quantity:j,selling_plan_id:N}=x[l];c.append("items[".concat(l,"][id]"),n),N&&c.append("items[".concat(l,"][selling_plan]"),N),c.append("items[".concat(l,"][quantity]"),String(j))}return c.append("return_to",o),"https://".concat(s,"/cart/clear?return_to=").concat(encodeURIComponent("/cart/add?".concat(c.toString())))}async function z({product:s,selectedUpsells:r,website_match:u,selling_plan_id:f,affiliate_id:t,plan_id:a,storefront_token:d,shopify_buy_button_return_to:o}){const c=[{merchandiseId:"gid://shopify/ProductVariant/".concat(s.value),quantity:1}];r.forEach(({value:l})=>{c.push({merchandiseId:"gid://shopify/ProductVariant/".concat(l),quantity:1})});const x=await fetch("https://".concat(u,"/api/2025-04/graphql.json"),{method:"POST",headers:{"X-Shopify-Storefront-Access-Token":d,"Content-Type":"application/json"},body:JSON.stringify({query:"mutation cartCreate($input: CartInput!) {\n cartCreate(input: $input) {\n cart {\n id\n checkoutUrl\n }\n userErrors {\n code\n field\n message\n }\n }\n }",variables:{input:{note:"Goaffpro memberships",lines:c,attributes:[{key:"Membership Affiliate ID",value:String(t)},{key:"Membership Plan ID",value:String(a)}]}}})}).then(l=>l.json()).catch(l=>null);return x?x.data.cartCreate.cart.checkoutUrl:A(u,s.variation_id,t,a,f,r,null,o||"/checkout")}const le=s=>[s.settings.website_match,s.settings.affiliate_id,{fname:s.settings.fname,lname:s.settings.lname,email:s.settings.email,address_1:s.settings.address_1,address_2:s.settings.address_2,city:s.settings.city,state:s.settings.state,country:s.settings.country,zip:s.settings.zip}];function oe({product:s,upsells:r,storefront_token:u,selling_plan_id:f,plan_id:t}){const[a,d,o]=k(le),[c,x]=p.useState(null),l=r.filter(i=>!i.required),n=k(i=>i.settings.shopify_buy_button_return_to),[j,N]=p.useState(!1),[m,h]=p.useState(!1),[b,C]=p.useState(r.filter(i=>i.required).map(i=>i.value));p.useEffect(()=>{d&&t&&s&&a&&(u?(N(!0),z({product:s,selectedUpsells:b,website_match:a,affiliate_id:d,plan_id:t,storefront_token:u,shopify_buy_button_return_to:n}).then(i=>{N(!1),x(i)})):x(A(a,s.variation_id,d,t,f,b,o,n||"/checkout")))},[s,b,f,d,t,u,a,o,n]);const g=()=>{u?z({product:s,selectedUpsells:b,selling_plan_id:f,website_match:a,affiliate_id:d,plan_id:t,storefront_token:u,shopify_buy_button_return_to:n}).then(i=>{h(!1),window.open(i)}):(h(!1),window.open(A(a,s.variation_id,d,t,f,b,o,n||"/checkout")))};return s&&a?j?e.jsx("div",{className:"py-2",children:e.jsx(G,{width:90,height:36.5})}):e.jsxs(e.Fragment,{children:[e.jsxs(U,{title:"membership_special_offer_title",visible:m,onOk:g,okText:"Checkout",size:"lg",onClose:()=>h(!1),children:[e.jsx("p",{children:e.jsx(y,{id:"membership_special_offer_subtitle"})}),e.jsx("div",{className:"row row-cols-1 g-4",children:l.map(({product:i,value:v})=>{var M,O;const w=(M=i==null?void 0:i.variants)==null?void 0:M.find(({id:S})=>S==v),{title:I}=i,_=(i==null?void 0:i.images)||[],Y=(w==null?void 0:w.title)||"",{price:T,compare_at_price:E}=w||{};return _.forEach(({variant_ids:S,src:$,height:pe,width:ge})=>{S&&S.indexOf(v)>-1}),e.jsx("div",{className:"col",children:e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col-4",children:_.length>0?e.jsx("img",{alt:I,src:_[0].src,style:{width:"100%",aspectRatio:"1/1",objectFit:"contain"}}):null}),e.jsxs("div",{className:"col-8",children:[e.jsx("h5",{children:I}),((O=i==null?void 0:i.variants)==null?void 0:O.length)>1?e.jsx("small",{children:Y}):null,e.jsx("div",{children:e.jsx("div",{dangerouslySetInnerHTML:{__html:i.body_html}})}),e.jsxs("p",{className:"fs-5 mt-2",children:[e.jsx("span",{className:"mr-2",children:e.jsx(P,{value:T})}),E&&Number(E)>Number(T)?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"ml-2",style:{textDecoration:"line-through"},children:e.jsx(P,{value:E})}
1),e.jsxs("span",{className:"ml-2 rounded badge badge-danger",children:[V(E).minus(T).times(100).div(Number(E)).toFixed(0),"% off"]})]}):null]}),e.jsxs(W,{onClick:()=>C(S=>S.indexOf(v)>-1?S.filter($=>$!==v):[...S,v]),className:"btn btn-outline-secondary",children:[b.indexOf(v)>-1?e.jsx(J,{className:"mr-2"}):null,e.jsx(y,{id:"Add to cart"})]})]})]})})})})]}),e.jsx("div",{className:"py-2",children:e.jsx("a",{href:(l==null?void 0:l.length)>1?null:c,onClick:l.length>1?()=>h(!0):null,rel:"opener",className:"btn btn-primary",title:s.label,children:e.jsx(y,{id:"Buy Now"})})})]}):null}function ce(){const[s,r]=p.useState(!1),[u,f]=p.useState("");return p.useEffect(()=>{const t=new URLSearchParams(window.location.search),a=t.get("number"),d=t.get("id");(a||d)&&(r(!0),L("/paymentplans/activate/store_purchase",{data:{order_number:a,order_id:d}}).then(o=>{o.success?window.location="/":(r(!1),f(o.error))}).catch(o=>{r(!1)}))},[]),p.useEffect(()=>{const t=a=>{try{const{type:d,id:o}=JSON.parse(a.data);d==="goaffpro"&&o&&(r(!0),L("/paymentplans/activate/store_purchase",{data:{order_id:o}}).then(c=>{c.success?window.location="/":(r(!1),f(c.error))}).catch(c=>{r(!1)}))}catch(d){}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},[]),s?e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(255,255,255,0.8)",zIndex:1},children:e.jsx("div",{className:"d-flex align-items-center justify-content-center min-vh-100",children:e.jsx(D,{size:32})})}):null}function de({plan_id:s,plan_title:r}){const[u,f]=X(),[t,a]=p.useState(""),[d,o]=p.useState(null),[c,x]=p.useState(!1),l=p.useCallback(n=>{n&&(n.preventDefault(),n.stopPropagation()),x(!0),o(null),L("/paymentplans/activate/store_purchase",{data:{order_number:t},plan_id:s,payment_gateway:"store_purchase"}).then(j=>{x(!1),j.success?window.location="/":o(j.error)}).catch(j=>{console.log(j),o("Network error"),x(!1)})},[t]);return e.jsxs(e.Fragment,{children:[e.jsxs(U,{onSubmit:l,title:r,okText:"Submit",confirmLoading:c,visible:u,onClose:f,children:[e.jsx(K,{label:"Order Number",info:"Enter your purchased order number to verify",children:e.jsx(Z,{value:t,onChange:a})}),d?e.jsx("p",{className:"text-danger",children:d}):null]}),e.jsx("div",{className:"text-center",children:e.jsx("button",{className:"btn btn-sm btn-link already_purchased_link",onClick:f,children:"Already purchased ? Click here"})})]})}function ue({plan_id:s,product:r}){const u=k(n=>n.settings.website),f=k(n=>n.settings.email),[t,a]=F.useState(!1),[d,o]=F.useState(""),c=k(n=>n.settings.integration),x=()=>{a(!0),L("https://api-server-3.goaffpro.com/partner/paymentplans/activate/store_purchase",{email:f,integration:c,data:{},plan_id:s,payment_gateway:"store_purchase"}).then(n=>{n.success?window.location.assign("/"):o(n.error)}).catch(n=>{o("Network error")}).finally(()=>{a(!1)})};p.useEffect(()=>{const n=setInterval(x,5e3);return()=>{clearInterval(n)}},[]);const l=p.useMemo(()=>{const n=new URL(u.includes("://")?u:"https://".concat(u));return n.pathname="/checkout/",n.searchParams.set("add-to-cart",r.value),n.searchParams.set("clear-cart","true"),n.searchParams.set("quantity","1"),n.href},[u,r]);return e.jsx("a",{href:l,rel:"opener",className:"btn btn-primary",target:"_blank",title:r.label,children:e.jsx(y,{id:"Buy Now"})})}function me({cost:s,plan_title:r,num_plans:u,plan_id:f,plan_type:t,perks:a,description:d,interval_count:o,interval_unit:c,has_trial:x,trial_label:l,trial_interval_count:n,trial_interval_unit:j,trial_cost:N,selling_plan_id:m,upsells:h,onChoose:b,loading:C,isChosen:g,currency:i,storefront_access_token:v,product:w}){const I=k(_=>_.settings.integration);return e.jsxs("div",{className:"card flex-fill",children:[e.jsxs("div",{className:"flex-fill",children:[e.jsxs("div",{className:"p-3",children:[e.jsx("h5",{className:"card-title text-center",children:r}),e.jsx("div",{className:"text-center",children:t==="recurring"?e.jsx(e.Fragment,{children:x?e.jsxs("div",{children:[e.jsx("span",{className:"badge badge-info",children:l}),e.jsxs("div",{className:"fs-2",children:[e.jsx(P,{currency:i,value:N}),e.jsx("span",{className:"text-muted",style:{fontSize:"0.8rem"},children:"Â now"})]}),"after ",n," ",j.toLowerCase()," ",e.jsx(P,{currency:i,value:s}),e.jsxs("span",{className:"text-muted",style:{fontSize:"0.8rem"},children:["/",e.jsx(q,{interval_count:o,interval_unit:c})]})]}):e.jsxs("div",{className:"fs-2",children:[e.jsx(P,{currency:i,value:s}),e.jsxs("span",{className:"text-muted",style:{fontSize:"1rem"},children:["/",e.jsx(q,{interval_count:o,interval_unit:c})]})]})}):e.jsx("div",{className:"fs-2 mb-2",children:e.jsx(P,{currency:i,value:s})})}),t==="one_time_purchase"&&I==="shopify"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-center",children:e.jsx(oe,{upsells:h,selling_plan_id:m,plan_id:f,product:w,storefront_token:v})}),e.jsx("div",{children:e.jsx(de,{plan_id:f,plan_title:r})})]}):null,t==="one_time_purchase"&&I==="woocommerce"?e.jsx(e.Fragment,{children:e.jsx("div",{className:"text-center",children:e.jsx(ue,{upsells:h,selling_plan_id:m,plan_id:f,product:w,storefront_token:v})})}):null]}),a&&a.split("\n").length>0&&e.jsx("ul",{className:"list-group list-group-flush",children:a&&a.split("\n").filter(_=>_).map(_=>e.jsx("li",{className:"text-center list-group-item",children:_},_))}),d&&e.jsx("div",{className:"card-body",dangerouslySetInnerHTML:{__html:d}})]}),u>1&&t!=="one_time_purchase"?e.jsx("div",{className:"card-footer text-center",children:e.jsx(B,{disabled:C&&!g,loading:C&&g,className:"btn btn-primary",onClick:b,children:e.jsx(y,{id:"Choose"})})}):null]})}
1function he(){const s=k(m=>m.settings.affiliate_id),r=p.useMemo(()=>{const m=new URLSearchParams(window.location.search).get("id")||void 0;return m?"/paymentplans?id=".concat(m||""):"/paymentplans"},[]),{data:u,isLoading:f}=ee(s?r:null,se),t=u==null?void 0:u.plans,[a,d]=p.useState(!1),[o,c]=p.useState(null),[x,l]=p.useState(null),n=()=>{const m=t.length>1;return o||(m?void 0:t[0].plan_id)},j=async m=>{d(!0),c(m),l(!1),console.log("Activating plan",m,await R()),L("/paymentplans/payment_url",{cancel_url:await R(),plan_id:m}).then(h=>{d(!1);const{payment_gateway:b,error:C}=h;if(C){l(C);return}if(b==="stripe")window.top!==window.self?window.top.location=h.session.url:document.location=h.session.url;else if(b==="paypal"){const{approve:g}=h;window.top!==window.self?window.top.location=g:document.location=g}else if(h!=null&&h.url){if((h==null?void 0:h.method)==="POST"){const g=document.createElement("form");g.method="POST",g.action=h.url,g.style.display="none",h.params&&Object.entries(h.params).forEach(([i,v])=>{const w=document.createElement("input");w.name=i,w.value=v,g.appendChild(w)}),document.body.appendChild(g),g.submit();return}window.top!==window.self?window.top.location=h.url:document.location=h.url}})};if(!s)return e.jsx(te,{to:"/login?next="+document.location.pathname+document.location.search,replace:!0});if(!t)return f?e.jsx(fe,{}):null;if(Array.isArray(t)&&t.length===0)return e.jsx("p",{className:"text-center",children:"No membership plans configured for this user"});if(!ne())return e.jsx("p",{className:"text-danger",children:"Error: You are currently not logged in."});const N=t.length;return e.jsxs(H,{children:[e.jsx(ce,{}),e.jsx(re,{id:"Activate membership"}),e.jsxs("div",{className:"container my-4 py-4",children:[e.jsx("div",{className:"text-center",children:e.jsx(ae,{})}),e.jsx("h3",{className:"text_on_bg text-center mt-4 mb-4",children:e.jsx(y,{id:"Activate membership"})}),x&&e.jsx("p",{className:"text-danger text-center",children:x}),e.jsx("div",{className:"row row-cols-1 g-2 row-cols-md-2 row-cols-lg-3 justify-content-center",children:t.map(m=>e.jsx("div",{className:"col d-flex flex-row",id:"plan-".concat(String(m.plan_id)),children:e.jsx(me,{loading:a,isChosen:m.plan_id===o,...m,num_plans:N,onChoose:()=>j(m.plan_id)})},String(m.plan_id)))}),n()&&N===1&&t.some(m=>m.plan_type!=="one_time_purchase")&&e.jsxs("div",{className:"text-center mt-2",children:[x&&e.jsx("p",{className:"text-danger",children:x}),e.jsx(B,{loading:a,onClick:()=>j(n()),children:e.jsx(y,{id:"Continue"})})]}),e.jsx("div",{className:"mt-4 text-center activate_membership_logout",children:e.jsx("small",{children:e.jsx(ie,{to:"/logout",children:e.jsx(y,{id:"Logout"})})})})]})]})}function fe(){return e.jsx(H,{children:e.jsx(D,{size:"lg"})})}function H({children:s}){return e.jsx("div",{className:"bg-light-subtle min-vh-100 d-flex align-items-center justify-content-center",children:s})}function xe(s){return{name:s.settings.name,email:s.settings.email}}const ye=Q(xe)(he);export{ye as default}; 2//# sourceMappingURL=SubscribePayment_Internal-BQ4QIsDy.js.map
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.