@vue-stripe/vue-stripe 4.4.4 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +174 -58
- package/dist/cjs/index.js +1 -0
- package/dist/es/index.js +896 -0
- package/dist/types/components/VueStripeAddressElement.vue.d.ts +105 -0
- package/dist/types/components/VueStripeAddressElement.vue.d.ts.map +1 -0
- package/dist/types/components/VueStripeCardCvcElement.vue.d.ts +24 -0
- package/dist/types/components/VueStripeCardCvcElement.vue.d.ts.map +1 -0
- package/dist/types/components/VueStripeCardElement.vue.d.ts +197 -0
- package/dist/types/components/VueStripeCardElement.vue.d.ts.map +1 -0
- package/dist/types/components/VueStripeCardExpiryElement.vue.d.ts +24 -0
- package/dist/types/components/VueStripeCardExpiryElement.vue.d.ts.map +1 -0
- package/dist/types/components/VueStripeCardNumberElement.vue.d.ts +24 -0
- package/dist/types/components/VueStripeCardNumberElement.vue.d.ts.map +1 -0
- package/dist/types/components/VueStripeCheckout.vue.d.ts +50 -0
- package/dist/types/components/VueStripeCheckout.vue.d.ts.map +1 -0
- package/dist/types/components/VueStripeElements.vue.d.ts +90 -0
- package/dist/types/components/VueStripeElements.vue.d.ts.map +1 -0
- package/dist/types/components/VueStripeExpressCheckoutElement.vue.d.ts +220 -0
- package/dist/types/components/VueStripeExpressCheckoutElement.vue.d.ts.map +1 -0
- package/dist/types/components/VueStripeLinkAuthenticationElement.vue.d.ts +167 -0
- package/dist/types/components/VueStripeLinkAuthenticationElement.vue.d.ts.map +1 -0
- package/dist/types/components/VueStripePaymentElement.vue.d.ts +206 -0
- package/dist/types/components/VueStripePaymentElement.vue.d.ts.map +1 -0
- package/dist/types/components/VueStripeProvider.vue.d.ts +42 -0
- package/dist/types/components/VueStripeProvider.vue.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +12 -0
- package/dist/types/components/index.d.ts.map +1 -0
- package/dist/types/composables/index.d.ts +6 -0
- package/dist/types/composables/index.d.ts.map +1 -0
- package/dist/types/composables/usePaymentIntent.d.ts +45 -0
- package/dist/types/composables/usePaymentIntent.d.ts.map +1 -0
- package/dist/types/composables/useSetupIntent.d.ts +62 -0
- package/dist/types/composables/useSetupIntent.d.ts.map +1 -0
- package/dist/types/composables/useStripe.d.ts +27 -0
- package/dist/types/composables/useStripe.d.ts.map +1 -0
- package/dist/types/composables/useStripeCheckout.d.ts +9 -0
- package/dist/types/composables/useStripeCheckout.d.ts.map +1 -0
- package/dist/types/composables/useStripeElements.d.ts +26 -0
- package/dist/types/composables/useStripeElements.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/plugin.d.ts +23 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/types/index.d.ts +171 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/constants.d.ts +11 -0
- package/dist/types/utils/constants.d.ts.map +1 -0
- package/dist/types/utils/element-factory.d.ts +28 -0
- package/dist/types/utils/element-factory.d.ts.map +1 -0
- package/dist/types/utils/errors.d.ts +11 -0
- package/dist/types/utils/errors.d.ts.map +1 -0
- package/dist/types/utils/injection-keys.d.ts +15 -0
- package/dist/types/utils/injection-keys.d.ts.map +1 -0
- package/dist/umd/index.js +1 -0
- package/dist/vue-stripe.css +1 -0
- package/package.json +67 -66
- package/CONTRIBUTING.md +0 -77
- package/LICENSE +0 -21
- package/babel.config.js +0 -22
- package/dist/index.js +0 -7
- package/dist/vue-stripe.js +0 -7
- package/rollup.config.js +0 -37
- package/typings/index.d.ts +0 -73
package/README.md
CHANGED
|
@@ -1,65 +1,181 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vue-stripe/vue-stripe
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@vue-stripe/vue-stripe)
|
|
4
|
+
[](https://bundlephobia.com/package/@vue-stripe/vue-stripe)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
Vue.js library for Stripe Checkout and Elements. Built for Vue 3.x with TypeScript-first development and a modern Composition API.
|
|
8
|
+
|
|
9
|
+
> This package is part of the [Vue Stripe monorepo](../../README.md). For contributing guidelines and development setup, see the root README.
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @vue-stripe/vue-stripe @stripe/stripe-js
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Basic Usage
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<template>
|
|
21
|
+
<VueStripeProvider :publishable-key="publishableKey">
|
|
22
|
+
<VueStripeElements>
|
|
23
|
+
<VueStripePaymentElement @ready="onReady" />
|
|
24
|
+
<button @click="processPayment">Pay Now</button>
|
|
25
|
+
</VueStripeElements>
|
|
26
|
+
</VueStripeProvider>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script setup lang="ts">
|
|
30
|
+
import {
|
|
31
|
+
VueStripeProvider,
|
|
32
|
+
VueStripeElements,
|
|
33
|
+
VueStripePaymentElement,
|
|
34
|
+
usePaymentIntent
|
|
35
|
+
} from '@vue-stripe/vue-stripe'
|
|
36
|
+
|
|
37
|
+
const publishableKey = 'pk_test_...'
|
|
38
|
+
const { confirmPayment } = usePaymentIntent()
|
|
39
|
+
|
|
40
|
+
const processPayment = async () => {
|
|
41
|
+
const result = await confirmPayment(clientSecret)
|
|
42
|
+
// Handle result
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Components
|
|
48
|
+
|
|
49
|
+
### Provider Components
|
|
50
|
+
|
|
51
|
+
| Component | Description |
|
|
52
|
+
|-----------|-------------|
|
|
53
|
+
| `VueStripeProvider` | Root component that loads Stripe.js and provides context |
|
|
54
|
+
| `VueStripeElements` | Creates an Elements instance and provides it to child components |
|
|
55
|
+
|
|
56
|
+
### Payment Components
|
|
57
|
+
|
|
58
|
+
| Component | Description |
|
|
59
|
+
|-----------|-------------|
|
|
60
|
+
| `VueStripePaymentElement` | Modern payment element supporting 40+ payment methods |
|
|
61
|
+
| `VueStripeExpressCheckoutElement` | Wallet payments (Apple Pay, Google Pay, etc.) |
|
|
62
|
+
| `VueStripeLinkAuthenticationElement` | Link authentication element |
|
|
63
|
+
| `VueStripeAddressElement` | Address collection with Google Maps autocomplete |
|
|
64
|
+
| `VueStripeCheckout` | Embedded Stripe Checkout |
|
|
65
|
+
|
|
66
|
+
### VueStripeAddressElement
|
|
67
|
+
|
|
68
|
+
Collect shipping or billing addresses with Google Maps autocomplete:
|
|
69
|
+
|
|
70
|
+
```vue
|
|
71
|
+
<template>
|
|
72
|
+
<VueStripeAddressElement
|
|
73
|
+
ref="addressRef"
|
|
74
|
+
:options="{ mode: 'shipping' }"
|
|
75
|
+
@change="onAddressChange"
|
|
76
|
+
/>
|
|
77
|
+
<button @click="validateAddress">Validate</button>
|
|
78
|
+
</template>
|
|
79
|
+
|
|
80
|
+
<script setup>
|
|
81
|
+
import { ref } from 'vue'
|
|
82
|
+
|
|
83
|
+
const addressRef = ref()
|
|
84
|
+
|
|
85
|
+
// Use getValue() to programmatically get address data
|
|
86
|
+
const validateAddress = async () => {
|
|
87
|
+
const result = await addressRef.value?.getValue()
|
|
88
|
+
if (result.complete) {
|
|
89
|
+
console.log('Valid address:', result.value)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
</script>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### VueStripeLinkAuthenticationElement
|
|
96
|
+
|
|
97
|
+
Enable Stripe Link for faster checkout by collecting and authenticating the customer's email.
|
|
98
|
+
|
|
99
|
+
> **Note:** This element collects email only and **must be paired with `VueStripePaymentElement`** for a complete checkout flow. It cannot process payments on its own.
|
|
100
|
+
|
|
101
|
+
```vue
|
|
102
|
+
<template>
|
|
103
|
+
<VueStripeProvider :publishable-key="publishableKey">
|
|
104
|
+
<VueStripeElements :client-secret="clientSecret">
|
|
105
|
+
<!-- Step 1: Email + Link authentication -->
|
|
106
|
+
<VueStripeLinkAuthenticationElement @change="onEmailChange" />
|
|
107
|
+
|
|
108
|
+
<!-- Step 2: Payment methods (auto-fills if Link authenticated) -->
|
|
109
|
+
<VueStripePaymentElement @change="onPaymentChange" />
|
|
110
|
+
|
|
111
|
+
<button :disabled="!canPay">Pay Now</button>
|
|
112
|
+
</VueStripeElements>
|
|
113
|
+
</VueStripeProvider>
|
|
114
|
+
</template>
|
|
115
|
+
|
|
116
|
+
<script setup>
|
|
117
|
+
import { ref, computed } from 'vue'
|
|
118
|
+
import {
|
|
119
|
+
VueStripeProvider,
|
|
120
|
+
VueStripeElements,
|
|
121
|
+
VueStripeLinkAuthenticationElement,
|
|
122
|
+
StripePaymentElement
|
|
123
|
+
} from '@vue-stripe/vue-stripe'
|
|
124
|
+
|
|
125
|
+
const emailComplete = ref(false)
|
|
126
|
+
const paymentComplete = ref(false)
|
|
127
|
+
const canPay = computed(() => emailComplete.value && paymentComplete.value)
|
|
128
|
+
|
|
129
|
+
const onEmailChange = (event) => {
|
|
130
|
+
emailComplete.value = event.complete
|
|
131
|
+
if (event.complete) {
|
|
132
|
+
console.log('Email:', event.value.email)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const onPaymentChange = (event) => {
|
|
137
|
+
paymentComplete.value = event.complete
|
|
138
|
+
}
|
|
139
|
+
</script>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Legacy Card Components
|
|
143
|
+
|
|
144
|
+
| Component | Description |
|
|
145
|
+
|-----------|-------------|
|
|
146
|
+
| `VueStripeCardElement` | Single card input field |
|
|
147
|
+
| `VueStripeCardNumberElement` | Card number input |
|
|
148
|
+
| `VueStripeCardExpiryElement` | Expiry date input |
|
|
149
|
+
| `VueStripeCardCvcElement` | CVC input |
|
|
150
|
+
|
|
151
|
+
## Composables
|
|
152
|
+
|
|
153
|
+
| Composable | Description |
|
|
154
|
+
|------------|-------------|
|
|
155
|
+
| `useStripe()` | Access Stripe instance |
|
|
156
|
+
| `useStripeElements()` | Access Elements instance |
|
|
157
|
+
| `usePaymentIntent()` | Payment confirmation helpers |
|
|
158
|
+
| `useSetupIntent()` | Setup intent handling |
|
|
159
|
+
| `useStripeCheckout()` | Checkout session management |
|
|
160
|
+
|
|
161
|
+
## TypeScript
|
|
162
|
+
|
|
163
|
+
Full TypeScript support with re-exported Stripe.js types:
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import type {
|
|
167
|
+
StripeElementChangeEvent,
|
|
168
|
+
PaymentIntent,
|
|
169
|
+
SetupIntent
|
|
170
|
+
} from '@vue-stripe/vue-stripe'
|
|
171
|
+
```
|
|
15
172
|
|
|
16
173
|
## Documentation
|
|
17
174
|
|
|
18
|
-
- [Website
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
- [Stripe Elements](https://docs.vuestripe.com/vue-stripe/stripe-elements)
|
|
22
|
-
- [Stripe Plugin](https://docs.vuestripe.com/vue-stripe/vue-stripe-plugin)
|
|
23
|
-
|
|
24
|
-
## Contributors
|
|
25
|
-
|
|
26
|
-
### Code Contributors
|
|
27
|
-
|
|
28
|
-
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
|
|
29
|
-
<a href="https://github.com/jofftiquez/vue-stripe-checkout/graphs/contributors"><img src="https://opencollective.com/vue-stripe-checkout/contributors.svg?width=890&button=false" /></a>
|
|
30
|
-
|
|
31
|
-
### Financial Contributors
|
|
32
|
-
|
|
33
|
-
Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/vue-stripe-checkout/contribute)]
|
|
34
|
-
|
|
35
|
-
#### Individuals
|
|
36
|
-
|
|
37
|
-
<a href="https://opencollective.com/vue-stripe-checkout"><img src="https://opencollective.com/vue-stripe-checkout/individuals.svg?width=890"></a>
|
|
38
|
-
|
|
39
|
-
#### Organizations
|
|
40
|
-
|
|
41
|
-
Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/vue-stripe-checkout/contribute)]
|
|
42
|
-
|
|
43
|
-
<a href="https://opencollective.com/vue-stripe-checkout/organization/0/website"><img src="https://opencollective.com/vue-stripe-checkout/organization/0/avatar.svg"></a>
|
|
44
|
-
<a href="https://opencollective.com/vue-stripe-checkout/organization/1/website"><img src="https://opencollective.com/vue-stripe-checkout/organization/1/avatar.svg"></a>
|
|
45
|
-
<a href="https://opencollective.com/vue-stripe-checkout/organization/2/website"><img src="https://opencollective.com/vue-stripe-checkout/organization/2/avatar.svg"></a>
|
|
46
|
-
<a href="https://opencollective.com/vue-stripe-checkout/organization/3/website"><img src="https://opencollective.com/vue-stripe-checkout/organization/3/avatar.svg"></a>
|
|
47
|
-
<a href="https://opencollective.com/vue-stripe-checkout/organization/4/website"><img src="https://opencollective.com/vue-stripe-checkout/organization/4/avatar.svg"></a>
|
|
48
|
-
<a href="https://opencollective.com/vue-stripe-checkout/organization/5/website"><img src="https://opencollective.com/vue-stripe-checkout/organization/5/avatar.svg"></a>
|
|
49
|
-
<a href="https://opencollective.com/vue-stripe-checkout/organization/6/website"><img src="https://opencollective.com/vue-stripe-checkout/organization/6/avatar.svg"></a>
|
|
50
|
-
<a href="https://opencollective.com/vue-stripe-checkout/organization/7/website"><img src="https://opencollective.com/vue-stripe-checkout/organization/7/avatar.svg"></a>
|
|
51
|
-
<a href="https://opencollective.com/vue-stripe-checkout/organization/8/website"><img src="https://opencollective.com/vue-stripe-checkout/organization/8/avatar.svg"></a>
|
|
52
|
-
<a href="https://opencollective.com/vue-stripe-checkout/organization/9/website"><img src="https://opencollective.com/vue-stripe-checkout/organization/9/avatar.svg"></a>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
**SPECIAL THANKS TO:**
|
|
56
|
-
|
|
57
|
-
[<img src="https://i.imgur.com/Ttv4fMw.png" width="200px">](https://mightyminds.org)
|
|
58
|
-
[<img src="https://i.imgur.com/x0SERyj.png" width="200px">](https://mycure.md)
|
|
59
|
-
[<img src="https://i.imgur.com/4jF5M4A.png">](http://myteamops.com)
|
|
60
|
-
|
|
61
|
-
**Vue Stripe is now powered by GitBook**
|
|
175
|
+
- [Website](https://vuestripe.com)
|
|
176
|
+
- [Guides](https://vuestripe.com/guide/introduction)
|
|
177
|
+
- [API Reference](https://vuestripe.com/api/)
|
|
62
178
|
|
|
63
|
-
|
|
179
|
+
## License
|
|
64
180
|
|
|
65
|
-
|
|
181
|
+
[MIT](LICENSE) License © 2017-2025 Vue Stripe Contributors
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("@stripe/stripe-js"),e=require("vue-demi"),g=Symbol("stripe"),h=Symbol("stripe-elements");class v extends Error{constructor(s){super(s),this.name="VueStripeProviderError"}}class f extends Error{constructor(s){super(s),this.name="VueStripeElementsError"}}class $ extends Error{constructor(s){super(s),this.name="VueStripeLoadError"}}function x(u,s){switch(u){case"provider":return new v(s);case"elements":return new f(s);case"load":return new $(s);default:return new Error(s)}}const I={name:"vue-stripe",version:"5.0.0",url:"https://vuestripe.com",partner_id:"pp_partner_IqtOXpBSuz0IE2"},N={key:0,class:"vue-stripe-error"},A={class:"vue-stripe-error-message"},T={key:1,class:"vue-stripe-loading"},R={key:2},j=e.defineComponent({__name:"VueStripeProvider",props:{publishableKey:{},stripeKey:{},stripeAccount:{},apiVersion:{},locale:{},options:{}},emits:["load","error"],setup(u,{emit:s}){const l=u,c=s,o=e.ref(null),a=e.ref(!0),r=e.ref(null),t=l.publishableKey||l.stripeKey;if(!t)throw new v("publishableKey or stripeKey is required");const i={publishableKey:t,stripeAccount:l.stripeAccount||l.options?.stripeAccount,apiVersion:l.apiVersion||l.options?.apiVersion,locale:l.locale||l.options?.locale},m=async()=>{try{a.value=!0,r.value=null;const d={},n=l.stripeAccount||l.options?.stripeAccount,p=l.apiVersion||l.options?.apiVersion,y=l.locale||l.options?.locale;if(n&&(d.stripeAccount=n),p&&(d.apiVersion=p),y&&(d.locale=y),o.value=await k.loadStripe(t,d),!o.value)throw new v("Failed to initialize Stripe");o.value.registerAppInfo(I),c("load",o.value)}catch(d){const n=d instanceof Error?d.message:"Failed to load Stripe";r.value=n,console.error("[Vue Stripe] Initialization error:",n),c("error",d instanceof Error?d:new Error(n))}finally{a.value=!1}};return e.onMounted(()=>{m()}),e.provide("vue-stripe-config",i),e.provide(g,{stripe:o,loading:a,error:r}),(d,n)=>e.unref(r)?(e.openBlock(),e.createElementBlock("div",N,[e.renderSlot(d.$slots,"error",{error:e.unref(r)},()=>[e.createElementVNode("div",A,e.toDisplayString(e.unref(r)),1)],!0)])):e.unref(a)?(e.openBlock(),e.createElementBlock("div",T,[e.renderSlot(d.$slots,"loading",{},()=>[n[0]||(n[0]=e.createElementVNode("div",{class:"vue-stripe-loading-message"}," Loading Stripe... ",-1))],!0)])):(e.openBlock(),e.createElementBlock("div",R,[e.renderSlot(d.$slots,"default",{},void 0,!0)]))}}),E=(u,s)=>{const l=u.__vccOpts||u;for(const[c,o]of s)l[c]=o;return l},z=E(j,[["__scopeId","data-v-ce126b08"]]),U={key:0,class:"vue-stripe-elements-error"},L={class:"vue-stripe-error-message"},F={key:1,class:"vue-stripe-elements-loading"},K={key:2},D=e.defineComponent({__name:"VueStripeElements",props:{clientSecret:{},mode:{},currency:{},amount:{},setupFutureUsage:{},captureMethod:{},paymentMethodTypes:{},options:{}},setup(u){const s=u,l=e.inject(g);if(!l)throw new v("VueStripeElements must be used within VueStripeProvider");const c=e.ref(null),o=e.ref(!0),a=e.ref(null),r=()=>{if(!l.stripe.value){a.value="Stripe instance not available",o.value=!1;return}try{a.value=null,o.value=!0;const t={...s.options};s.clientSecret&&(t.clientSecret=s.clientSecret),s.mode&&(t.mode=s.mode),s.currency&&(t.currency=s.currency),s.amount!==void 0&&(t.amount=s.amount),s.setupFutureUsage&&(t.setupFutureUsage=s.setupFutureUsage),s.captureMethod&&(t.captureMethod=s.captureMethod),s.paymentMethodTypes&&(t.paymentMethodTypes=s.paymentMethodTypes),c.value=l.stripe.value.elements(t),o.value=!1}catch(t){const i=t instanceof Error?t.message:"Failed to create elements";a.value=i,o.value=!1,console.error("[Vue Stripe] Elements creation error:",i)}};return e.watch(()=>l.stripe.value,t=>{t&&!c.value&&r()},{immediate:!0}),e.watch(()=>s.clientSecret,()=>{l.stripe.value&&r()}),e.watch(()=>[s.mode,s.currency,s.amount,s.setupFutureUsage],()=>{l.stripe.value&&r()}),e.onMounted(()=>{l.stripe.value&&!c.value&&r()}),e.provide(h,{elements:c,loading:o,error:a}),(t,i)=>e.unref(a)?(e.openBlock(),e.createElementBlock("div",U,[e.renderSlot(t.$slots,"error",{error:e.unref(a)},()=>[e.createElementVNode("div",L,e.toDisplayString(e.unref(a)),1)],!0)])):e.unref(o)?(e.openBlock(),e.createElementBlock("div",F,[e.renderSlot(t.$slots,"loading",{},()=>[i[0]||(i[0]=e.createElementVNode("div",{class:"vue-stripe-loading-message"}," Initializing Elements... ",-1))],!0)])):(e.openBlock(),e.createElementBlock("div",K,[e.renderSlot(t.$slots,"default",{},void 0,!0)]))}}),q=E(D,[["__scopeId","data-v-478abfa3"]]),O={class:"vue-stripe-payment-element"},J={key:0,class:"vue-stripe-payment-element-error"},W={class:"vue-stripe-error-message"},X={key:1,class:"vue-stripe-payment-element-loader"},G=e.defineComponent({__name:"VueStripePaymentElement",props:{options:{}},emits:["ready","change","focus","blur","escape","loaderstart","loaderstop"],setup(u,{expose:s,emit:l}){const c=u,o=l,a=e.ref(),r=e.ref(null),t=e.ref(!0),i=e.ref(null),m=e.inject(h);if(!m)throw new f("VueStripePaymentElement must be used within VueStripeElements");const d=()=>{if(!m.elements.value){i.value="Elements instance not available",t.value=!1;return}if(!a.value){i.value="Mount point not available",t.value=!1;return}try{i.value=null,t.value=!0,r.value=m.elements.value.create("payment",c.options),r.value.on("ready",()=>{t.value=!1,o("ready",r.value)}),r.value.on("change",p=>{o("change",p)}),r.value.on("focus",()=>{o("focus")}),r.value.on("blur",()=>{o("blur")}),r.value.on("escape",()=>{o("escape")});const n=r.value;n.on("loaderstart",()=>{o("loaderstart")}),n.on("loaderstop",()=>{o("loaderstop")}),r.value.mount(a.value)}catch(n){const p=n instanceof Error?n.message:"Failed to create payment element";i.value=p,t.value=!1,console.error("[Vue Stripe] Payment element creation error:",p)}};return e.watch(()=>c.options,n=>{r.value&&n&&r.value.update(n)},{deep:!0}),e.watch(()=>m.elements.value,n=>{n&&a.value&&!r.value&&d()},{immediate:!0}),e.onMounted(()=>{m.elements.value&&a.value&&!r.value&&d()}),e.onUnmounted(()=>{r.value&&r.value.destroy()}),s({element:r,loading:t,error:i}),(n,p)=>(e.openBlock(),e.createElementBlock("div",O,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",J,[e.renderSlot(n.$slots,"error",{error:e.unref(i)},()=>[e.createElementVNode("div",W,e.toDisplayString(e.unref(i)),1)],!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"elementRef",ref:a,class:e.normalizeClass(["vue-stripe-payment-element-mount",{"vue-stripe-payment-element-loading":e.unref(t)}])},null,2),e.unref(t)?(e.openBlock(),e.createElementBlock("div",X,[e.renderSlot(n.$slots,"loading",{},()=>[p[0]||(p[0]=e.createElementVNode("div",{class:"vue-stripe-loading-message"}," Loading payment form... ",-1))],!0)])):e.createCommentVNode("",!0)]))}}),H=E(G,[["__scopeId","data-v-2477e9df"]]),Q={class:"vue-stripe-express-checkout-element"},Y={key:0,class:"vue-stripe-express-checkout-element-error"},Z={class:"vue-stripe-error-message"},ee={key:1,class:"vue-stripe-express-checkout-element-loader"},te=e.defineComponent({__name:"VueStripeExpressCheckoutElement",props:{options:{}},emits:["ready","click","confirm","cancel","shippingaddresschange","shippingratechange"],setup(u,{expose:s,emit:l}){const c=u,o=l,a=e.ref(),r=e.ref(null),t=e.ref(!0),i=e.ref(null),m=e.inject(h);if(!m)throw new f("VueStripeExpressCheckoutElement must be used within VueStripeElements");const d=()=>{if(!m.elements.value){i.value="Elements instance not available",t.value=!1;return}if(!a.value){i.value="Mount point not available",t.value=!1;return}try{i.value=null,t.value=!0,r.value=m.elements.value.create("expressCheckout",c.options),r.value.on("ready",n=>{t.value=!1,o("ready",n)}),r.value.on("click",n=>{o("click",n)}),r.value.on("confirm",n=>{o("confirm",n)}),r.value.on("cancel",()=>{o("cancel")}),r.value.on("shippingaddresschange",n=>{o("shippingaddresschange",n)}),r.value.on("shippingratechange",n=>{o("shippingratechange",n)}),r.value.mount(a.value)}catch(n){const p=n instanceof Error?n.message:"Failed to create express checkout element";i.value=p,t.value=!1,console.error("[Vue Stripe] Express checkout element creation error:",p)}};return e.watch(()=>c.options,n=>{r.value&&n&&r.value.update(n)},{deep:!0}),e.watch(()=>m.elements.value,n=>{n&&a.value&&!r.value&&d()},{immediate:!0}),e.onMounted(()=>{m.elements.value&&a.value&&!r.value&&d()}),e.onUnmounted(()=>{r.value&&r.value.destroy()}),s({element:r,loading:t,error:i}),(n,p)=>(e.openBlock(),e.createElementBlock("div",Q,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",Y,[e.renderSlot(n.$slots,"error",{error:e.unref(i)},()=>[e.createElementVNode("div",Z,e.toDisplayString(e.unref(i)),1)],!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"elementRef",ref:a,class:e.normalizeClass(["vue-stripe-express-checkout-element-mount",{"vue-stripe-express-checkout-element-loading":e.unref(t)}])},null,2),e.unref(t)?(e.openBlock(),e.createElementBlock("div",ee,[e.renderSlot(n.$slots,"loading",{},()=>[p[0]||(p[0]=e.createElementVNode("div",{class:"vue-stripe-loading-message"}," Loading express checkout... ",-1))],!0)])):e.createCommentVNode("",!0)]))}}),re=E(te,[["__scopeId","data-v-20294cda"]]),ne={class:"vue-stripe-card-element"},oe={key:0,class:"vue-stripe-card-element-error"},ae={class:"vue-stripe-error-message"},se={key:1,class:"vue-stripe-card-element-loader"},le=e.defineComponent({__name:"VueStripeCardElement",props:{options:{}},emits:["ready","change","focus","blur","escape"],setup(u,{expose:s,emit:l}){const c=u,o=l,a=e.ref(),r=e.ref(null),t=e.ref(!0),i=e.ref(null),m=e.inject(h);if(!m)throw new f("VueStripeCardElement must be used within VueStripeElements");const d=()=>{if(!m.elements.value){i.value="Elements instance not available",t.value=!1;return}if(!a.value){i.value="Mount point not available",t.value=!1;return}try{i.value=null,t.value=!0,r.value=m.elements.value.create("card",c.options),r.value.on("ready",()=>{t.value=!1,o("ready",r.value)}),r.value.on("change",n=>{n.error?i.value=n.error.message:i.value=null,o("change",n)}),r.value.on("focus",()=>{o("focus")}),r.value.on("blur",()=>{o("blur")}),r.value.on("escape",()=>{o("escape")}),r.value.mount(a.value)}catch(n){const p=n instanceof Error?n.message:"Failed to create card element";i.value=p,t.value=!1,console.error("[Vue Stripe] Card element creation error:",p)}};return e.watch(()=>c.options,n=>{r.value&&n&&r.value.update(n)},{deep:!0}),e.watch(()=>m.elements.value,n=>{n&&a.value&&!r.value&&d()},{immediate:!0}),e.onMounted(()=>{m.elements.value&&a.value&&!r.value&&d()}),e.onUnmounted(()=>{r.value&&r.value.destroy()}),s({element:r,loading:t,error:i,focus:()=>r.value?.focus(),blur:()=>r.value?.blur(),clear:()=>r.value?.clear()}),(n,p)=>(e.openBlock(),e.createElementBlock("div",ne,[e.unref(i)?(e.openBlock(),e.createElementBlock("div",oe,[e.renderSlot(n.$slots,"error",{error:e.unref(i)},()=>[e.createElementVNode("div",ae,e.toDisplayString(e.unref(i)),1)],!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"elementRef",ref:a,class:e.normalizeClass(["vue-stripe-card-element-mount",{"vue-stripe-card-element-loading":e.unref(t)}])},null,2),e.unref(t)?(e.openBlock(),e.createElementBlock("div",se,[e.renderSlot(n.$slots,"loading",{},()=>[p[0]||(p[0]=e.createElementVNode("div",{class:"vue-stripe-loading-message"}," Loading card form... ",-1))],!0)])):e.createCommentVNode("",!0)]))}}),ue=E(le,[["__scopeId","data-v-a41a7ee5"]]);function V({elementType:u,componentName:s}){return e.defineComponent({name:s,props:{options:{type:Object,default:()=>({})}},emits:["ready","change","focus","blur","escape"],setup(l,{emit:c,expose:o}){const a=e.ref(),r=e.ref(null),t=e.ref(!0),i=e.ref(null),m=e.inject(h);if(!m)throw new f(`${s} must be used within VueStripeElements`);const d=()=>{if(!m.elements.value){i.value="Elements instance not available",t.value=!1;return}if(!a.value){i.value="Mount point not available",t.value=!1;return}try{i.value=null,t.value=!0;const n=m.elements.value.create(u,l.options);r.value=n,n.on("ready",()=>{t.value=!1,c("ready",r.value)}),n.on("change",p=>{const y=p;y.error?i.value=y.error.message:i.value=null,c("change",y)}),n.on("focus",()=>{c("focus")}),n.on("blur",()=>{c("blur")}),n.on("escape",()=>{c("escape")}),n.mount(a.value)}catch(n){const p=n instanceof Error?n.message:`Failed to create ${u} element`;i.value=p,t.value=!1,console.error(`[Vue Stripe] ${s} creation error:`,p)}};return e.watch(()=>l.options,n=>{r.value?.update&&n&&r.value.update(n)},{deep:!0}),e.watch(()=>m.elements.value,n=>{n&&a.value&&!r.value&&d()},{immediate:!0}),e.onMounted(()=>{m.elements.value&&a.value&&!r.value&&d()}),e.onUnmounted(()=>{r.value&&r.value.destroy()}),o({element:r,loading:t,error:i,focus:()=>{r.value?.focus?.()},blur:()=>{r.value?.blur?.()},clear:()=>{r.value?.clear?.()}}),()=>{const n=`vue-stripe-${u}-element`;return e.h("div",{class:n},[i.value&&e.h("div",{class:`${n}-error`},[e.h("div",{class:"vue-stripe-error-message"},i.value)]),e.h("div",{ref:a,class:{[`${n}-mount`]:!0,[`${n}-loading`]:t.value}}),t.value&&e.h("div",{class:`${n}-loader`},[e.h("div",{class:"vue-stripe-loading-message"},`Loading ${u}...`)])])}}})}const ie=V({elementType:"cardNumber",componentName:"VueStripeCardNumberElement"}),ce=V({elementType:"cardExpiry",componentName:"VueStripeCardExpiryElement"}),de=V({elementType:"cardCvc",componentName:"VueStripeCardCvcElement"}),me=e.defineComponent({__name:"VueStripeLinkAuthenticationElement",props:{options:{}},emits:["ready","change"],setup(u,{expose:s,emit:l}){const c=u,o=l,a=e.inject(h);if(!a)throw new f("VueStripeLinkAuthenticationElement must be used within VueStripeElements");const r=e.ref(),t=e.ref(null),i=()=>{if(!(!a.elements?.value||!r.value))try{t.value=a.elements?.value.create("linkAuthentication",c.options),t.value.mount(r.value),t.value.on("ready",()=>{t.value&&o("ready",t.value)}),t.value.on("change",d=>{o("change",d)})}catch(d){console.error("[Vue Stripe] Link authentication element creation error:",d)}},m=()=>{t.value&&(t.value.unmount(),t.value.destroy(),t.value=null)};return e.watch(()=>a.elements?.value,d=>{d&&r.value&&!t.value&&i()},{immediate:!0}),e.watch(()=>c.options,d=>{t.value&&d&&typeof t.value.update=="function"&&t.value.update(d)},{deep:!0}),e.onMounted(()=>{a.elements?.value&&r.value&&i()}),e.onUnmounted(()=>{m()}),s({element:t,focus:()=>t.value?.focus(),blur:()=>t.value?.blur(),clear:()=>t.value?.clear()}),(d,n)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"elementRef",ref:r,class:"vue-stripe-link-auth-element"},null,512))}}),pe=E(me,[["__scopeId","data-v-b79076eb"]]),ve=e.defineComponent({name:"VueStripeAddressElement",props:{options:{type:Object,default:()=>({mode:"shipping"})}},emits:["ready","change","blur","focus","escape","loadError"],setup(u,{emit:s,expose:l}){const c=e.ref(),o=e.ref(null),a=e.inject(h);if(!a)throw new f("VueStripeAddressElement must be used within VueStripeElements");const r=()=>{s("ready")},t=S=>{s("change",S)},i=()=>{s("blur")},m=()=>{s("focus")},d=()=>{s("escape")},n=S=>{s("loadError",S)},p=()=>{!a.elements.value||!c.value||(o.value=a.elements.value.create("address",u.options),o.value.mount(c.value),o.value.on("ready",r),o.value.on("change",t),o.value.on("blur",i),o.value.on("focus",m),o.value.on("escape",d),o.value.on("loaderror",n))},y=()=>{o.value&&o.value.update(u.options)},P=()=>{o.value&&(o.value.off("ready",r),o.value.off("change",t),o.value.off("blur",i),o.value.off("focus",m),o.value.off("escape",d),o.value.off("loaderror",n),o.value.destroy(),o.value=null)},b=async()=>{if(!o.value)throw new f("Address element not mounted");return o.value.getValue()},w=()=>{o.value?.focus()},C=()=>{o.value?.clear()};return e.onMounted(()=>{p()}),e.onBeforeUnmount(()=>{P()}),e.watch(()=>u.options,()=>{y()},{deep:!0}),l({element:o,getValue:b,focus:w,clear:C}),{addressRef:c,element:o,getValue:b,focus:w,clear:C}}}),fe={ref:"addressRef"};function he(u,s,l,c,o,a){return e.openBlock(),e.createElementBlock("div",fe,null,512)}const ye=E(ve,[["render",he]]);function _(){const u=e.inject(g);if(!u)throw new v("useStripe must be called within a VueStripeProvider component");return{stripe:e.readonly(u.stripe),loading:e.readonly(u.loading),error:e.readonly(u.error),initialize:async()=>{}}}const Ee=["disabled"],ge=e.defineComponent({__name:"VueStripeCheckout",props:{sessionId:{},priceId:{},mode:{default:"payment"},successUrl:{},cancelUrl:{},customerEmail:{},clientReferenceId:{},submitType:{},options:{},buttonText:{default:"Checkout"},loadingText:{default:"Redirecting..."},disabled:{type:Boolean,default:!1},buttonClass:{default:"vue-stripe-checkout-button"}},emits:["click","success","error"],setup(u,{emit:s}){const l=u,c=s,{stripe:o}=_(),a=e.ref(!1),r=async()=>{if(!o.value){const t=new v("Stripe not initialized");c("error",t);return}if(!l.sessionId&&!l.priceId){const t=new v("Either sessionId or priceId is required");c("error",t);return}try{a.value=!0,c("click");let t;if(l.sessionId?t=await o.value.redirectToCheckout({sessionId:l.sessionId,...l.options}):t=await o.value.redirectToCheckout({lineItems:[{price:l.priceId,quantity:1}],mode:l.mode,successUrl:l.successUrl||window.location.origin+"/success",cancelUrl:l.cancelUrl||window.location.origin+"/cancel",customerEmail:l.customerEmail,clientReferenceId:l.clientReferenceId,submitType:l.submitType}),t.error)throw new v(t.error.message||"Redirect to checkout failed");c("success")}catch(t){const i=t instanceof Error?t:new Error("Checkout failed");c("error",i),console.error("[Vue Stripe] Checkout error:",i)}finally{a.value=!1}};return(t,i)=>(e.openBlock(),e.createElementBlock("button",{disabled:e.unref(a)||u.disabled,class:e.normalizeClass(u.buttonClass),onClick:r},[e.unref(a)?e.renderSlot(t.$slots,"loading",{key:1},()=>[i[0]||(i[0]=e.createElementVNode("span",{class:"vue-stripe-loading-spinner"},null,-1)),e.createTextVNode(" "+e.toDisplayString(u.loadingText),1)],!0):e.renderSlot(t.$slots,"default",{key:0},()=>[e.createTextVNode(e.toDisplayString(u.buttonText),1)],!0)],10,Ee))}}),Se=E(ge,[["__scopeId","data-v-b439ab37"]]);function ke(){const u=e.inject(g),s=e.inject(h);if(!u)throw new v("usePaymentIntent must be called within a VueStripeProvider component");const l=e.ref(!1),c=e.ref(null);return{confirmPayment:async a=>{if(!u.stripe.value)return c.value="Stripe not initialized",{error:{message:"Stripe not initialized"}};l.value=!0,c.value=null;try{const r=a.elements??s?.elements.value;if(r&&!a.skipSubmit){const{error:i}=await r.submit();if(i)return c.value=i.message||"Form validation failed",{error:i}}const t=await u.stripe.value.confirmPayment({elements:r??void 0,clientSecret:a.clientSecret,confirmParams:a.confirmParams??{},redirect:a.redirect??"if_required"});return t.error&&(c.value=t.error.message||"Payment confirmation failed"),t}catch(r){const t=r instanceof Error?r.message:"Payment confirmation failed";return c.value=t,{error:{message:t}}}finally{l.value=!1}},loading:e.readonly(l),error:e.readonly(c)}}function Ve(){const u=e.inject(g),s=e.inject(h);if(!u)throw new v("useSetupIntent must be called within a VueStripeProvider component");const l=e.ref(!1),c=e.ref(null);return{confirmSetup:async a=>{if(!u.stripe.value)return c.value="Stripe not initialized",{error:{message:"Stripe not initialized"}};l.value=!0,c.value=null;try{const r=a.elements??s?.elements.value;if(r&&!a.skipSubmit){const{error:i}=await r.submit();if(i)return c.value=i.message||"Form validation failed",{error:i}}const t=await u.stripe.value.confirmSetup({elements:r??void 0,clientSecret:a.clientSecret,confirmParams:a.confirmParams??{},redirect:a.redirect??"if_required"});return t.error&&(c.value=t.error.message||"Setup confirmation failed"),t}catch(r){const t=r instanceof Error?r.message:"Setup confirmation failed";return c.value=t,{error:{message:t}}}finally{l.value=!1}},loading:e.readonly(l),error:e.readonly(c)}}function B(){const{stripe:u}=_(),s=e.ref(!1),l=e.ref(null);return{redirectToCheckout:async o=>{if(!u.value)throw new v("Stripe not initialized");try{s.value=!0,l.value=null;const a=await u.value.redirectToCheckout(o);if(a.error){const r=a.error.message||"Checkout redirect failed";throw l.value=r,new v(r)}}catch(a){const r=a instanceof Error?a.message:"Checkout redirect failed";throw l.value=r,a}finally{s.value=!1}},loading:e.readonly(s),error:e.readonly(l)}}function M(){const u=e.inject(h);if(!u)throw new f("Elements context not found. Make sure to wrap your component with VueStripeElements.");const s=async()=>u.elements.value?u.elements.value.submit():{error:{message:"Elements not initialized"}};return{elements:e.readonly(u.elements),submit:s,loading:e.readonly(u.loading),error:e.readonly(u.error)}}function _e(u){return{install(s){s.provide("vue-stripe-config",u);let l=null;s.provide("vue-stripe-global",{get stripe(){if(!l){const c={};u.stripeAccount&&(c.stripeAccount=u.stripeAccount),u.apiVersion&&(c.apiVersion=u.apiVersion),u.locale&&(c.locale=u.locale),l=k.loadStripe(u.publishableKey,c).then(o=>(o&&o.registerAppInfo(I),o))}return l}})}}}Object.defineProperty(exports,"loadStripe",{enumerable:!0,get:()=>k.loadStripe});exports.VueStripeAddressElement=ye;exports.VueStripeCardCvcElement=de;exports.VueStripeCardElement=ue;exports.VueStripeCardExpiryElement=ce;exports.VueStripeCardNumberElement=ie;exports.VueStripeCheckout=Se;exports.VueStripeElements=q;exports.VueStripeElementsError=f;exports.VueStripeExpressCheckoutElement=re;exports.VueStripeLinkAuthenticationElement=pe;exports.VueStripeLoadError=$;exports.VueStripePaymentElement=H;exports.VueStripeProvider=z;exports.VueStripeProviderError=v;exports.createVueStripe=_e;exports.createVueStripeError=x;exports.useCheckout=B;exports.useElements=M;exports.usePaymentIntent=ke;exports.useSetupIntent=Ve;exports.useStripe=_;exports.useStripeCheckout=B;exports.useStripeElements=M;
|