부모님 안심케어by 안부웍스
안부웍스 결제 설정

결제 주문과 구독을
서버에 저장합니다.

토스페이먼츠 결제창을 연결하고, 결제 성공 후 서버에서 승인한 뒤 결제내역과 구독 상태를 Supabase에 저장합니다.

현재 상태

NEXT_PUBLIC_SUPABASE_URL확인 필요
SUPABASE_SERVICE_ROLE_KEY확인 필요
NEXT_PUBLIC_TOSS_CLIENT_KEY확인 필요
TOSS_SECRET_KEY확인 필요
ANBU_ADMIN_CODE확인 필요

결제 테이블

아직 결제 설정이 완료되지 않았습니다. SQL 실행과 Vercel 환경변수를 확인하세요.

실행할 SQL

Supabase Dashboard → SQL Editor → New query에 붙여넣고 Run을 누르세요.

-- 안부웍스 결제/구독 저장용 스키마
create extension if not exists pgcrypto;

create table if not exists public.anbu_payment_orders (
  id uuid primary key default gen_random_uuid(),
  family_code text,
  order_id text unique not null,
  order_name text not null,
  plan_id text not null,
  plan_name text not null,
  amount integer not null default 0,
  billing_cycle text not null default 'one_time',
  plan_type text not null default 'care_fee',
  buyer_name text,
  buyer_phone text,
  buyer_email text,
  customer_key text,
  payment_provider text not null default 'toss',
  payment_key text,
  payment_status text not null default 'ready',
  requested_at timestamptz not null default now(),
  paid_at timestamptz,
  failed_at timestamptz,
  failure_reason text,
  raw_response jsonb not null default '{}'::jsonb,
  created_at timestamptz not null default now(),
  updated_at timestamptz not null default now()
);

create table if not exists public.anbu_subscriptions (
  id uuid primary key default gen_random_uuid(),
  family_code text,
  plan_id text not null,
  plan_name text not null,
  subscription_status text not null default 'active',
  current_period_start timestamptz not null default now(),
  current_period_end timestamptz,
  last_order_id text,
  created_at timestamptz not null default now(),
  updated_at timestamptz not null default now()
);

create unique index if not exists idx_anbu_payment_orders_order_id
  on public.anbu_payment_orders(order_id);

create index if not exists idx_anbu_payment_orders_family_code
  on public.anbu_payment_orders(family_code);

create index if not exists idx_anbu_payment_orders_status
  on public.anbu_payment_orders(payment_status);

create index if not exists idx_anbu_subscriptions_family_code
  on public.anbu_subscriptions(family_code);

create index if not exists idx_anbu_subscriptions_status
  on public.anbu_subscriptions(subscription_status);

Vercel 환경변수

Vercel Project Settings → Environment Variables에 아래 값을 넣고 재배포해야 합니다.

NEXT_PUBLIC_TOSS_CLIENT_KEY

토스페이먼츠 클라이언트 키. 브라우저 결제창에서 사용합니다.

TOSS_SECRET_KEY

토스페이먼츠 시크릿 키. 서버 결제 승인 API에서만 사용합니다.

NEXT_PUBLIC_SUPABASE_URL

Supabase Project URL

SUPABASE_SERVICE_ROLE_KEY

Supabase service_role key

ANBU_ADMIN_CODE

운영실/설정 화면 관리자 코드