You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+90-39Lines changed: 90 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
10
10
Vue 3 components for Stripe. Build advanced payment integrations quickly. Easy to start, friendly DX, minimal abstractions, and full control. It's a glue between Stripe.js and Vue component lifecycle.
11
11
12
-
# Quickstart
12
+
##Quickstart ⚡️
13
13
14
14
### 1. Install
15
15
@@ -21,8 +21,8 @@ npm i vue-stripe-js @stripe/stripe-js
21
21
22
22
```vue
23
23
<script setup lang="ts">
24
-
import { loadStripe } from "@stripe/stripe-js"
25
24
import { onBeforeMount, ref } from "vue"
25
+
import { loadStripe } from "@stripe/stripe-js"
26
26
import type { Stripe } from "@stripe/stripe-js"
27
27
28
28
const publishableKey = ref('')
@@ -34,20 +34,23 @@ onBeforeMount(async() => {
34
34
</script>
35
35
```
36
36
37
-
Alternatively, include a script tag. Make sure Stripe.js is loaded before you mount vue components.
37
+
Alternatively, include a script tag. Make sure Stripe.js is loaded before you mount Vue components.
38
38
39
39
```html
40
40
<scriptsrc="https://js.stripe.com/v3/"></script>
41
41
```
42
42
43
43
### 3. Payment Element
44
44
45
-
This example is based on – [deferred payment guide](https://docs.stripe.com/payments/accept-a-payment-deferred?type=payment)
45
+
Based on – [deferred payment guide](https://docs.stripe.com/payments/accept-a-payment-deferred?type=payment)
46
+
46
47
```vue
47
48
<template>
48
-
<form @submit.prevent="handleSubmit">
49
+
<form
50
+
v-if="stripeLoaded"
51
+
@submit.prevent="handleSubmit"
52
+
>
49
53
<StripeElements
50
-
v-if="stripeLoaded"
51
54
:stripe-key="stripeKey"
52
55
:instance-options="stripeOptions"
53
56
:elements-options="elementsOptions"
@@ -68,10 +71,9 @@ This example is based on – [deferred payment guide](https://docs.stripe.com/pa
68
71
</template>
69
72
70
73
<script setup lang="ts">
71
-
import StripeElements from "vue-stripe-js"
72
-
import StripeElement from "vue-stripe-js"
73
-
import { loadStripe } from "@stripe/stripe-js"
74
74
import { onBeforeMount, ref, useTemplateRef } from "vue"
75
+
import { loadStripe } from "@stripe/stripe-js"
76
+
import { StripeElements, StripeElement } from "vue-stripe-js"
@@ -141,38 +143,65 @@ async function handleSubmit() {
141
143
142
144
```
143
145
144
-
### 4. Payment element (requires backend)
146
+
## Examples 🌿
147
+
148
+
Thanks to the Provider Pattern used in Stripe Elements, you get minimalist tools with full access to Stripe.js methods and properties. This results in better developer experience (DX), simpler code, and fewer bugs.
149
+
150
+
These examples use Vue Composition API and TypeScript.
All features of Stripe.js are available in two components. The benefits of Vue solution: element is created and destroyed automatically, options are reactive, event listeners are attached to StripeElement. Simple and future-proof.
0 commit comments