import { ExternalLink } from 'lucide-react'
import { Button } from 'ui'
import { Admonition } from 'ui-patterns/admonition'
import PartnerIcon from '@/components/ui/PartnerIcon'
import { MANAGED_BY } from '@/lib/constants/infrastructure'
export type StripeTokenStatus = 'connected' | 'attention' | 'unknown'
export const STRIPE_DASHBOARD_URL = 'https://dashboard.stripe.com'
export const STRIPE_PROJECTS_DOCS_URL = 'https://docs.stripe.com/projects'
interface StripePaymentConnectionProps {
status?: StripeTokenStatus
tokenLast4?: string | null
tokenExpiresAt?: number | null
}
const formatStripeTokenExpiry = (expiresAt?: number | null) => {
if (!expiresAt) return undefined
return new Date(expiresAt * 1000).toLocaleDateString('en-US', { month: 'short', year: 'numeric' })
}
export function StripePaymentConnection({
status = 'connected',
tokenLast4,
tokenExpiresAt,
}: StripePaymentConnectionProps) {
const tokenExpiry = formatStripeTokenExpiry(tokenExpiresAt)
const hasTokenSummary =
tokenLast4 !== null && tokenLast4 !== undefined && tokenExpiry !== undefined
if (status === 'attention') {
return (
Payment managed through Stripe
Billing for this organisation is handled via a connected Stripe payment token.
{hasTokenSummary && (Token ending in {tokenLast4} expires {tokenExpiry}.
)}