Merge branch 'dev'
Deploy / deploy (push) Failing after 13m43s

This commit is contained in:
ByungCheol
2026-06-28 15:13:01 +09:00
3 changed files with 187 additions and 3 deletions
+13
View File
@@ -0,0 +1,13 @@
import http from './http'
// 백엔드 /api/billing 엔드포인트와 매핑
export const billingApi = {
// 구독 상품 목록
products() {
return http.get('/billing/products')
},
// Google Play 구매 검증 → 멤버십 부여
verifyGoogle(payload) {
return http.post('/billing/google/verify', payload)
},
}
+26
View File
@@ -0,0 +1,26 @@
import { Capacitor } from '@capacitor/core'
// 인앱 결제(Google Play) 헬퍼.
// 결제는 Android 앱에서만 가능 — 웹/데스크톱(PC)은 앱 다운로드로 유도한다.
export const billing = {
// Capacitor 네이티브(안드로이드) 여부
isNative() {
return Capacitor.isNativePlatform()
},
/**
* 상품 구매 → 구매 토큰 반환.
* 스캐폴드(테스트): 실제 스토어 호출 없이 test- 토큰을 만들어 백엔드 검증 흐름을 태운다.
*
* TODO(실연동): Google Play Billing 플러그인(cordova-plugin-purchase 등)을 연결해
* 실제 구매 후 purchaseToken/orderId 를 받아 반환하도록 교체.
*/
async purchase(productId) {
const rand = (globalThis.crypto?.randomUUID?.() || `${Date.now()}-${Math.floor(Math.random() * 1e9)}`)
return {
productId,
purchaseToken: `test-${productId}-${rand}`,
orderId: `TEST-${rand}`,
}
},
}
+148 -3
View File
@@ -1,12 +1,59 @@
<script setup> <script setup>
import { computed } from 'vue' import { computed, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useAuthStore } from '@/stores/auth' import { useAuthStore } from '@/stores/auth'
import { billingApi } from '@/api/billingApi'
import { billing } from '@/native/billing'
const router = useRouter() const router = useRouter()
const auth = useAuthStore() const auth = useAuthStore()
const isPremium = computed(() => auth.isPremium) const isPremium = computed(() => auth.isPremium)
// 결제는 Android 앱에서만 — PC(웹/데스크톱)는 앱 다운로드로 유도
const isNative = billing.isNative()
const APP_DOWNLOAD_URL = 'https://app.sblog.kr' // TODO: 실제 앱(APK/Play 스토어) 다운로드 주소로 교체
const products = ref([])
const purchasing = ref('')
const message = ref('')
const error = ref('')
// 만료일 표시
const expiresAt = computed(() => auth.user?.planExpiresAt)
function fmtDate(s) {
if (!s) return ''
const d = new Date(s)
if (Number.isNaN(d.getTime())) return s
const p = (n) => String(n).padStart(2, '0')
return `${d.getFullYear()}.${p(d.getMonth() + 1)}.${p(d.getDate())}`
}
onMounted(async () => {
if (!isNative) return // PC 는 상품 목록 불필요
try {
products.value = await billingApi.products()
} catch {
products.value = []
}
})
async function buy(product) {
if (purchasing.value) return
purchasing.value = product.id
message.value = ''
error.value = ''
try {
const receipt = await billing.purchase(product.id)
await billingApi.verifyGoogle(receipt)
await auth.refreshProfile() // plan/만료일 갱신
message.value = '결제가 완료되어 프리미엄이 적용되었습니다. 감사합니다!'
} catch (e) {
error.value = e.response?.data?.message || '결제에 실패했습니다. 다시 시도해 주세요.'
} finally {
purchasing.value = ''
}
}
// 무료 / 유료 기능 비교 (docs/plan-membership-tiers.md 기준) // 무료 / 유료 기능 비교 (docs/plan-membership-tiers.md 기준)
const freeFeatures = [ const freeFeatures = [
'가계부 내역 기록 · 조회', '가계부 내역 기록 · 조회',
@@ -60,9 +107,42 @@ function goBack() {
</div> </div>
<div class="cta"> <div class="cta">
<p v-if="!isPremium" class="notice"> <!-- 이미 유료 회원 -->
결제 기능은 준비 중입니다. 먼저 사용해 보고 싶다면 관리자에게 문의해 주세요. <p v-if="isPremium" class="status-premium">
프리미엄 이용 <span v-if="expiresAt"> · {{ fmtDate(expiresAt) }}까지</span>
</p> </p>
<!-- 미가입 + Android : 상품 구매 -->
<template v-else-if="isNative">
<div class="products">
<button
v-for="p in products"
:key="p.id"
type="button"
class="buy-btn"
:disabled="!!purchasing"
@click="buy(p)"
>
<span class="buy-label">{{ p.label }}</span>
<span class="buy-price">{{ p.priceKrw.toLocaleString('ko-KR') }}<span class="buy-per"> / {{ p.months }}개월</span></span>
<span v-if="purchasing === p.id" class="buy-ing">처리 </span>
</button>
</div>
<p v-if="!products.length" class="notice">상품을 불러오지 못했습니다.</p>
</template>
<!-- 미가입 + PC(/데스크톱): 다운로드 유도 -->
<template v-else>
<p class="notice">
📱 구독 결제는 <b>모바일 </b>에서 진행됩니다.<br />
앱을 설치한 로그인하여 프리미엄을 구독해 주세요.
</p>
<a class="primary-link" :href="APP_DOWNLOAD_URL" target="_blank" rel="noopener"> 다운로드</a>
</template>
<p v-if="message" class="msg-ok">{{ message }}</p>
<p v-if="error" class="msg-err">{{ error }}</p>
<button type="button" class="ghost" @click="goBack">돌아가기</button> <button type="button" class="ghost" @click="goBack">돌아가기</button>
</div> </div>
</div> </div>
@@ -153,6 +233,71 @@ function goBack() {
color: var(--color-text); color: var(--color-text);
opacity: 0.85; opacity: 0.85;
margin-bottom: 0.9rem; margin-bottom: 0.9rem;
line-height: 1.6;
}
.status-premium {
font-size: 1rem;
font-weight: 700;
color: #b8860b;
margin-bottom: 1rem;
}
.products {
display: flex;
flex-direction: column;
gap: 0.6rem;
max-width: 360px;
margin: 0 auto 0.9rem;
}
.buy-btn {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.85rem 1.1rem;
border: 1px solid hsla(40, 90%, 50%, 0.8);
border-radius: 10px;
background: hsla(40, 90%, 55%, 0.08);
color: var(--color-text);
cursor: pointer;
font-size: 0.95rem;
}
.buy-btn:disabled {
opacity: 0.6;
cursor: default;
}
.buy-label {
font-weight: 700;
}
.buy-price {
margin-left: auto;
font-weight: 700;
color: #b8860b;
}
.buy-per {
font-weight: 400;
font-size: 0.82rem;
opacity: 0.7;
}
.buy-ing {
font-size: 0.82rem;
opacity: 0.7;
}
.primary-link {
display: inline-block;
padding: 0.6rem 1.6rem;
border-radius: 8px;
background: hsla(160, 100%, 37%, 1);
color: #fff;
font-weight: 700;
margin-bottom: 0.9rem;
}
.msg-ok {
color: hsla(160, 100%, 37%, 1);
font-weight: 600;
margin-bottom: 0.9rem;
}
.msg-err {
color: #c0392b;
margin-bottom: 0.9rem;
} }
.ghost { .ghost {
padding: 0.55rem 1.4rem; padding: 0.55rem 1.4rem;