1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-14 10:36:19 +02:00

fix billing

This commit is contained in:
Kushagra Gour
2024-04-25 00:36:29 +05:30
parent f04a0f3b72
commit 9e6130d38b
4 changed files with 61 additions and 33 deletions

View File

@ -207,19 +207,11 @@ const Assets = ({ onProBtnClick, onLoginBtnClick }) => {
<VStack align="stretch" gap={2}> <VStack align="stretch" gap={2}>
<p>Assets feature is available in PRO plan.</p> <p>Assets feature is available in PRO plan.</p>
<button <button
class="btn btn--primary" class="btn btn--pro"
onClick={window.user ? onProBtnClick : onLoginBtnClick} onClick={window.user ? onProBtnClick : onLoginBtnClick}
> >
<HStack gap={1} fullWidth justify="center"> <HStack gap={1} fullWidth justify="center">
{window.user ? ( {window.user ? <>Upgrade to PRO</> : <>Login & upgrade to PRO</>}
<>
Upgrade to <ProBadge />
</>
) : (
<>
Login & upgrade to <ProBadge />
</>
)}
</HStack> </HStack>
</button> </button>
</VStack> </VStack>

View File

@ -11,7 +11,8 @@ import { showConfetti } from '../utils';
const checkoutIds = { const checkoutIds = {
monthly: '1601bc00-9623-435b-b1de-2a70a2445c13', monthly: '1601bc00-9623-435b-b1de-2a70a2445c13',
annual: 'aae95d78-05c8-46f5-b11e-2d40ddd211d3' annual: 'aae95d78-05c8-46f5-b11e-2d40ddd211d3',
generic: 'f8c64e50-7734-438b-a122-3510156f14ed'
}; };
export function Pro({ user }) { export function Pro({ user }) {
const hasCheckoutLoaded = useCheckout(); const hasCheckoutLoaded = useCheckout();
@ -38,7 +39,7 @@ export function Pro({ user }) {
}, [hasCheckoutLoaded]); }, [hasCheckoutLoaded]);
return ( return (
<VStack gap={2} align="stretch"> <VStack gap={2} align="stretch">
<Stack justify="center"> {/* <Stack justify="center">
<Switch <Switch
labels={['Monthly', 'Annually']} labels={['Monthly', 'Annually']}
checked={isAnnual} checked={isAnnual}
@ -47,7 +48,7 @@ export function Pro({ user }) {
setIsAnnual(e.target.checked); setIsAnnual(e.target.checked);
}} }}
/> />
</Stack> </Stack> */}
<Stack gap={2} align="stretch"> <Stack gap={2} align="stretch">
<Card <Card
price="Free" price="Free"
@ -60,17 +61,15 @@ export function Pro({ user }) {
/> />
<Card <Card
bg="#674dad" bg="#674dad"
price={!isAnnual ? '$8/mo' : '$65/yr'} price={'Starting $6/mo'}
name="Pro" name="Pro"
action={ action={
<A <A
class="btn btn--primary lemonsqueezy-button d-f jc-c ai-c" class="btn btn--pro lemonsqueezy-button d-f jc-c ai-c"
style="gap:0.2rem" style="gap:0.2rem"
href={`https://web-maker.lemonsqueezy.com/checkout/buy/${ href={`https://web-maker.lemonsqueezy.com/checkout/buy/${checkoutIds.generic}?embed=1&checkout[custom][userId]=${user?.uid}`}
checkoutIds[isAnnual ? 'annual' : 'monthly']
}?embed=1&checkout[custom][userId]=${user?.uid}`}
> >
Go <ProBadge /> Go PRO
</A> </A>
} }
features={[ features={[

View File

@ -53,7 +53,11 @@ export function Profile({ user, logoutBtnHandler }) {
setIsFetchingSubscription(false); setIsFetchingSubscription(false);
const creationEvent = events const creationEvent = events
.filter(event => event.type === 'subscription_created') .filter(
event =>
event.type === 'subscription_created' ||
event.type === 'order_created'
)
.sort((a, b) => b.timestamp.seconds - a.timestamp.seconds)[0]; .sort((a, b) => b.timestamp.seconds - a.timestamp.seconds)[0];
if (creationEvent) { if (creationEvent) {
console.log(creationEvent); console.log(creationEvent);
@ -69,7 +73,7 @@ export function Profile({ user, logoutBtnHandler }) {
{window.user?.isPro && ( {window.user?.isPro && (
<Panel> <Panel>
{isFetchingSubscription ? ( {isFetchingSubscription ? (
<LoaderWithText>Loading subscription details...</LoaderWithText> <LoaderWithText>Loading billing details...</LoaderWithText>
) : null} ) : null}
{currentSubscription ? ( {currentSubscription ? (
<VStack align="stretch" gap={1}> <VStack align="stretch" gap={1}>
@ -77,31 +81,39 @@ export function Profile({ user, logoutBtnHandler }) {
Plan: Plan:
<Text weight="700"> <Text weight="700">
{' '} {' '}
{currentSubscription.attributes.product_name} Web Maker PRO (
{currentSubscription.attributes.first_order_item.variant_name}
)
</Text> </Text>
</Text> </Text>
<Text> <Text>
Subscription Status:{' '} Subscription Status:{' '}
<Text weight="700"> <Text weight="700">
{currentSubscription.attributes.status} {currentSubscription.attributes.status === 'paid'
? 'PRO for life ❤️'
: currentSubscription.attributes.status}
</Text> </Text>
</Text> </Text>
<Text> <Text>
Renews on:{' '} Renews on:{' '}
<Text weight="700"> <Text weight="700">
{getHumanReadableDate( {currentSubscription.attributes.status === 'paid'
? 'Never ever'
: getHumanReadableDate(
currentSubscription.attributes.renews_at currentSubscription.attributes.renews_at
)} )}
</Text> </Text>
</Text> </Text>
{currentSubscription.attributes.status === 'paid' ? null : (
<a <a
target="_blank" target="_blank"
href={currentSubscription.attributes.urls.customer_portal} href={currentSubscription.attributes.urls.customer_portal}
> >
Cancel subscription Cancel subscription
</a> </a>
)}
{/* <a {/* <a
target="_blank" target="_blank"
href={ href={

View File

@ -478,6 +478,31 @@ a > svg {
margin-right: 12px; margin-right: 12px;
} }
@property --angle {
syntax: '<angle>';
initial-value: 0deg;
inherits: false;
}
.btn--pro {
background: linear-gradient(
var(--angle),
var(--color-pro-1),
var(--color-pro-2)
);
color: #222;
border: 0;
font-weight: 700;
animation: gradient_move 3s ease infinite;
}
@keyframes gradient_move {
from {
--angle: 0deg;
}
to {
--angle: 360deg;
}
}
.btn-loader { .btn-loader {
display: none; display: none;
} }
@ -2228,7 +2253,7 @@ while the theme CSS file is loading */
padding: 0.1rem 0.3rem; padding: 0.1rem 0.3rem;
background: crimson; background: crimson;
border-radius: 1rem; border-radius: 1rem;
font-size: 0.7em; font-size: 0.75em;
color: #222; color: #222;
font-weight: 800; font-weight: 800;
line-height: 1; line-height: 1;