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

@ -7,7 +7,6 @@ import { MetalCard, TactileBadge } from '@d3ro/ui/components/ds'
import { d3roFontMono } from '@d3ro/ui/theme'
import { BillingCheckoutOptions } from '@/components/billing/billing-checkout-options'
import { PaypleManageButton } from '@/components/billing/payple-manage-button'
import { PortalButton } from '@/components/billing/portal-button'
import { getSupabaseServerClient } from '@/lib/supabase-server'
import {
formatPlanCatalogPrice,
@ -45,6 +44,7 @@ interface Plan {
}
const VALID_TIERS = new Set<SubscriptionTier>(['free', 'pro', 'pro_plus'])
// 'stripe' 는 결제 경로가 제거된 뒤에도 과거 구독 행(provider='stripe')을 읽기 위해 남긴다.
const VALID_PROVIDERS = new Set<BillingProvider>([
'none',
'stripe',
@ -96,7 +96,7 @@ function providerLabel(provider: BillingProvider): string {
const labels: Record<BillingProvider, string> = {
none: '없음',
payple: 'Payple',
stripe: 'Stripe',
stripe: 'Stripe (종료)',
google_play: 'Google Play',
app_store: 'App Store',
admin: '관리자 부여'
@ -164,8 +164,6 @@ export default async function BillingPage({ searchParams }: BillingPageProps): P
const canPurchase = !isPaid && subscription.provider === 'none'
const cancellationDate = formatDate(subscription.cancel_at)
const periodEnd = formatDate(subscription.current_period_end)
const stripeCanceled = params['canceled'] === '1'
const stripeReturned = params['success'] === '1'
const selectedTier = selectedTierFrom(params['tier'])
return (
@ -182,19 +180,6 @@ export default async function BillingPage({ searchParams }: BillingPageProps): P
</Typography>
</Box>
{stripeCanceled && (
<Alert severity="info" sx={{ mb: 2 }} data-testid="stripe-canceled-message">
Stripe Checkout을 취소했습니다. 결제나 구독 변경은 발생하지 않았습니다.
</Alert>
)}
{stripeReturned && (
<Alert severity={isPaid ? 'success' : 'warning'} sx={{ mb: 2 }} data-testid="stripe-return-message">
{isPaid
? 'Stripe 결제가 확인되어 구독 정보가 갱신되었습니다.'
: 'Stripe 결제 결과를 확인 중입니다. 잠시 후 이 페이지를 새로고침해 주세요.'}
</Alert>
)}
<MetalCard sx={{ p: { xs: 2.5, md: 3.5 }, mb: 4 }}>
<Stack direction={{ xs: 'column', md: 'row' }} justifyContent="space-between" gap={3}>
<Box>
@ -257,7 +242,7 @@ export default async function BillingPage({ searchParams }: BillingPageProps): P
</Box>
<Typography sx={{ mt: 4, textAlign: 'center', color: 'var(--d3-text-label)', fontSize: 11 }}>
국내 카드는 Payple, 해외 카드는 Stripe가 처리합니다. 활성 구독이 있으면 같은 provider에서만 관리할 수 있습니다.
웹 결제는 Payple(원화 카드)이 처리합니다. 모바일 앱 구독은 Google Play에서 관리합니다.
</Typography>
</Box>
)
@ -350,7 +335,9 @@ function SubscriptionManagement({ subscription }: { subscription: BillingSubscri
return <Typography sx={{ color: 'var(--d3-status-warning)', fontSize: 12 }}>자동 갱신이 해지되었습니다.</Typography>
}
if (subscription.provider === 'payple') return <PaypleManageButton />
if (subscription.provider === 'stripe') return <PortalButton />
if (subscription.provider === 'stripe') {
return <Alert severity="info">종료된 Stripe 결제로 만든 구독입니다. 변경·해지는 고객센터에 문의해 주세요.</Alert>
}
if (subscription.provider === 'google_play') {
return <Alert severity="info">Google Play 앱에서 구독을 관리해 주세요.</Alert>
}

View file

@ -52,7 +52,7 @@ function tierLabel(tier: DashboardSnapshot['subscription']['tier']): string {
function providerLabel(provider: DashboardSnapshot['subscription']['provider']): string {
const labels: Record<DashboardSnapshot['subscription']['provider'], string> = {
none: '미연결',
stripe: 'Stripe',
stripe: 'Stripe (종료)',
payple: '페이플',
google_play: 'Google Play',
app_store: 'App Store',

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>
)
}

View file

@ -1,6 +1,7 @@
import type { SubscriptionTier } from '@d3ro/api-client'
export type WebBillingProvider = 'payple' | 'stripe'
/** 웹 결제사는 Payple(KRW) 하나다. Stripe는 2026-09-26 제거됐다. */
export type WebBillingProvider = 'payple'
export type BillingInterval = 'day' | 'week' | 'month' | 'year'
export interface BillingCatalogPrice {
@ -15,7 +16,7 @@ export interface BillingCatalog {
plans: Record<'pro' | 'pro_plus', BillingCatalogPrice[]>
}
const PROVIDERS = new Set<WebBillingProvider>(['payple', 'stripe'])
const PROVIDERS = new Set<WebBillingProvider>(['payple'])
const INTERVALS = new Set<BillingInterval>(['day', 'week', 'month', 'year'])
const PAID_TIERS = new Set(['pro', 'pro_plus'])
@ -30,7 +31,7 @@ export function parseBillingCatalog(value: unknown): BillingCatalog | null {
if (!rawPlan || typeof rawPlan !== 'object' || Array.isArray(rawPlan)) return null
const plan = rawPlan as { tier?: unknown; prices?: unknown }
if (typeof plan.tier !== 'string' || !PAID_TIERS.has(plan.tier) || seenTiers.has(plan.tier)) return null
if (!Array.isArray(plan.prices) || plan.prices.length > 2) return null
if (!Array.isArray(plan.prices) || plan.prices.length > PROVIDERS.size) return null
seenTiers.add(plan.tier)
const seenProviders = new Set<string>()
for (const rawPrice of plan.prices) {
@ -91,7 +92,5 @@ export function formatPlanCatalogPrice(
if (tier === 'free') return '무료'
if (!catalog) return null
const prices = catalog.plans[tier]
if (prices.length === 0) return null
if (prices.length === 1) return formatBillingPrice(prices[0])
return prices.map((price) => `${price.provider === 'payple' ? 'Payple' : 'Stripe'} ${formatBillingPrice(price)}`).join(' · ')
return prices.length === 0 ? null : formatBillingPrice(prices[0])
}

View file

@ -1,15 +1,10 @@
// apps/web/src/lib/web-app-url.ts
// 웹앱 안에서 쓰는 절대 URL·복귀 경로 헬퍼. 주소 정본은 @d3ro/core/web-urls 다.
//
// 결제사(Stripe·Payple)와 OAuth 는 절대 URL 을 요구한다. 운영은 d3ro.chanpaca.net/app,
// 결제사(Payple)와 OAuth 는 절대 URL 을 요구한다. 운영은 d3ro.chanpaca.net/app,
// 로컬 개발은 localhost:3000/app 이므로 origin 만 현재 브라우저 것으로 바꿔 끼운다.
import {
billingUrl,
PUBLIC_SITE_ORIGIN,
WEB_APP_BASE_PATH,
type BillingReturn
} from '@d3ro/core/web-urls'
import { billingUrl, PUBLIC_SITE_ORIGIN, WEB_APP_BASE_PATH } from '@d3ro/core/web-urls'
/** 로그인 뒤 돌아갈 경로를 proxy 가 (app) 레이아웃에 넘길 때 쓰는 요청 헤더. */
export const RETURN_PATH_HEADER = 'x-d3ro-return-path'
@ -39,7 +34,7 @@ export function appUrlFor(origin: string, path: string): string {
}
/** 브라우저에서 결제 페이지 절대 URL. 쿼리 형식은 core billingUrl() 을 그대로 따른다. */
export function browserBillingUrl(result?: BillingReturn): string {
const canonical = billingUrl(result ? { result } : {})
export function browserBillingUrl(): string {
const canonical = billingUrl()
return `${window.location.origin}${canonical.slice(PUBLIC_SITE_ORIGIN.length)}`
}