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,65 +1,33 @@
import {
createBillingCatalog,
parseStripeCatalogPrice,
} from './billing-catalog.ts'
import { createBillingCatalog } from './billing-catalog.ts'
import { PLAN_PRICE_KRW } from './core-contract.generated.ts'
function assert(condition: unknown, message: string): asserts condition {
if (!condition) throw new Error(message)
}
Deno.test('Stripe catalog accepts only the exact active recurring price', () => {
const parsed = parseStripeCatalogPrice({
id: 'price_pro',
active: true,
type: 'recurring',
unit_amount: 990,
currency: 'usd',
recurring: { interval: 'month', interval_count: 1 },
}, 'price_pro')
assert(parsed?.unit_amount === 990, 'amount must be preserved')
assert(parsed?.currency === 'USD', 'currency must be normalized')
assert(parsed?.interval === 'month', 'interval must be preserved')
})
Deno.test('Stripe catalog rejects mismatched, inactive, free, malformed, and one-time prices', () => {
const base = {
id: 'price_pro',
active: true,
type: 'recurring',
unit_amount: 990,
currency: 'usd',
recurring: { interval: 'month', interval_count: 1 },
}
const invalid = [
{ ...base, id: 'price_other' },
{ ...base, active: false },
{ ...base, type: 'one_time', recurring: null },
{ ...base, unit_amount: 0 },
{ ...base, currency: 'US$' },
{ ...base, recurring: { interval: 'minute', interval_count: 1 } },
{ ...base, recurring: { interval: 'month', interval_count: 0 } },
]
for (const value of invalid) {
assert(parseStripeCatalogPrice(value, 'price_pro') === null, 'invalid Stripe price must fail closed')
}
})
Deno.test('catalog exposes only configured provider prices and never invents a fallback', () => {
Deno.test('catalog exposes only configured Payple prices and never invents a fallback', () => {
const catalog = createBillingCatalog({
payple: { pro: PLAN_PRICE_KRW.pro, pro_plus: PLAN_PRICE_KRW.pro_plus },
stripe: {
pro: { unit_amount: 990, currency: 'USD', interval: 'month', interval_count: 1 },
},
})
assert(catalog.plans[0].prices.length === 2, 'pro must expose two verified providers')
assert(catalog.plans[1].prices.length === 1, 'pro plus must omit unavailable Stripe')
assert(
catalog.plans.every((plan) => plan.prices.length === 1 && plan.prices[0].provider === 'payple'),
'each paid plan must expose exactly one Payple price',
)
assert(
catalog.plans[0].prices[0].unit_amount === PLAN_PRICE_KRW.pro
&& catalog.plans[1].prices[0].unit_amount === PLAN_PRICE_KRW.pro_plus,
'Payple prices must come from the core plan catalog',
)
assert(
catalog.plans.every((plan) => plan.prices[0].currency === 'KRW' && plan.prices[0].interval === 'month'),
'Payple prices are monthly KRW',
)
const unavailable = createBillingCatalog({})
assert(unavailable.plans.every((plan) => plan.prices.length === 0), 'missing configuration must stay unavailable')
})
Deno.test('catalog rejects non-positive or non-integer Payple amounts', () => {
const catalog = createBillingCatalog({ payple: { pro: 0, pro_plus: 1.5 } })
assert(catalog.plans.every((plan) => plan.prices.length === 0), 'invalid amounts must fail closed')
})

View file

@ -1,5 +1,6 @@
export type BillingCatalogTier = 'pro' | 'pro_plus'
export type BillingCatalogProvider = 'payple' | 'stripe'
/** 웹 결제는 Payple(KRW) 하나다. 모바일은 Google Play 스토어 가격을 쓰고 이 카탈로그에 오지 않는다. */
export type BillingCatalogProvider = 'payple'
export interface BillingCatalogPrice {
provider: BillingCatalogProvider
@ -19,54 +20,8 @@ export interface BillingCatalogResponse {
plans: BillingCatalogPlan[]
}
interface StripePriceRecord {
id?: unknown
active?: unknown
type?: unknown
unit_amount?: unknown
currency?: unknown
recurring?: {
interval?: unknown
interval_count?: unknown
} | null
}
const CURRENCY_PATTERN = /^[a-z]{3}$/
const INTERVALS = new Set(['day', 'week', 'month', 'year'])
export function parseStripeCatalogPrice(
value: unknown,
expectedId: string,
): Omit<BillingCatalogPrice, 'provider'> | null {
if (!value || typeof value !== 'object' || Array.isArray(value)) return null
const price = value as StripePriceRecord
if (
price.id !== expectedId
|| price.active !== true
|| price.type !== 'recurring'
|| !Number.isSafeInteger(price.unit_amount)
|| (price.unit_amount as number) < 1
|| typeof price.currency !== 'string'
|| !CURRENCY_PATTERN.test(price.currency)
|| !price.recurring
|| typeof price.recurring.interval !== 'string'
|| !INTERVALS.has(price.recurring.interval)
|| !Number.isSafeInteger(price.recurring.interval_count)
|| (price.recurring.interval_count as number) < 1
|| (price.recurring.interval_count as number) > 12
) return null
return {
unit_amount: price.unit_amount as number,
currency: price.currency.toUpperCase(),
interval: price.recurring.interval as BillingCatalogPrice['interval'],
interval_count: price.recurring.interval_count as number,
}
}
export function createBillingCatalog(input: {
payple?: Record<BillingCatalogTier, number> | null
stripe?: Partial<Record<BillingCatalogTier, Omit<BillingCatalogPrice, 'provider'>>> | null
}): BillingCatalogResponse {
const tiers: BillingCatalogTier[] = ['pro', 'pro_plus']
return {
@ -83,8 +38,6 @@ export function createBillingCatalog(input: {
interval_count: 1,
})
}
const stripePrice = input.stripe?.[tier]
if (stripePrice) prices.push({ provider: 'stripe', ...stripePrice })
return { tier, prices }
}),
}

View file

@ -18,7 +18,7 @@ export type PlanTier = 'free' | PaidPlanTier
/**
* 월 요금(원). Payple 청구 금액이며, 기존 구독자도 다음 갱신부터 이 값으로 청구된다.
* Stripe(USD)·Google Play 가격은 각 콘솔에서 따로 관리한다.
* Google Play 가격은 Play Console에서 따로 관리한다. 웹 결제는 Payple(KRW) 하나다.
*/
export const PLAN_PRICE_KRW: Readonly<Record<PlanTier, number>> = {
free: 0,
@ -122,19 +122,13 @@ export const SITE_URLS = {
acceptInvite: `${PUBLIC_SITE_ORIGIN}/accept-invite/`,
} as const
/** 결제 결과로 돌아올 때 붙는 쿼리. apps/web 결제 페이지가 읽는 이름과 같다. */
export type BillingReturn = 'success' | 'canceled'
/**
* 웹 결제 페이지 URL.
* 웹 결제 페이지 URL. 결제는 이 페이지 안의 Payple 창에서 끝나므로 복귀 쿼리가 없다.
* - `tier`: 고를 요금제를 미리 선택한다.
* - `result`: 외부 결제(Stripe 등)에서 돌아올 때의 결과.
*/
export function billingUrl(options: { tier?: PaidPlanTier; result?: BillingReturn } = {}): string {
export function billingUrl(options: { tier?: PaidPlanTier } = {}): string {
const params = new URLSearchParams()
if (options.tier) params.set('tier', options.tier)
if (options.result === 'success') params.set('success', '1')
if (options.result === 'canceled') params.set('canceled', '1')
const query = params.toString()
return `${WEB_APP_URL}/billing${query ? `?${query}` : ''}`
}