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

@ -28,7 +28,6 @@ import { registerMeetingDocTemplateHandlers } from './meeting-doc-template-handl
import { registerCloudSyncHandlers } from './cloud-sync-handlers'
import { registerAdsHandlers } from './ads-handlers'
import { registerSupportHandlers } from './support-handlers'
import { registerPaymentHandlers } from './payment-handlers'
import { registerInputTelemetryHandlers } from './input-telemetry-handlers'
import { registerSuggestionHandlers } from './suggestion-handlers'
import { getLogger } from '../services/LoggerService'
@ -64,7 +63,6 @@ export function registerAllIpcHandlers(): void {
registerCloudSyncHandlers()
registerAdsHandlers()
registerSupportHandlers()
registerPaymentHandlers()
registerInputTelemetryHandlers()
registerSuggestionHandlers()
logger.info('All IPC handlers registered')

View file

@ -1,247 +0,0 @@
// apps/desktop/src/main/ipc/payment-handlers.ts
// Authenticated, server-authoritative checkout and subscription IPC handlers.
import { randomUUID } from 'node:crypto'
import { ipcMain } from 'electron'
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
import { ErrorCode, ipcError, ok, type IPCResult } from '@d3ro/core/errors'
import type { CheckoutSessionParams, CheckoutSessionResult } from '@d3ro/core/types'
import { billingUrl } from '@d3ro/core/web-urls'
import { getCloudSyncService } from '../services/CloudSyncService'
const CHECKOUT_FUNCTION = 'stripe-checkout'
const SUBSCRIPTION_FUNCTION = 'payple-manage'
const CHECKOUT_SUCCESS_URL = billingUrl({ result: 'success' })
const CHECKOUT_CANCEL_URL = billingUrl({ result: 'canceled' })
const STRIPE_CHECKOUT_ORIGIN = 'https://checkout.stripe.com'
const STRIPE_CHECKOUT_PATH_PREFIX = '/c/pay/'
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
const SERVER_ENTITLED_STATUSES = new Set([
'active',
'trialing',
'past_due',
'canceled',
'cancelled'
])
export const PAYMENT_REQUEST_TIMEOUT_MS = 15_000
const CHECKOUT_IDEMPOTENCY_TTL_MS = 5 * 60_000
type PaidTier = 'pro' | 'pro_plus'
type CloudSyncService = ReturnType<typeof getCloudSyncService>
interface CheckoutAttempt {
idempotencyKey: string
expiresAt: number
inFlight?: Promise<IPCResult<CheckoutSessionResult>>
result?: CheckoutSessionResult
}
interface SubscriptionStatus {
tier: 'free' | PaidTier
valid: boolean
expiresAt: number | null
}
class PaymentTimeoutError extends Error {}
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null && !Array.isArray(value)
}
function parseCheckoutParams(value: unknown): { tier: PaidTier } | null {
if (!isRecord(value)) return null
if (value.provider !== 'stripe') return null
if (value.tier !== 'pro' && value.tier !== 'pro_plus') return null
return { tier: value.tier }
}
function getAuthenticatedCloud(): { cloud: CloudSyncService; userId: string } | null {
const cloud = getCloudSyncService()
const user = cloud.getUser()
if (!cloud.isAuthenticated() || !user || !UUID_PATTERN.test(user.id)) return null
return { cloud, userId: user.id }
}
async function invokeWithDeadline(
cloud: CloudSyncService,
name: string,
body: Record<string, unknown>
): Promise<{ data: unknown; error: { message: string } | null }> {
const controller = new AbortController()
let timeout: ReturnType<typeof setTimeout> | undefined
const deadline = new Promise<never>((_resolve, reject) => {
timeout = setTimeout(() => {
controller.abort()
reject(new PaymentTimeoutError('Payment server request timed out'))
}, PAYMENT_REQUEST_TIMEOUT_MS)
})
try {
return await Promise.race([
cloud.invokeFunction(name, body, {
signal: controller.signal,
timeoutMs: PAYMENT_REQUEST_TIMEOUT_MS
}),
deadline
])
} finally {
if (timeout !== undefined) clearTimeout(timeout)
}
}
function parseTrustedCheckoutUrl(value: unknown): string | null {
if (!isRecord(value) || typeof value.url !== 'string') return null
try {
const url = new URL(value.url)
if (
url.protocol !== 'https:' ||
url.origin !== STRIPE_CHECKOUT_ORIGIN ||
url.username !== '' ||
url.password !== '' ||
!url.pathname.startsWith(STRIPE_CHECKOUT_PATH_PREFIX) ||
url.pathname.length <= STRIPE_CHECKOUT_PATH_PREFIX.length
)
return null
return url.toString()
} catch {
return null
}
}
function parseServerSubscription(value: unknown, now = Date.now()): SubscriptionStatus | null {
if (!isRecord(value)) return null
if (value.tier !== 'free' && value.tier !== 'pro' && value.tier !== 'pro_plus') return null
if (typeof value.status !== 'string' || value.status.length === 0) return null
let expiresAt: number | null = null
if (value.current_period_end !== null && value.current_period_end !== undefined) {
if (typeof value.current_period_end !== 'string') return null
const parsed = Date.parse(value.current_period_end)
if (!Number.isFinite(parsed)) return null
expiresAt = parsed
}
const paidTier = value.tier === 'pro' || value.tier === 'pro_plus'
const valid =
paidTier &&
SERVER_ENTITLED_STATUSES.has(value.status) &&
(expiresAt === null || expiresAt > now)
return {
tier: valid ? value.tier : 'free',
valid,
expiresAt
}
}
async function readServerSubscription(cloud: CloudSyncService): Promise<SubscriptionStatus> {
const response = await invokeWithDeadline(cloud, SUBSCRIPTION_FUNCTION, { action: 'info' })
if (response.error) throw new Error('subscription_provider_error')
const status = parseServerSubscription(response.data)
if (!status) throw new Error('subscription_response_invalid')
return status
}
function paymentFailure<T>(error: unknown, fallback: string): IPCResult<T> {
if (error instanceof PaymentTimeoutError) {
return ipcError(ErrorCode.UnknownError, 'Payment server request timed out')
}
return ipcError(ErrorCode.UnknownError, fallback)
}
export function registerPaymentHandlers(): void {
const attempts = new Map<string, CheckoutAttempt>()
ipcMain.handle(
IPC_CHANNELS.PAYMENT.CREATE_CHECKOUT_SESSION,
async (_event, rawParams: CheckoutSessionParams) => {
const params = parseCheckoutParams(rawParams)
if (!params) {
return ipcError(ErrorCode.UnknownError, 'Invalid checkout request')
}
const authenticated = getAuthenticatedCloud()
if (!authenticated) {
return ipcError(ErrorCode.UnknownError, 'Sign in is required for checkout')
}
const now = Date.now()
for (const [key, attempt] of attempts) {
if (!attempt.inFlight && attempt.expiresAt <= now) attempts.delete(key)
}
const fingerprint = `${authenticated.userId}:stripe:${params.tier}`
let attempt = attempts.get(fingerprint)
if (!attempt || attempt.expiresAt <= now) {
attempt = {
idempotencyKey: `desktop:stripe-checkout:${randomUUID()}`,
expiresAt: now + CHECKOUT_IDEMPOTENCY_TTL_MS
}
attempts.set(fingerprint, attempt)
}
if (attempt.result) return ok(attempt.result)
if (attempt.inFlight) return attempt.inFlight
const currentAttempt = attempt
const operation = (async (): Promise<IPCResult<CheckoutSessionResult>> => {
try {
const response = await invokeWithDeadline(authenticated.cloud, CHECKOUT_FUNCTION, {
tier: params.tier,
success_url: CHECKOUT_SUCCESS_URL,
cancel_url: CHECKOUT_CANCEL_URL,
idempotency_key: currentAttempt.idempotencyKey
})
if (response.error) {
return ipcError(ErrorCode.UnknownError, 'Checkout service rejected the request')
}
const checkoutUrl = parseTrustedCheckoutUrl(response.data)
if (!checkoutUrl) {
return ipcError(ErrorCode.UnknownError, 'Checkout service returned an invalid URL')
}
const result: CheckoutSessionResult = {
checkoutUrl,
provider: 'stripe',
status: 'pending'
}
currentAttempt.result = result
return ok(result)
} catch (error) {
return paymentFailure(error, 'Checkout service is unavailable')
} finally {
currentAttempt.inFlight = undefined
}
})()
currentAttempt.inFlight = operation
return operation
}
)
ipcMain.handle(IPC_CHANNELS.PAYMENT.VERIFY_PAYMENT, async () => {
const authenticated = getAuthenticatedCloud()
if (!authenticated) {
return ipcError(ErrorCode.UnknownError, 'Sign in is required to verify a subscription')
}
try {
const status = await readServerSubscription(authenticated.cloud)
return ok({ success: status.valid, activeTier: status.tier })
} catch (error) {
return paymentFailure(error, 'Subscription status is unavailable')
}
})
ipcMain.handle(IPC_CHANNELS.PAYMENT.GET_SUBSCRIPTION_STATUS, async () => {
const authenticated = getAuthenticatedCloud()
if (!authenticated) {
return ipcError(ErrorCode.UnknownError, 'Sign in is required to read a subscription')
}
try {
return ok(await readServerSubscription(authenticated.cloud))
} catch (error) {
return paymentFailure(error, 'Subscription status is unavailable')
}
})
}

View file

@ -93,7 +93,7 @@ export function registerSupportHandlers(): void {
const result: RefundEligibilityResult = {
eligible: true,
reason: '결제일로부터 7일 이내이며 클라우드 AI 정제 쿼터를 10% 미만 사용하셨습니다. (100% 전액 환불 가능)',
refundMethod: 'Toss Payments / Stripe 결제 즉시 취소',
refundMethod: 'Payple 카드 결제 즉시 취소',
estimatedRefundKrw: 229000,
}
return ok(result)