Skip to content

Simplify examples #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ npm i vue-stripe-js @stripe/stripe-js
```vue
<script setup lang="ts">
import { onBeforeMount, ref } from "vue"
import { loadStripe } from "@stripe/stripe-js"
import type { Stripe } from "@stripe/stripe-js"
import { loadStripe, type Stripe } from "@stripe/stripe-js"

const publishableKey = ref('')
const publishableKey = '' // use your publishable key
const stripe = ref<Stripe | null>(null)

onBeforeMount(async() => {
stripe.value = await loadStripe(publishableKey.value)
stripe.value = await loadStripe(publishableKey)
})
</script>
```
Expand Down Expand Up @@ -91,7 +90,7 @@ import type {
StripePaymentElementOptions,
} from "@stripe/stripe-js"

const stripeKey = ref("pk_test_f3duw0VsAEM2TJFMtWQ90QAT")
const stripeKey = "pk_test_f3duw0VsAEM2TJFMtWQ90QAT" // use your publishable key
const stripeOptions = ref({
// https://stripe.com/docs/js/initializing#init_stripe_js-options
})
Expand All @@ -115,7 +114,7 @@ const elementsComponent = ref()
const paymentComponent = ref()

onBeforeMount(() => {
loadStripe(stripeKey.value).then(() => {
loadStripe(stripeKey).then(() => {
stripeLoaded.value = true

// Good place to call your backend to create PaymentIntent
Expand Down
4 changes: 2 additions & 2 deletions examples/CardElement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { onBeforeMount, ref, useTemplateRef } from "vue"
import StripeElement from "../src/components/StripeElement.vue"
import StripeElements from "../src/components/StripeElements.vue"

const publishableKey = ref("pk_test_TYooMQauvdEDq54NiTphI7jx") // test key
const publishableKey = "pk_test_TYooMQauvdEDq54NiTphI7jx" // test key
const stripeOptions = ref<StripeConstructorOptions>({
// https://stripe.com/docs/js/initializing#init_stripe_js-options
})
Expand All @@ -56,7 +56,7 @@ const cardComponent = useTemplateRef("cardComponent")
const stripe = ref<Stripe | null>(null)

onBeforeMount(async () => {
stripe.value = await loadStripe(publishableKey.value)
stripe.value = await loadStripe(publishableKey)
stripeLoaded.value = true
})

Expand Down
4 changes: 2 additions & 2 deletions examples/CardElementLegacy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default defineComponent({
},

setup() {
const stripeKey = ref("pk_test_TYooMQauvdEDq54NiTphI7jx") // test key
const stripeKey = "pk_test_TYooMQauvdEDq54NiTphI7jx" // test key
const stripeOptions = ref({
// https://stripe.com/docs/js/initializing#init_stripe_js-options
})
Expand All @@ -56,7 +56,7 @@ export default defineComponent({
const elms = ref()

onBeforeMount(() => {
const stripePromise = loadStripe(stripeKey.value)
const stripePromise = loadStripe(stripeKey)
stripePromise.then(() => {
stripeLoaded.value = true
})
Expand Down
4 changes: 2 additions & 2 deletions examples/ExpressCheckoutElement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { onBeforeMount, ref, useTemplateRef } from "vue"
import StripeElement from "../src/components/StripeElement.vue"
import StripeElements from "../src/components/StripeElements.vue"

const publishableKey = ref("pk_test_f3duw0VsAEM2TJFMtWQ90QAT") // test key
const publishableKey = "pk_test_f3duw0VsAEM2TJFMtWQ90QAT" // test key
const stripeOptions = ref<StripeConstructorOptions>({
// https://stripe.com/docs/js/initializing#init_stripe_js-options
})
Expand All @@ -42,7 +42,7 @@ const expressCheckoutOptions = ref<StripeExpressCheckoutElementOptions>({
const stripeLoaded = ref(false)

onBeforeMount(() => {
loadStripe(publishableKey.value).then(() => {
loadStripe(publishableKey).then(() => {
stripeLoaded.value = true
})
})
Expand Down
4 changes: 2 additions & 2 deletions examples/PaymentElementDeferred.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { onBeforeMount, ref, useTemplateRef } from "vue"
import StripeElement from "../src/components/StripeElement.vue"
import StripeElements from "../src/components/StripeElements.vue"

const stripeKey = ref("pk_test_f3duw0VsAEM2TJFMtWQ90QAT")
const stripeKey = "pk_test_f3duw0VsAEM2TJFMtWQ90QAT"
const stripeOptions = ref({
// https://stripe.com/docs/js/initializing#init_stripe_js-options
})
Expand All @@ -61,7 +61,7 @@ const elementsComponent = useTemplateRef("elementsComponent")
const paymentComponent = useTemplateRef("paymentComponent")

onBeforeMount(() => {
loadStripe(stripeKey.value).then(() => {
loadStripe(stripeKey).then(() => {
stripeLoaded.value = true

// Good place to call your backend to create PaymentIntent
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-stripe-js",
"version": "2.0.1",
"version": "2.0.2",
"description": "Vue 3 components for Stripe.js",
"type": "module",
"main": "./dist/vue-stripe.js",
Expand All @@ -15,6 +15,7 @@
"dev": "vite",
"build": "vue-tsc -b && vite build",
"build:demo": "vite --config vite.demo.config.ts build",
"preview:demo": "vite --config vite.demo.config.ts preview",
"check:types": "publint && attw --pack . --ignore-rules=cjs-resolves-to-esm",
"ci": "biome check && pnpm run build && pnpm run check:types"
},
Expand All @@ -34,15 +35,15 @@
"@stripe/stripe-js": "^5.5.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.2",
"@arethetypeswrong/cli": "^0.17.3",
"@biomejs/biome": "1.9.4",
"@tailwindcss/vite": "4.0.0-beta.8",
"@tailwindcss/vite": "4.0.0",
"@vitejs/plugin-vue": "^5.2.1",
"@vue/tsconfig": "0.7.0",
"publint": "^0.3.0",
"tailwindcss": "4.0.0-beta.8",
"publint": "^0.3.2",
"tailwindcss": "4.0.0",
"typescript": "^5.7.3",
"vite": "^6.0.7",
"vite": "^6.0.11",
"vite-plugin-dts": "^4.5.0",
"vue": "^3.5.13",
"vue-tsc": "^2.2.0"
Expand Down
Loading
Loading