Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.2 KB
Raw Blame
import { useActions, useValues } from 'kea'

import { LemonBanner, LemonButton, SpinnerOverlay } from '@posthog/lemon-ui'

import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { urls } from 'scenes/urls'

import { PaymentCompletion } from './PaymentCompletion'
import { paymentEntryLogic } from './paymentEntryLogic'

// note(@zach): this page is only used when a payment method is entered into the payment entry modal
// that requires the user to be redirect to another url, this is where they get redirected back to
export const AuthorizationStatus = (): JSX.Element => {
    const { pollAuthorizationStatus } = useActions(paymentEntryLogic)
    const { apiError, stripeError, completedPaymentOrganization } = useValues(paymentEntryLogic)
    useOnMountEffect(pollAuthorizationStatus)

    if (completedPaymentOrganization) {
        return <PaymentCompletion />
    }
    if (apiError || stripeError) {
        return (
            <LemonBanner type="error">
                <p>{apiError || stripeError}</p>
                <LemonButton to={urls.organizationBilling()} type="primary">
                    Return to billing
                </LemonButton>
            </LemonBanner>
        )
    }
    return <SpinnerOverlay sceneLevel />
}