결제 (토스페이먼츠) & 구독

ainote.kiam.kr 의 토스 결제 시스템 재활용

27
핵심: 시니어가 직접 결제하기 어려우므로 "가족이 대신 결제" 흐름을 메인으로.
"어머니께 실벗 프리미엄을 선물하세요" → 자녀 결제 → 어머니 계정에 자동 활성화.

결제 흐름 (3가지 시나리오)

🎁 시나리오 A: 자녀가 부모 선물

  1. 자녀 화면에서 "부모님 멤버십 결제"
  2. 플랜 선택 (월 9,900원 ~ 29,900원)
  3. 토스페이먼츠 결제창
  4. 결제 완료 → 부모 계정에 자동 활성화
  5. 부모님께 "딸이 선물했어요" 알림

👤 시나리오 B: 본인 결제

  1. 시니어가 "프리미엄 둘러보기"
  2. 큰 글씨로 혜택 설명 + 음성 안내
  3. "가족과 의논" 옵션 권장
  4. 본인 결제 시 6자리 PIN 재확인
  5. 토스 결제창

🏢 시나리오 C: 기관(B2B)

  1. 관리자가 "단체 가입" 신청
  2. 세금계산서 발행
  3. 월별 정산 (인원 × 단가)
  4. 토스 일반 결제 또는 무통장

♻ 정기결제 (Subscription)

  1. 토스 빌링키 발급 (카드 등록)
  2. 매월 동일 일자 자동 결제
  3. 실패 시 3일 재시도 → 정지
  4. 가족에게 결제 영수증 자동 발송

결제 페이지 UI (토스 SDK 연동)

<!-- /payment/checkout.html -->
<script src="https://js.tosspayments.com/v1/payment"></script>
<script>
const tossPayments = TossPayments('클라이언트키');

async function requestPayment(plan){
  const orderRes = await fetch('/api/v1/payment/create-order', {
    method:'POST', headers:authHeader(),
    body: JSON.stringify({plan})
  });
  const {orderId, amount, orderName} = await orderRes.json();
  
  tossPayments.requestPayment('카드', {
    amount,
    orderId,
    orderName,
    customerName: userName,
    successUrl: location.origin + '/payment/success.html',
    failUrl:    location.origin + '/payment/fail.html'
  });
}
</script>

서버 측 결제 승인 (PHP)

// /api/payment/confirm.php
$payload = json_decode(file_get_contents('php://input'), true);
$paymentKey = $payload['paymentKey'];
$orderId    = $payload['orderId'];
$amount     = $payload['amount'];

// 토스 API 호출
$ch = curl_init('https://api.tosspayments.com/v1/payments/confirm');
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    'Authorization: Basic '.base64_encode(TOSS_SECRET_KEY.':'),
    'Content-Type: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode([
    'paymentKey'=>$paymentKey,
    'orderId'=>$orderId,
    'amount'=>$amount
  ])
]);
$res = json_decode(curl_exec($ch), true);

if($res['status'] === 'DONE'){
  // DB 업데이트 → 구독 활성화
  activateSubscription($userId, $plan, $res);
  echo json_encode(['success'=>true]);
}

시니어 친화 결제 UX

환불 정책

14일 이내 무사용전액 환불
14일 이내 일부 사용일할 계산 환불
1개월 이후잔여일 환불 (자동결제 정지)
오결제고객센터 → 1영업일 처리