-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update stripe utils, impl confirmation page, update premium section
- Loading branch information
Showing
3 changed files
with
78 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import { Center, Container, Title, useMantineTheme } from '@mantine/core'; | ||
import { GetServerSideProps } from 'next/types'; | ||
import { validateCheckoutSession } from 'api/stripe'; | ||
|
||
const PremiumConfirmation = (props: { success: boolean }) => { | ||
const theme = useMantineTheme(); | ||
return ( | ||
<Container style={{ maxWidth: '700px' }}> | ||
<Center | ||
style={{ | ||
minHeight: '230px', | ||
paddingTop: theme.spacing.xl, | ||
paddingBottom: theme.spacing.md, | ||
}} | ||
> | ||
<Title size={'h2'}> | ||
Premium{' '} | ||
{props.success ? 'Activated' : 'Subscription Failed'}! | ||
</Title> | ||
</Center> | ||
</Container> | ||
); | ||
}; | ||
|
||
export const getServerSideProps: GetServerSideProps< | ||
any, | ||
{ id: string } | ||
> = async ({ params, res }) => { | ||
res.setHeader('Cache-Control', 'private, maxage=600'); | ||
|
||
let success = false; | ||
const checkoutSessionId = params?.id; | ||
|
||
if (checkoutSessionId) { | ||
const sessionPaid = await validateCheckoutSession(checkoutSessionId); | ||
|
||
if (sessionPaid) success = true; | ||
} | ||
|
||
return { props: { success } }; | ||
}; | ||
|
||
export default PremiumConfirmation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters