Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tweak plan gate query param #163

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/PlanGate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { TopLevelLoader } from './Loader';
import { Logo } from '@/brand';
import { usePlan } from '@/hooks';
import { useRecordRefcode, useReferredBy } from '@/lib/referrals/hooks';
import { useSearchParams } from 'next/navigation';

export function PlanGate ({ children }: { children: ReactNode }): ReactNode {
const [{ accounts }] = useW3()
Expand Down Expand Up @@ -64,7 +65,8 @@ export function PlanGate ({ children }: { children: ReactNode }): ReactNode {
}

export function MaybePlanGate ({ children }: { children: ReactNode }): ReactNode {
if (process.env.NEXT_PUBLIC_DISABLE_PLAN_GATE == 'true') {
const params = useSearchParams()
if ((process.env.NEXT_PUBLIC_DISABLE_PLAN_GATE == 'true') || params.get('checkout.session')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check if the checkout was completed?
e.g: https://docs.stripe.com/api/events/types#event_types-checkout.session.completed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah so that's a slightly separate thing - the name matches the event names, but the param is actually just set manually in the Stripe pricing table config:

Screenshot 2024-12-12 at 10 39 15 AM

I had been planning on adding checkout as a custom query param but realized we already have checkout.session - we only redirect here if checkout completed so it's essentially what you're suggesting already

return children
} else {
return <PlanGate>{children}</PlanGate>
Expand Down
Loading