Subscription 플러그인
📋 작성 예정
이 문서는 플러그인 구현 후 상세 내용이 추가됩니다.
구독/결제 관리 플러그인입니다.
개요
Subscription 플러그인은 SaaS 구독 결제 시스템을 제공합니다. 다양한 결제 게이트웨이와 연동하여 자동 결제, 플랜 관리, 인보이스 발행을 지원합니다.
| 항목 | 값 |
|---|---|
| 티어 | Business |
| 가격 | Subscription |
| 상태 | 📋 개발 예정 |
| Core 의존성 | >= 1.1.0 |
예정 기능
플랜 관리
- 무료/유료 플랜: Free, Starter, Pro, Enterprise
- 기능 제한: 플랜별 기능 접근 제어
- 사용량 제한: API 호출, 저장 공간 등
결제 게이트웨이
| 게이트웨이 | 지역 | 지원 예정 |
|---|---|---|
| Stripe | Global | ✅ |
| PayPal | Global | ✅ |
| Toss Payments | 한국 | ✅ |
| KG이니시스 | 한국 | 🔜 |
| 카카오페이 | 한국 | 🔜 |
구독 생명주기
생성 → 활성 → [갱신 성공 → 활성]
[갱신 실패 → 유예 → 취소/복구]
[취소 요청 → 기간 만료 → 비활성]
인보이스
- 자동 발행: 결제 완료 시 자동 생성
- PDF 다운로드: 인보이스 PDF 생성
- 이메일 발송: 인보이스 자동 발송
예상 데이터 모델
구독 플랜
// plg_sub_plans 테이블
Schema::create('plg_sub_plans', function (Blueprint $table) {
$table->id();
$table->string('slug')->unique();
$table->string('name');
$table->text('description')->nullable();
$table->decimal('price', 10, 2);
$table->string('billing_period'); // monthly, yearly
$table->json('features');
$table->json('limits');
$table->integer('sort_order')->default(0);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
구독
// plg_sub_subscriptions 테이블
Schema::create('plg_sub_subscriptions', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained();
$table->foreignId('plan_id')->constrained('plg_sub_plans');
$table->string('status'); // active, past_due, canceled, trialing
$table->timestamp('trial_ends_at')->nullable();
$table->timestamp('current_period_start');
$table->timestamp('current_period_end');
$table->timestamp('canceled_at')->nullable();
$table->timestamps();
});
예상 사용법
플랜 확인
// 현재 테넌트의 플랜
$plan = $tenant->subscription->plan;
// 기능 접근 확인
if ($tenant->canAccess('advanced_analytics')) {
// 고급 분석 기능 사용
}
// 사용량 확인
$usage = $tenant->getUsage('api_calls');
$limit = $tenant->getLimit('api_calls');
구독 관리
// 구독 생성
$subscription = $subscriptionService->create($tenant, $plan);
// 플랜 업그레이드
$subscriptionService->changePlan($subscription, $newPlan);
// 구독 취소
$subscriptionService->cancel($subscription, $immediately = false);
Middleware
// 플랜별 접근 제어
Route::middleware(['subscription:pro'])->group(function () {
Route::get('/analytics', AdvancedAnalyticsController::class);
});