REPO STORY / 레포 이야기
ectoflow/vue-stripe-js
Stripe 결제를 Vue 3 컴포넌트로 구성하는 라이브러리
01 / 뭐 하는 레포인가요?
어떤 일을
도와주나요?
Vue 3 프로젝트에서 Stripe의 결제 UI 요소(카드, 결제 버튼 등)를 컴포넌트로 추가하는 라이브러리입니다. npm으로 설치한 후 StripeElements와 StripeElement 컴포넌트로 결제 폼을 구성하고, Stripe의 confirmPayment 메서드를 호출하여 결제를 완료합니다. Stripe 계정의 publishable key가 필요합니다. ⚠️ 주의: 이 라이브러리는 현재 유지보수되지 않으며, npm 패키지도 더 이상 업데이트되지 않습니다.
- Vue 3 컴포넌트로 Stripe Elements 쉽게 통합
- 카드·결제·편의결제·IBAN·iDEAL 등 20개 이상의 결제 요소 타입 지원
- 반응형 옵션과 자동 생명주기 관리
02 / 내 상황에 맞을까?
이럴 때 써요,
선택 전에 확인해요.
이럴 때 써요
요약에 별도 활용 대상이 없어요. 위 설명과 GitHub 문서를 확인해 주세요.
이럴 땐 다시 확인해요
아래 준비 조건이 맞지 않으면 먼저 환경을 준비해 주세요.
- Vue 3
- Stripe 계정 및 publishable key
- @stripe/stripe-js (npm 의존성)
- 백엔드에서 PaymentIntent 생성 및 clientSecret 제공
깃밥 한국어 요약의 활용 예와 준비 조건을 옮겼어요.
03 / 시작하려면
첫 걸음,
차근차근.
준비할 것
- Vue 3
- Stripe 계정 및 publishable key
- @stripe/stripe-js (npm 의존성)
- 백엔드에서 PaymentIntent 생성 및 clientSecret 제공
- 필수 패키지 설치
npm i vue-stripe-js @stripe/stripe-js
- Vue 컴포넌트에서 Stripe 인스턴스 초기화
<script setup lang="ts">
import { onBeforeMount, ref } from "vue"
import { loadStripe, type Stripe } from "@stripe/stripe-js"
const publishableKey = '' // use your publishable key
const stripe = ref<Stripe | null>(null)
onBeforeMount(async() => {
stripe.value = await loadStripe(publishableKey)
})
</script>
- Payment Element 결제 폼 구성
<template>
<form
v-if="stripeLoaded"
@submit.prevent="handleSubmit"
>
<StripeElements
:stripe-key="stripeKey"
:instance-options="stripeOptions"
:elements-options="elementsOptions"
ref="elementsComponent"
>
<StripeElement
type="payment"
:options="paymentElementOptions"
ref="paymentComponent"
/>
</StripeElements>
<button type="submit">
Submit
</button>
</form>
</template>
<script setup lang="ts">
import { onBeforeMount, ref } from "vue"
import { loadStripe } from "@stripe/stripe-js"
import { StripeElements, StripeElement } from "vue-stripe-js"
import type {
StripeElementsOptionsMode,
StripePaymentElementOptions,
} from "@stripe/stripe-js"
const stripeKey = "pk_test_f3duw0VsAEM2TJFMtWQ90QAT" // use your publishable key
const stripeOptions = ref({})
const elementsOptions = ref<StripeElementsOptionsMode>({
mode: "payment",
amount: 1099,
currency: "usd",
appearance: {
theme: "flat",
},
})
const paymentElementOptions = ref<StripePaymentElementOptions>({})
const stripeLoaded = ref(false)
const clientSecret = ref("")
const elementsComponent = ref()
const paymentComponent = ref()
onBeforeMount(() => {
loadStripe(stripeKey).then(() => {
stripeLoaded.value = true
})
})
async function handleSubmit() {
const stripeInstance = elementsComponent.value?.instance
const elements = elementsComponent.value?.elements
if (stripeInstance) {
const { error } = await stripeInstance.confirmPayment({
elements,
clientSecret: clientSecret.value,
confirmParams: {
return_url: "https://example.com/order/123/complete",
},
})
if (error) {
console.log(error)
}
}
}
</script>
- (선택사항) Stripe.js를 script tag로 로드 - 단계 2 대신 HTML에 추가
<script src="https://js.stripe.com/v3/"></script>
명령은 기존 요약에 적힌 그대로예요. 실행하거나 설치 성공을 검증하지 않았어요. 공식 소요시간 미제시.
04 / 이웃 레포
어떤 레포와 연결될까요?
비교 연결망의 정적 스냅샷 · 관계 종류와 기록된 근거예요. 현재 공개된 레포만 표시해요.
vue-stripe/vue-stripe ↗
구체 GitHub 토픽 공유: stripe-elements,stripe-checkout
repos.topics 교집합 (stripe-elements,stripe-checkout)
연결망 스냅샷 원자료 ↗