Files
mtdb_movie/public/build/assets/checkout-routes-05b6ef38.js
maher 703f50a09d
Some checks failed
Build / run (push) Has been cancelled
first commit
2025-10-29 11:42:25 +01:00

18 lines
11 KiB
JavaScript
Executable File
Vendored
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{b$ as U,j as s,aB as E,O as z,r as u,cY as G,t as W,T as b,N as H,C as Q,cZ as Y,aG as h,d as Z,bj as K,e as N,m as A,be as V,c_ as J,c1 as X,q as ee,aq as y,bd as q,u as C,aL as te,aI as D,aH as se,bU as F,h as p,cU as re,cV as w}from"./main-239552ae.js";import{S as ne,l as ae,B as I}from"./billing-redirect-message-799c6490.js";import"./TaskAlt-50ceef7c.js";function S({children:t}){const{isLoggedIn:e,isSubscribed:r}=U();return e?e&&r?s.jsx(E,{to:"/billing",replace:!0}):t||s.jsx(z,{}):s.jsx(E,{to:"/register",replace:!0})}function L({children:t}){const[e,r]=t;return u.useEffect(()=>{G("be.onboarding.selected")},[]),s.jsxs(u.Fragment,{children:[s.jsx(W,{children:s.jsx(b,{message:"Checkout"})}),s.jsx(H,{size:"sm",color:"transparent",className:"z-10 mb-20 md:mb-0",textColor:"text-main",logoColor:"dark",darkModeColor:"transparent",menuPosition:"checkout-page-navbar"}),s.jsxs("div",{className:"md:flex w-full mx-auto justify-between px-20 md:px-0 md:pt-128 md:max-w-950",children:[s.jsx("div",{className:"hidden md:block fixed right-0 top-0 w-1/2 h-full bg-alt shadow-[15px_0_30px_0_rgb(0_0_0_/_18%)]"}),s.jsxs("div",{className:"md:w-400 overflow-hidden",children:[e,s.jsx(Q,{menu:"checkout-page-footer",className:"text-xs mt-50 text-muted overflow-x-auto"}),s.jsx("div",{className:"mt-40",children:s.jsx(Y,{})})]}),s.jsx("div",{className:"hidden md:block w-384",children:s.jsx("div",{className:"relative z-10",children:r})})]})]})}const O=t=>`billing/products/${t}`;function ie(){var c;const{productId:t,priceId:e}=h(),r=Z({queryKey:[O(t)],queryFn:()=>ce(t),placeholderData:K,enabled:t!=null&&e!=null}),n=(c=r.data)==null?void 0:c.product,i=(n==null?void 0:n.prices.find(a=>a.id===parseInt(e)))||(n==null?void 0:n.prices[0]);return{status:r.status,product:n,price:i}}function ce(t){return N.get(O(t)).then(e=>e.data)}function _({showBillingLine:t=!0}){const{status:e,product:r,price:n}=ie();return e==="error"||e!=="pending"&&(!r||!n)?null:s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl mb-30",children:s.jsx(b,{message:"Summary"})}),e==="pending"?s.jsx(ue,{},"loading-skeleton"):s.jsx(oe,{product:r,price:n,showBillingLine:t})]})}function oe({product:t,price:e,showBillingLine:r}){return s.jsxs(A.div,{children:[s.jsx("div",{className:"text-xl font-semibold mb-6",children:t.name}),t.description&&s.jsx("div",{className:"text-sm text-muted",children:t.description}),s.jsx(V,{priceClassName:"font-bold text-4xl",periodClassName:"text-muted text-xs",variant:"separateLine",price:e,className:"mt-32"}),s.jsx(J,{product:t}),r&&s.jsxs("div",{className:"flex items-center justify-between gap-24 border-t pt-24 mt-32 font-medium",children:[s.jsx("div",{children:s.jsx(b,{message:"Billed today"})}),s.jsx("div",{children:s.jsx(X,{value:e.amount,currency:e.currency})})]})]})}function ue(){return s.jsxs(A.div,{...ee,className:"max-w-180",children:[s.jsx(y,{className:"text-xl mb-6"}),s.jsx(y,{className:"text-sm"}),s.jsx(y,{className:"text-4xl mt-32"})]})}/*!
* paypal-js v7.0.3 (2023-09-19T14:17:47.731Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function le(t,e){var r=document.querySelector('script[src="'.concat(t,'"]'));if(r===null)return null;var n=T(t,e),i=r.cloneNode();if(delete i.dataset.uidAuto,Object.keys(i.dataset).length!==Object.keys(n.dataset).length)return null;var c=!0;return Object.keys(i.dataset).forEach(function(a){i.dataset[a]!==n.dataset[a]&&(c=!1)}),c?r:null}function de(t){var e=t.url,r=t.attributes,n=t.onSuccess,i=t.onError,c=T(e,r);c.onerror=i,c.onload=n,document.head.insertBefore(c,document.head.firstElementChild)}function pe(t){var e="https://www.paypal.com/sdk/js";t.sdkBaseUrl&&(e=t.sdkBaseUrl,delete t.sdkBaseUrl);var r=t,n=Object.keys(r).filter(function(a){return typeof r[a]<"u"&&r[a]!==null&&r[a]!==""}).reduce(function(a,o){var l=r[o].toString();return o=fe(o),o.substring(0,4)==="data"?a.dataAttributes[o]=l:a.queryParams[o]=l,a},{queryParams:{},dataAttributes:{}}),i=n.queryParams,c=n.dataAttributes;return i["merchant-id"]&&i["merchant-id"].indexOf(",")!==-1&&(c["data-merchant-id"]=i["merchant-id"],i["merchant-id"]="*"),{url:"".concat(e,"?").concat(me(i)),dataAttributes:c}}function fe(t){var e=function(r,n){return(n?"-":"")+r.toLowerCase()};return t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,e)}function me(t){var e="";return Object.keys(t).forEach(function(r){e.length!==0&&(e+="&"),e+=r+"="+t[r]}),e}function T(t,e){e===void 0&&(e={});var r=document.createElement("script");return r.src=t,Object.keys(e).forEach(function(n){r.setAttribute(n,e[n]),n==="data-csp-nonce"&&r.setAttribute("nonce",e["data-csp-nonce"])}),r}function be(t,e){if(e===void 0&&(e=Promise),M(t,e),typeof document>"u")return e.resolve(null);var r=pe(t),n=r.url,i=r.dataAttributes,c=i["data-namespace"]||"paypal",a=B(c);return le(n,i)&&a?e.resolve(a):xe({url:n,attributes:i},e).then(function(){var o=B(c);if(o)return o;throw new Error("The window.".concat(c," global variable is not available."))})}function xe(t,e){e===void 0&&(e=Promise),M(t,e);var r=t.url,n=t.attributes;if(typeof r!="string"||r.length===0)throw new Error("Invalid url.");if(typeof n<"u"&&typeof n!="object")throw new Error("Expected attributes to be an object.");return new e(function(i,c){if(typeof document>"u")return i();de({url:r,attributes:n,onSuccess:function(){return i()},onError:function(){var a=new Error('The script "'.concat(r,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return c(a)}})})}function B(t){return window[t]}function M(t,e){if(typeof t!="object"||t===null)throw new Error("Expected an options object.");if(typeof e<"u"&&typeof e!="function")throw new Error("Expected PromisePonyfill to be a function.")}function he({productId:t,priceId:e}){const{data:r}=q(),n=u.useRef(!1),i=u.useRef(!1),[c,a]=u.useState(!1),o=u.useRef(null),{base_url:l,billing:{stripe:{enable:f},paypal:{enable:x,public_key:d}}}=C();return u.useEffect(()=>{!x||!d||n.current||(be({clientId:d,intent:"subscription",vault:!0,disableFunding:f?"card":void 0}).then(()=>{a(!0)}),n.current=!0)},[d,x,f]),u.useEffect(()=>{var $;if(!c||!(($=window.paypal)!=null&&$.Buttons)||!o.current||!(r!=null&&r.products.length)||!t||!e||i.current)return;const g=r.products.find(m=>m.id===parseInt(t)),j=g==null?void 0:g.prices.find(m=>m.id===parseInt(e));window.paypal.Buttons({style:{label:"pay"},createSubscription:(m,v)=>v.subscription.create({application_context:{shipping_preference:"NO_SHIPPING"},plan_id:j==null?void 0:j.paypal_id}),onApprove:(m,v)=>(v.redirect(`${l}/checkout/${t}/${e}/paypal/done?subscriptionId=${m.subscriptionID}&status=success`),Promise.resolve()),onError:m=>{location.href=`${l}/checkout/${t}/${e}/paypal/done?status=error`}}).render(o.current).then(()=>{i.current=!0})},[t,e,r,c,l]),{paypalElementRef:o,stripeIsEnabled:d!=null&&x}}function ge(){var l;const{productId:t,priceId:e}=h(),r=q(),{paypalElementRef:n}=he({productId:t,priceId:e}),{base_url:i,billing:{stripe:c}}=C();if(r.isLoading)return s.jsx(te,{screen:!0});const a=(l=r.data)==null?void 0:l.products.find(f=>f.id===parseInt(t)),o=a==null?void 0:a.prices.find(f=>f.id===parseInt(e));return!a||!o||r.status==="error"?s.jsx(E,{to:"/pricing",replace:!0}):s.jsxs(L,{children:[s.jsxs(u.Fragment,{children:[s.jsx("h1",{className:"mb-40 text-4xl",children:s.jsx(b,{message:"Checkout"})}),c.enable?s.jsxs(u.Fragment,{children:[s.jsx(ne,{productId:t,priceId:e,submitLabel:s.jsx(b,{message:"Upgrade"}),type:"subscription",returnUrl:`${i}/checkout/${t}/${e}/stripe/done`}),s.jsx(je,{})]}):null,s.jsx("div",{ref:n}),s.jsx("div",{className:"mt-30 text-xs text-muted",children:s.jsx(b,{message:"Youll be charged until you cancel your subscription. Previous charges wont be refunded when you cancel unless its legally required. Your payment data is encrypted and secure. By subscribing your agree to our terms of service and privacy policy."})})]}),s.jsx(_,{})]})}function je(){return s.jsx("div",{className:"relative my-20 text-center before:absolute before:left-0 before:top-1/2 before:h-1 before:w-full before:-translate-y-1/2 before:bg-divider",children:s.jsx("span",{className:"relative z-10 bg px-10 text-sm text-muted",children:s.jsx(b,{message:"or"})})})}function ve(){const{invalidateBootstrapData:t}=D(),{productId:e,priceId:r}=h(),n=se(),{billing:{stripe_public_key:i}}=C(),[c]=F(),a=c.get("payment_intent_client_secret"),[o,l]=u.useState(),f=u.useRef();return u.useEffect(()=>{f.current||(ae(i).then(async x=>{if(!x||!a){l(k());return}x.retrievePaymentIntent(a).then(async({paymentIntent:d})=>{(d==null?void 0:d.status)==="succeeded"?(await ye(d.id),l(k("succeeded",e,r)),window.location.href="/billing"):l(k(d==null?void 0:d.status,e,r))})}),f.current=!0)},[i,a,r,e,t]),a?s.jsxs(L,{children:[s.jsx(I,{config:o}),s.jsx(_,{showBillingLine:!1})]}):(n("/"),null)}function k(t,e,r){switch(t){case"succeeded":return{message:p("Subscription successful!"),status:"success",buttonLabel:p("Return to site"),link:"/billing"};case"processing":return{message:p("Payment processing. We'll update you when payment is received."),status:"success",buttonLabel:p("Return to site"),link:"/billing"};case"requires_payment_method":return{message:p("Payment failed. Please try another payment method."),status:"error",buttonLabel:p("Go back"),link:P(e,r)};default:return{message:p("Something went wrong"),status:"error",buttonLabel:p("Go back"),link:P(e,r)}}}function P(t,e){return t&&e?`/checkout/${t}/${e}`:"/"}function ye(t){return N.post("billing/stripe/store-subscription-details-locally",{payment_intent_id:t})}function we(){const{invalidateBootstrapData:t}=D(),{productId:e,priceId:r}=h(),[n]=F(),[i,c]=u.useState();return u.useEffect(()=>{const a=n.get("subscriptionId"),o=n.get("status");a&&o==="success"?ke(a).then(()=>{c(R("success",e,r)),window.location.href="/billing"}):c(R(o,e,r))},[r,e,n,t]),s.jsxs(L,{children:[s.jsx(I,{config:i}),s.jsx(_,{showBillingLine:!1})]})}function R(t,e,r){switch(t){case"success":return{message:p("Subscription successful!"),status:"success",buttonLabel:p("Return to site"),link:"/billing"};default:return{message:p("Something went wrong. Please try again."),status:"error",buttonLabel:p("Go back"),link:Se(e,r)}}}function Se(t,e){return t&&e?`/checkout/${t}/${e}`:"/"}function ke(t){return N.post("billing/paypal/store-subscription-details-locally",{paypal_subscription_id:t})}function Le(){return s.jsxs(re,{children:[s.jsx(w,{path:":productId/:priceId",element:s.jsx(S,{children:s.jsx(ge,{})})}),s.jsx(w,{path:":productId/:priceId/stripe/done",element:s.jsx(S,{children:s.jsx(ve,{})})}),s.jsx(w,{path:":productId/:priceId/paypal/done",element:s.jsx(S,{children:s.jsx(we,{})})})]})}export{Le as default};
//# sourceMappingURL=checkout-routes-05b6ef38.js.map