refactor(billing): remove Stripe; payments are Payple (web) and Google Play (mobile)
Some checks failed
ci / 정본·보안·린트·타입·테스트 (push) Failing after 1m13s
ci / 워크스페이스 빌드 검증 (push) Has been skipped
ci / 모바일 린트·타입·Jest (push) Failing after 1m4s
ci / Supabase Edge Functions + Cloudflare Worker (push) Successful in 37s
ci / .NET API 서버 테스트 (push) Successful in 27s
deploy-site / deploy (push) Failing after 20s

Stripe is not used. Keeping its checkout, portal and webhook paths meant a
second payment provider, a second return-URL format and dead UI.

- Delete the stripe-checkout, stripe-portal and stripe-webhook functions and
  their config; billing-catalog serves Payple prices only, and the web parser
  rejects a catalog that still mixes in Stripe prices.
- Web: drop the Stripe checkout/portal buttons, provider toggle and return
  notices; billing shows Payple only. Past rows with provider='stripe' are
  still displayed ("Stripe (종료)") with a support contact instead of a portal.
- Desktop: delete the Stripe checkout modal, payment IPC channels, preload
  namespace and their types; "Remove ads with Pro" opens the web billing page
  via license.openBilling. Support/refund copy names Payple.
- billingUrl() loses the Stripe-only success/canceled result option; the
  Deno contract is regenerated.
- Migrations and the DB's accepted provider values are untouched (history).
- Docs and the backlog record the removal (MON-04, EXT-STRIPE-01, GAP-BILL-03).

Verified: typecheck (desktop/web/admin/api-client/mobile), contract:check,
deno check all functions, deno test 80/80, desktop 1478/1480 on the Electron
runtime (2 known environment failures), web and admin builds, release
metadata and mobile boundary self-tests, eslint on changed files.
This commit is contained in:
Yun Chan 2026-09-26 20:56:18 +09:00
parent 7224e43bfb
commit eedd127ea7
50 changed files with 97 additions and 2600 deletions

View file

@ -1,12 +1,11 @@
'use client'
import { useMemo, useState } from 'react'
import { Alert, Box, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material'
import { CheckoutButton } from './checkout-button'
import { Alert, Box } from '@mui/material'
import { PaypleCheckoutButton } from './payple-checkout-button'
import type { PaypleTier } from './payple-client'
import type { BillingCatalogPrice, WebBillingProvider } from '@/lib/billing-catalog'
import type { BillingCatalogPrice } from '@/lib/billing-catalog'
/** 웹 결제 진입점. 결제사는 Payple(KRW) 하나이며 가격은 billing-catalog 응답을 따른다. */
export function BillingCheckoutOptions({
tier,
prices
@ -14,48 +13,12 @@ export function BillingCheckoutOptions({
tier: PaypleTier
prices: BillingCatalogPrice[]
}): React.ReactElement {
const availableProviders = useMemo(() => new Set(prices.map((price) => price.provider)), [prices])
const initialProvider: WebBillingProvider = availableProviders.has('payple') ? 'payple' : 'stripe'
const [provider, setProvider] = useState<WebBillingProvider>(initialProvider)
const payplePrice = prices.find((price): price is BillingCatalogPrice & { provider: 'payple' } => (
price.provider === 'payple'
))
const payplePrice = prices.find((price) => price.provider === 'payple')
return (
<Box data-testid={`billing-checkout-${tier}`}>
<Typography sx={{ mb: 1, color: 'var(--d3-text-label)', fontSize: 11 }}>
결제 수단을 선택해 주세요. 한 구독에는 하나의 결제사만 사용할 수 있습니다.
</Typography>
<ToggleButtonGroup
exclusive
fullWidth
size="small"
value={provider}
onChange={(_event, value: WebBillingProvider | null) => {
if (value !== null && availableProviders.has(value)) setProvider(value)
}}
aria-label="결제사 선택"
sx={{ mb: 1.5 }}
>
<ToggleButton value="payple" aria-label="Payple 국내 카드" disabled={!availableProviders.has('payple')}>
국내 카드 · Payple
</ToggleButton>
<ToggleButton value="stripe" aria-label="Stripe 해외 카드" disabled={!availableProviders.has('stripe')}>
해외 카드 · Stripe
</ToggleButton>
</ToggleButtonGroup>
{provider === 'payple' ? (
payplePrice ? <PaypleCheckoutButton tier={tier} catalogPrice={payplePrice} /> : (
<Alert severity="error">Payple 가격을 확인할 수 없습니다.</Alert>
)
) : (
<>
<Alert severity="info" variant="outlined" sx={{ mb: 1, fontSize: 11 }}>
Stripe Checkout으로 이동해 해외 발급 카드를 결제합니다.
</Alert>
<CheckoutButton tier={tier} />
</>
{payplePrice ? <PaypleCheckoutButton tier={tier} catalogPrice={payplePrice} /> : (
<Alert severity="error">Payple 가격을 확인할 수 없습니다.</Alert>
)}
</Box>
)

View file

@ -1,91 +0,0 @@
'use client'
// apps/web/src/components/billing/checkout-button.tsx
// Stripe Checkout 시작 — Edge Function stripe-checkout 호출
import { useState } from 'react'
import { Button, CircularProgress, Alert, Box } from '@mui/material'
import { getSupabaseBrowserClient } from '@/lib/supabase-browser'
import { browserBillingUrl } from '@/lib/web-app-url'
import type { PaypleTier } from './payple-client'
interface CheckoutButtonProps {
tier: PaypleTier
}
export function CheckoutButton({ tier }: CheckoutButtonProps): React.ReactElement {
const [busy, setBusy] = useState(false)
const [error, setError] = useState<string | null>(null)
async function handleCheckout(): Promise<void> {
setError(null)
setBusy(true)
try {
const supabase = getSupabaseBrowserClient()
const {
data: { session },
error: sessionError
} = await supabase.auth.getSession()
if (sessionError || !session) {
setError('로그인이 필요합니다')
return
}
const baseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL?.trim()
if (!baseUrl) throw new Error('결제 서버 설정이 완료되지 않았습니다')
const endpoint = new URL('/functions/v1/stripe-checkout', baseUrl).toString()
const response = await fetch(
endpoint,
{
method: 'POST',
headers: {
Authorization: `Bearer ${session.access_token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
tier,
idempotency_key: `stripe-checkout:${crypto.randomUUID()}`,
success_url: browserBillingUrl('success'),
cancel_url: browserBillingUrl('canceled')
})
}
)
const data = (await response.json().catch(() => null)) as { url?: unknown } | null
if (!response.ok) throw new Error('Stripe Checkout을 시작하지 못했습니다')
if (typeof data?.url !== 'string') throw new Error('Checkout URL을 받지 못했습니다')
const checkoutUrl = new URL(data.url)
if (checkoutUrl.protocol !== 'https:' || checkoutUrl.hostname !== 'checkout.stripe.com') {
throw new Error('Checkout URL을 신뢰할 수 없습니다')
}
window.location.assign(checkoutUrl.toString())
} catch (e) {
setError(e instanceof Error ? e.message : 'Unknown error')
} finally {
setBusy(false)
}
}
return (
<Box>
<Button
fullWidth
variant="contained"
size="large"
data-testid={`stripe-upgrade-${tier}`}
onClick={() => void handleCheckout()}
disabled={busy}
startIcon={busy ? <CircularProgress size={16} color="inherit" /> : null}
>
{tier === 'pro_plus' ? 'PRO+' : 'PRO'} Stripe로 업그레이드
</Button>
{error && (
<Alert severity="error" variant="outlined" sx={{ mt: 1, fontSize: 11 }}>
{error}
</Alert>
)}
</Box>
)
}

View file

@ -1,82 +0,0 @@
'use client'
// apps/web/src/components/billing/portal-button.tsx
// Stripe Customer Portal — 활성 구독 사용자가 결제 수단/취소 등을 관리
import { useState } from 'react'
import { Button, CircularProgress, Alert, Box } from '@mui/material'
import SettingsIcon from '@mui/icons-material/Settings'
import { getSupabaseBrowserClient } from '@/lib/supabase-browser'
import { browserBillingUrl } from '@/lib/web-app-url'
export function PortalButton(): React.ReactElement {
const [busy, setBusy] = useState(false)
const [error, setError] = useState<string | null>(null)
async function handleOpenPortal(): Promise<void> {
setError(null)
setBusy(true)
try {
const supabase = getSupabaseBrowserClient()
const {
data: { session },
error: sessionError
} = await supabase.auth.getSession()
if (sessionError || !session) {
setError('로그인이 필요합니다')
return
}
const baseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL?.trim()
if (!baseUrl) throw new Error('결제 서버 설정이 완료되지 않았습니다')
const response = await fetch(
new URL('/functions/v1/stripe-portal', baseUrl).toString(),
{
method: 'POST',
headers: {
Authorization: `Bearer ${session.access_token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
return_url: browserBillingUrl()
})
}
)
const data = await response.json().catch(() => null) as { url?: unknown } | null
if (!response.ok) throw new Error('Stripe 구독 관리 페이지를 열지 못했습니다')
if (typeof data?.url !== 'string') throw new Error('구독 관리 URL을 받지 못했습니다')
const portalUrl = new URL(data.url)
if (portalUrl.protocol !== 'https:' || portalUrl.hostname !== 'billing.stripe.com') {
throw new Error('구독 관리 URL을 신뢰할 수 없습니다')
}
window.location.assign(portalUrl.toString())
} catch (e) {
setError(e instanceof Error ? e.message : 'Unknown error')
} finally {
setBusy(false)
}
}
return (
<Box>
<Button
variant="outlined"
size="small"
data-testid="stripe-portal-open"
startIcon={busy ? <CircularProgress size={14} /> : <SettingsIcon />}
onClick={() => void handleOpenPortal()}
disabled={busy}
>
구독 관리
</Button>
{error && (
<Alert severity="error" variant="outlined" sx={{ mt: 1, fontSize: 11 }}>
{error}
</Alert>
)}
</Box>
)
}