@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.
Files changed (64) hide show
  1. package/README.md +174 -58
  2. package/dist/cjs/index.js +1 -0
  3. package/dist/es/index.js +896 -0
  4. package/dist/types/components/VueStripeAddressElement.vue.d.ts +105 -0
  5. package/dist/types/components/VueStripeAddressElement.vue.d.ts.map +1 -0
  6. package/dist/types/components/VueStripeCardCvcElement.vue.d.ts +24 -0
  7. package/dist/types/components/VueStripeCardCvcElement.vue.d.ts.map +1 -0
  8. package/dist/types/components/VueStripeCardElement.vue.d.ts +197 -0
  9. package/dist/types/components/VueStripeCardElement.vue.d.ts.map +1 -0
  10. package/dist/types/components/VueStripeCardExpiryElement.vue.d.ts +24 -0
  11. package/dist/types/components/VueStripeCardExpiryElement.vue.d.ts.map +1 -0
  12. package/dist/types/components/VueStripeCardNumberElement.vue.d.ts +24 -0
  13. package/dist/types/components/VueStripeCardNumberElement.vue.d.ts.map +1 -0
  14. package/dist/types/components/VueStripeCheckout.vue.d.ts +50 -0
  15. package/dist/types/components/VueStripeCheckout.vue.d.ts.map +1 -0
  16. package/dist/types/components/VueStripeElements.vue.d.ts +90 -0
  17. package/dist/types/components/VueStripeElements.vue.d.ts.map +1 -0
  18. package/dist/types/components/VueStripeExpressCheckoutElement.vue.d.ts +220 -0
  19. package/dist/types/components/VueStripeExpressCheckoutElement.vue.d.ts.map +1 -0
  20. package/dist/types/components/VueStripeLinkAuthenticationElement.vue.d.ts +167 -0
  21. package/dist/types/components/VueStripeLinkAuthenticationElement.vue.d.ts.map +1 -0
  22. package/dist/types/components/VueStripePaymentElement.vue.d.ts +206 -0
  23. package/dist/types/components/VueStripePaymentElement.vue.d.ts.map +1 -0
  24. package/dist/types/components/VueStripeProvider.vue.d.ts +42 -0
  25. package/dist/types/components/VueStripeProvider.vue.d.ts.map +1 -0
  26. package/dist/types/components/index.d.ts +12 -0
  27. package/dist/types/components/index.d.ts.map +1 -0
  28. package/dist/types/composables/index.d.ts +6 -0
  29. package/dist/types/composables/index.d.ts.map +1 -0
  30. package/dist/types/composables/usePaymentIntent.d.ts +45 -0
  31. package/dist/types/composables/usePaymentIntent.d.ts.map +1 -0
  32. package/dist/types/composables/useSetupIntent.d.ts +62 -0
  33. package/dist/types/composables/useSetupIntent.d.ts.map +1 -0
  34. package/dist/types/composables/useStripe.d.ts +27 -0
  35. package/dist/types/composables/useStripe.d.ts.map +1 -0
  36. package/dist/types/composables/useStripeCheckout.d.ts +9 -0
  37. package/dist/types/composables/useStripeCheckout.d.ts.map +1 -0
  38. package/dist/types/composables/useStripeElements.d.ts +26 -0
  39. package/dist/types/composables/useStripeElements.d.ts.map +1 -0
  40. package/dist/types/index.d.ts +7 -0
  41. package/dist/types/index.d.ts.map +1 -0
  42. package/dist/types/plugin.d.ts +23 -0
  43. package/dist/types/plugin.d.ts.map +1 -0
  44. package/dist/types/tsconfig.build.tsbuildinfo +1 -0
  45. package/dist/types/types/index.d.ts +171 -0
  46. package/dist/types/types/index.d.ts.map +1 -0
  47. package/dist/types/utils/constants.d.ts +11 -0
  48. package/dist/types/utils/constants.d.ts.map +1 -0
  49. package/dist/types/utils/element-factory.d.ts +28 -0
  50. package/dist/types/utils/element-factory.d.ts.map +1 -0
  51. package/dist/types/utils/errors.d.ts +11 -0
  52. package/dist/types/utils/errors.d.ts.map +1 -0
  53. package/dist/types/utils/injection-keys.d.ts +15 -0
  54. package/dist/types/utils/injection-keys.d.ts.map +1 -0
  55. package/dist/umd/index.js +1 -0
  56. package/dist/vue-stripe.css +1 -0
  57. package/package.json +67 -66
  58. package/CONTRIBUTING.md +0 -77
  59. package/LICENSE +0 -21
  60. package/babel.config.js +0 -22
  61. package/dist/index.js +0 -7
  62. package/dist/vue-stripe.js +0 -7
  63. package/rollup.config.js +0 -37
  64. package/typings/index.d.ts +0 -73
@@ -0,0 +1,896 @@
1
+ import { loadStripe as B } from "@stripe/stripe-js";
2
+ import { loadStripe as We } from "@stripe/stripe-js";
3
+ import { defineComponent as w, ref as d, onMounted as I, provide as z, createElementBlock as f, unref as v, openBlock as h, renderSlot as g, createElementVNode as y, toDisplayString as x, inject as S, watch as E, onUnmounted as A, createCommentVNode as M, normalizeClass as T, h as P, onBeforeUnmount as W, readonly as _, createTextVNode as q } from "vue-demi";
4
+ const R = Symbol("stripe"), V = Symbol("stripe-elements");
5
+ class b extends Error {
6
+ constructor(a) {
7
+ super(a), this.name = "VueStripeProviderError";
8
+ }
9
+ }
10
+ class k extends Error {
11
+ constructor(a) {
12
+ super(a), this.name = "VueStripeElementsError";
13
+ }
14
+ }
15
+ class X extends Error {
16
+ constructor(a) {
17
+ super(a), this.name = "VueStripeLoadError";
18
+ }
19
+ }
20
+ function Ie(l, a) {
21
+ switch (l) {
22
+ case "provider":
23
+ return new b(a);
24
+ case "elements":
25
+ return new k(a);
26
+ case "load":
27
+ return new X(a);
28
+ default:
29
+ return new Error(a);
30
+ }
31
+ }
32
+ const j = {
33
+ name: "vue-stripe",
34
+ version: "5.0.0",
35
+ url: "https://vuestripe.com",
36
+ partner_id: "pp_partner_IqtOXpBSuz0IE2"
37
+ }, G = {
38
+ key: 0,
39
+ class: "vue-stripe-error"
40
+ }, H = { class: "vue-stripe-error-message" }, J = {
41
+ key: 1,
42
+ class: "vue-stripe-loading"
43
+ }, Q = { key: 2 }, Y = /* @__PURE__ */ w({
44
+ __name: "VueStripeProvider",
45
+ props: {
46
+ publishableKey: {},
47
+ stripeKey: {},
48
+ stripeAccount: {},
49
+ apiVersion: {},
50
+ locale: {},
51
+ options: {}
52
+ },
53
+ emits: ["load", "error"],
54
+ setup(l, { emit: a }) {
55
+ const o = l, i = a, n = d(null), s = d(!0), t = d(null), e = o.publishableKey || o.stripeKey;
56
+ if (!e)
57
+ throw new b("publishableKey or stripeKey is required");
58
+ const u = {
59
+ publishableKey: e,
60
+ stripeAccount: o.stripeAccount || o.options?.stripeAccount,
61
+ apiVersion: o.apiVersion || o.options?.apiVersion,
62
+ locale: o.locale || o.options?.locale
63
+ }, p = async () => {
64
+ try {
65
+ s.value = !0, t.value = null;
66
+ const c = {}, r = o.stripeAccount || o.options?.stripeAccount, m = o.apiVersion || o.options?.apiVersion, $ = o.locale || o.options?.locale;
67
+ if (r && (c.stripeAccount = r), m && (c.apiVersion = m), $ && (c.locale = $), n.value = await B(e, c), !n.value)
68
+ throw new b("Failed to initialize Stripe");
69
+ n.value.registerAppInfo(j), i("load", n.value);
70
+ } catch (c) {
71
+ const r = c instanceof Error ? c.message : "Failed to load Stripe";
72
+ t.value = r, console.error("[Vue Stripe] Initialization error:", r), i("error", c instanceof Error ? c : new Error(r));
73
+ } finally {
74
+ s.value = !1;
75
+ }
76
+ };
77
+ return I(() => {
78
+ p();
79
+ }), z("vue-stripe-config", u), z(R, {
80
+ stripe: n,
81
+ loading: s,
82
+ error: t
83
+ }), (c, r) => v(t) ? (h(), f("div", G, [
84
+ g(c.$slots, "error", { error: v(t) }, () => [
85
+ y("div", H, x(v(t)), 1)
86
+ ], !0)
87
+ ])) : v(s) ? (h(), f("div", J, [
88
+ g(c.$slots, "loading", {}, () => [
89
+ r[0] || (r[0] = y("div", { class: "vue-stripe-loading-message" }, " Loading Stripe... ", -1))
90
+ ], !0)
91
+ ])) : (h(), f("div", Q, [
92
+ g(c.$slots, "default", {}, void 0, !0)
93
+ ]));
94
+ }
95
+ }), C = (l, a) => {
96
+ const o = l.__vccOpts || l;
97
+ for (const [i, n] of a)
98
+ o[i] = n;
99
+ return o;
100
+ }, Ce = /* @__PURE__ */ C(Y, [["__scopeId", "data-v-ce126b08"]]), Z = {
101
+ key: 0,
102
+ class: "vue-stripe-elements-error"
103
+ }, ee = { class: "vue-stripe-error-message" }, te = {
104
+ key: 1,
105
+ class: "vue-stripe-elements-loading"
106
+ }, re = { key: 2 }, ne = /* @__PURE__ */ w({
107
+ __name: "VueStripeElements",
108
+ props: {
109
+ clientSecret: {},
110
+ mode: {},
111
+ currency: {},
112
+ amount: {},
113
+ setupFutureUsage: {},
114
+ captureMethod: {},
115
+ paymentMethodTypes: {},
116
+ options: {}
117
+ },
118
+ setup(l) {
119
+ const a = l, o = S(R);
120
+ if (!o)
121
+ throw new b(
122
+ "VueStripeElements must be used within VueStripeProvider"
123
+ );
124
+ const i = d(null), n = d(!0), s = d(null), t = () => {
125
+ if (!o.stripe.value) {
126
+ s.value = "Stripe instance not available", n.value = !1;
127
+ return;
128
+ }
129
+ try {
130
+ s.value = null, n.value = !0;
131
+ const e = {
132
+ ...a.options
133
+ };
134
+ a.clientSecret && (e.clientSecret = a.clientSecret), a.mode && (e.mode = a.mode), a.currency && (e.currency = a.currency), a.amount !== void 0 && (e.amount = a.amount), a.setupFutureUsage && (e.setupFutureUsage = a.setupFutureUsage), a.captureMethod && (e.captureMethod = a.captureMethod), a.paymentMethodTypes && (e.paymentMethodTypes = a.paymentMethodTypes), i.value = o.stripe.value.elements(e), n.value = !1;
135
+ } catch (e) {
136
+ const u = e instanceof Error ? e.message : "Failed to create elements";
137
+ s.value = u, n.value = !1, console.error("[Vue Stripe] Elements creation error:", u);
138
+ }
139
+ };
140
+ return E(
141
+ () => o.stripe.value,
142
+ (e) => {
143
+ e && !i.value && t();
144
+ },
145
+ { immediate: !0 }
146
+ ), E(
147
+ () => a.clientSecret,
148
+ () => {
149
+ o.stripe.value && t();
150
+ }
151
+ ), E(
152
+ () => [a.mode, a.currency, a.amount, a.setupFutureUsage],
153
+ () => {
154
+ o.stripe.value && t();
155
+ }
156
+ ), I(() => {
157
+ o.stripe.value && !i.value && t();
158
+ }), z(V, {
159
+ elements: i,
160
+ loading: n,
161
+ error: s
162
+ }), (e, u) => v(s) ? (h(), f("div", Z, [
163
+ g(e.$slots, "error", { error: v(s) }, () => [
164
+ y("div", ee, x(v(s)), 1)
165
+ ], !0)
166
+ ])) : v(n) ? (h(), f("div", te, [
167
+ g(e.$slots, "loading", {}, () => [
168
+ u[0] || (u[0] = y("div", { class: "vue-stripe-loading-message" }, " Initializing Elements... ", -1))
169
+ ], !0)
170
+ ])) : (h(), f("div", re, [
171
+ g(e.$slots, "default", {}, void 0, !0)
172
+ ]));
173
+ }
174
+ }), xe = /* @__PURE__ */ C(ne, [["__scopeId", "data-v-478abfa3"]]), se = { class: "vue-stripe-payment-element" }, ae = {
175
+ key: 0,
176
+ class: "vue-stripe-payment-element-error"
177
+ }, oe = { class: "vue-stripe-error-message" }, le = {
178
+ key: 1,
179
+ class: "vue-stripe-payment-element-loader"
180
+ }, ue = /* @__PURE__ */ w({
181
+ __name: "VueStripePaymentElement",
182
+ props: {
183
+ options: {}
184
+ },
185
+ emits: ["ready", "change", "focus", "blur", "escape", "loaderstart", "loaderstop"],
186
+ setup(l, { expose: a, emit: o }) {
187
+ const i = l, n = o, s = d(), t = d(null), e = d(!0), u = d(null), p = S(V);
188
+ if (!p)
189
+ throw new k(
190
+ "VueStripePaymentElement must be used within VueStripeElements"
191
+ );
192
+ const c = () => {
193
+ if (!p.elements.value) {
194
+ u.value = "Elements instance not available", e.value = !1;
195
+ return;
196
+ }
197
+ if (!s.value) {
198
+ u.value = "Mount point not available", e.value = !1;
199
+ return;
200
+ }
201
+ try {
202
+ u.value = null, e.value = !0, t.value = p.elements.value.create("payment", i.options), t.value.on("ready", () => {
203
+ e.value = !1, n("ready", t.value);
204
+ }), t.value.on("change", (m) => {
205
+ n("change", m);
206
+ }), t.value.on("focus", () => {
207
+ n("focus");
208
+ }), t.value.on("blur", () => {
209
+ n("blur");
210
+ }), t.value.on("escape", () => {
211
+ n("escape");
212
+ });
213
+ const r = t.value;
214
+ r.on("loaderstart", () => {
215
+ n("loaderstart");
216
+ }), r.on("loaderstop", () => {
217
+ n("loaderstop");
218
+ }), t.value.mount(s.value);
219
+ } catch (r) {
220
+ const m = r instanceof Error ? r.message : "Failed to create payment element";
221
+ u.value = m, e.value = !1, console.error("[Vue Stripe] Payment element creation error:", m);
222
+ }
223
+ };
224
+ return E(
225
+ () => i.options,
226
+ (r) => {
227
+ t.value && r && t.value.update(r);
228
+ },
229
+ { deep: !0 }
230
+ ), E(
231
+ () => p.elements.value,
232
+ (r) => {
233
+ r && s.value && !t.value && c();
234
+ },
235
+ { immediate: !0 }
236
+ ), I(() => {
237
+ p.elements.value && s.value && !t.value && c();
238
+ }), A(() => {
239
+ t.value && t.value.destroy();
240
+ }), a({
241
+ element: t,
242
+ loading: e,
243
+ error: u
244
+ }), (r, m) => (h(), f("div", se, [
245
+ v(u) ? (h(), f("div", ae, [
246
+ g(r.$slots, "error", { error: v(u) }, () => [
247
+ y("div", oe, x(v(u)), 1)
248
+ ], !0)
249
+ ])) : M("", !0),
250
+ y("div", {
251
+ ref_key: "elementRef",
252
+ ref: s,
253
+ class: T(["vue-stripe-payment-element-mount", { "vue-stripe-payment-element-loading": v(e) }])
254
+ }, null, 2),
255
+ v(e) ? (h(), f("div", le, [
256
+ g(r.$slots, "loading", {}, () => [
257
+ m[0] || (m[0] = y("div", { class: "vue-stripe-loading-message" }, " Loading payment form... ", -1))
258
+ ], !0)
259
+ ])) : M("", !0)
260
+ ]));
261
+ }
262
+ }), Pe = /* @__PURE__ */ C(ue, [["__scopeId", "data-v-2477e9df"]]), ie = { class: "vue-stripe-express-checkout-element" }, ce = {
263
+ key: 0,
264
+ class: "vue-stripe-express-checkout-element-error"
265
+ }, de = { class: "vue-stripe-error-message" }, pe = {
266
+ key: 1,
267
+ class: "vue-stripe-express-checkout-element-loader"
268
+ }, me = /* @__PURE__ */ w({
269
+ __name: "VueStripeExpressCheckoutElement",
270
+ props: {
271
+ options: {}
272
+ },
273
+ emits: ["ready", "click", "confirm", "cancel", "shippingaddresschange", "shippingratechange"],
274
+ setup(l, { expose: a, emit: o }) {
275
+ const i = l, n = o, s = d(), t = d(null), e = d(!0), u = d(null), p = S(V);
276
+ if (!p)
277
+ throw new k(
278
+ "VueStripeExpressCheckoutElement must be used within VueStripeElements"
279
+ );
280
+ const c = () => {
281
+ if (!p.elements.value) {
282
+ u.value = "Elements instance not available", e.value = !1;
283
+ return;
284
+ }
285
+ if (!s.value) {
286
+ u.value = "Mount point not available", e.value = !1;
287
+ return;
288
+ }
289
+ try {
290
+ u.value = null, e.value = !0, t.value = p.elements.value.create("expressCheckout", i.options), t.value.on("ready", (r) => {
291
+ e.value = !1, n("ready", r);
292
+ }), t.value.on("click", (r) => {
293
+ n("click", r);
294
+ }), t.value.on("confirm", (r) => {
295
+ n("confirm", r);
296
+ }), t.value.on("cancel", () => {
297
+ n("cancel");
298
+ }), t.value.on("shippingaddresschange", (r) => {
299
+ n("shippingaddresschange", r);
300
+ }), t.value.on("shippingratechange", (r) => {
301
+ n("shippingratechange", r);
302
+ }), t.value.mount(s.value);
303
+ } catch (r) {
304
+ const m = r instanceof Error ? r.message : "Failed to create express checkout element";
305
+ u.value = m, e.value = !1, console.error("[Vue Stripe] Express checkout element creation error:", m);
306
+ }
307
+ };
308
+ return E(
309
+ () => i.options,
310
+ (r) => {
311
+ t.value && r && t.value.update(r);
312
+ },
313
+ { deep: !0 }
314
+ ), E(
315
+ () => p.elements.value,
316
+ (r) => {
317
+ r && s.value && !t.value && c();
318
+ },
319
+ { immediate: !0 }
320
+ ), I(() => {
321
+ p.elements.value && s.value && !t.value && c();
322
+ }), A(() => {
323
+ t.value && t.value.destroy();
324
+ }), a({
325
+ element: t,
326
+ loading: e,
327
+ error: u
328
+ }), (r, m) => (h(), f("div", ie, [
329
+ v(u) ? (h(), f("div", ce, [
330
+ g(r.$slots, "error", { error: v(u) }, () => [
331
+ y("div", de, x(v(u)), 1)
332
+ ], !0)
333
+ ])) : M("", !0),
334
+ y("div", {
335
+ ref_key: "elementRef",
336
+ ref: s,
337
+ class: T(["vue-stripe-express-checkout-element-mount", { "vue-stripe-express-checkout-element-loading": v(e) }])
338
+ }, null, 2),
339
+ v(e) ? (h(), f("div", pe, [
340
+ g(r.$slots, "loading", {}, () => [
341
+ m[0] || (m[0] = y("div", { class: "vue-stripe-loading-message" }, " Loading express checkout... ", -1))
342
+ ], !0)
343
+ ])) : M("", !0)
344
+ ]));
345
+ }
346
+ }), Me = /* @__PURE__ */ C(me, [["__scopeId", "data-v-20294cda"]]), ve = { class: "vue-stripe-card-element" }, fe = {
347
+ key: 0,
348
+ class: "vue-stripe-card-element-error"
349
+ }, he = { class: "vue-stripe-error-message" }, ge = {
350
+ key: 1,
351
+ class: "vue-stripe-card-element-loader"
352
+ }, ye = /* @__PURE__ */ w({
353
+ __name: "VueStripeCardElement",
354
+ props: {
355
+ options: {}
356
+ },
357
+ emits: ["ready", "change", "focus", "blur", "escape"],
358
+ setup(l, { expose: a, emit: o }) {
359
+ const i = l, n = o, s = d(), t = d(null), e = d(!0), u = d(null), p = S(V);
360
+ if (!p)
361
+ throw new k(
362
+ "VueStripeCardElement must be used within VueStripeElements"
363
+ );
364
+ const c = () => {
365
+ if (!p.elements.value) {
366
+ u.value = "Elements instance not available", e.value = !1;
367
+ return;
368
+ }
369
+ if (!s.value) {
370
+ u.value = "Mount point not available", e.value = !1;
371
+ return;
372
+ }
373
+ try {
374
+ u.value = null, e.value = !0, t.value = p.elements.value.create("card", i.options), t.value.on("ready", () => {
375
+ e.value = !1, n("ready", t.value);
376
+ }), t.value.on("change", (r) => {
377
+ r.error ? u.value = r.error.message : u.value = null, n("change", r);
378
+ }), t.value.on("focus", () => {
379
+ n("focus");
380
+ }), t.value.on("blur", () => {
381
+ n("blur");
382
+ }), t.value.on("escape", () => {
383
+ n("escape");
384
+ }), t.value.mount(s.value);
385
+ } catch (r) {
386
+ const m = r instanceof Error ? r.message : "Failed to create card element";
387
+ u.value = m, e.value = !1, console.error("[Vue Stripe] Card element creation error:", m);
388
+ }
389
+ };
390
+ return E(
391
+ () => i.options,
392
+ (r) => {
393
+ t.value && r && t.value.update(r);
394
+ },
395
+ { deep: !0 }
396
+ ), E(
397
+ () => p.elements.value,
398
+ (r) => {
399
+ r && s.value && !t.value && c();
400
+ },
401
+ { immediate: !0 }
402
+ ), I(() => {
403
+ p.elements.value && s.value && !t.value && c();
404
+ }), A(() => {
405
+ t.value && t.value.destroy();
406
+ }), a({
407
+ element: t,
408
+ loading: e,
409
+ error: u,
410
+ focus: () => t.value?.focus(),
411
+ blur: () => t.value?.blur(),
412
+ clear: () => t.value?.clear()
413
+ }), (r, m) => (h(), f("div", ve, [
414
+ v(u) ? (h(), f("div", fe, [
415
+ g(r.$slots, "error", { error: v(u) }, () => [
416
+ y("div", he, x(v(u)), 1)
417
+ ], !0)
418
+ ])) : M("", !0),
419
+ y("div", {
420
+ ref_key: "elementRef",
421
+ ref: s,
422
+ class: T(["vue-stripe-card-element-mount", { "vue-stripe-card-element-loading": v(e) }])
423
+ }, null, 2),
424
+ v(e) ? (h(), f("div", ge, [
425
+ g(r.$slots, "loading", {}, () => [
426
+ m[0] || (m[0] = y("div", { class: "vue-stripe-loading-message" }, " Loading card form... ", -1))
427
+ ], !0)
428
+ ])) : M("", !0)
429
+ ]));
430
+ }
431
+ }), Ae = /* @__PURE__ */ C(ye, [["__scopeId", "data-v-a41a7ee5"]]);
432
+ function L({ elementType: l, componentName: a }) {
433
+ return w({
434
+ name: a,
435
+ props: {
436
+ options: {
437
+ type: Object,
438
+ default: () => ({})
439
+ }
440
+ },
441
+ emits: ["ready", "change", "focus", "blur", "escape"],
442
+ setup(o, { emit: i, expose: n }) {
443
+ const s = d(), t = d(null), e = d(!0), u = d(null), p = S(V);
444
+ if (!p)
445
+ throw new k(
446
+ `${a} must be used within VueStripeElements`
447
+ );
448
+ const c = () => {
449
+ if (!p.elements.value) {
450
+ u.value = "Elements instance not available", e.value = !1;
451
+ return;
452
+ }
453
+ if (!s.value) {
454
+ u.value = "Mount point not available", e.value = !1;
455
+ return;
456
+ }
457
+ try {
458
+ u.value = null, e.value = !0;
459
+ const r = p.elements.value.create(l, o.options);
460
+ t.value = r, r.on("ready", () => {
461
+ e.value = !1, i("ready", t.value);
462
+ }), r.on("change", (m) => {
463
+ const $ = m;
464
+ $.error ? u.value = $.error.message : u.value = null, i("change", $);
465
+ }), r.on("focus", () => {
466
+ i("focus");
467
+ }), r.on("blur", () => {
468
+ i("blur");
469
+ }), r.on("escape", () => {
470
+ i("escape");
471
+ }), r.mount(s.value);
472
+ } catch (r) {
473
+ const m = r instanceof Error ? r.message : `Failed to create ${l} element`;
474
+ u.value = m, e.value = !1, console.error(`[Vue Stripe] ${a} creation error:`, m);
475
+ }
476
+ };
477
+ return E(
478
+ () => o.options,
479
+ (r) => {
480
+ t.value?.update && r && t.value.update(r);
481
+ },
482
+ { deep: !0 }
483
+ ), E(
484
+ () => p.elements.value,
485
+ (r) => {
486
+ r && s.value && !t.value && c();
487
+ },
488
+ { immediate: !0 }
489
+ ), I(() => {
490
+ p.elements.value && s.value && !t.value && c();
491
+ }), A(() => {
492
+ t.value && t.value.destroy();
493
+ }), n({
494
+ element: t,
495
+ loading: e,
496
+ error: u,
497
+ focus: () => {
498
+ t.value?.focus?.();
499
+ },
500
+ blur: () => {
501
+ t.value?.blur?.();
502
+ },
503
+ clear: () => {
504
+ t.value?.clear?.();
505
+ }
506
+ }), () => {
507
+ const r = `vue-stripe-${l}-element`;
508
+ return P("div", { class: r }, [
509
+ u.value && P("div", { class: `${r}-error` }, [
510
+ P("div", { class: "vue-stripe-error-message" }, u.value)
511
+ ]),
512
+ P("div", {
513
+ ref: s,
514
+ class: {
515
+ [`${r}-mount`]: !0,
516
+ [`${r}-loading`]: e.value
517
+ }
518
+ }),
519
+ e.value && P("div", { class: `${r}-loader` }, [
520
+ P("div", { class: "vue-stripe-loading-message" }, `Loading ${l}...`)
521
+ ])
522
+ ]);
523
+ };
524
+ }
525
+ });
526
+ }
527
+ const Re = L({
528
+ elementType: "cardNumber",
529
+ componentName: "VueStripeCardNumberElement"
530
+ }), Te = L({
531
+ elementType: "cardExpiry",
532
+ componentName: "VueStripeCardExpiryElement"
533
+ }), Fe = L({
534
+ elementType: "cardCvc",
535
+ componentName: "VueStripeCardCvcElement"
536
+ }), Ee = /* @__PURE__ */ w({
537
+ __name: "VueStripeLinkAuthenticationElement",
538
+ props: {
539
+ options: {}
540
+ },
541
+ emits: ["ready", "change"],
542
+ setup(l, { expose: a, emit: o }) {
543
+ const i = l, n = o, s = S(V);
544
+ if (!s)
545
+ throw new k(
546
+ "VueStripeLinkAuthenticationElement must be used within VueStripeElements"
547
+ );
548
+ const t = d(), e = d(null), u = () => {
549
+ if (!(!s.elements?.value || !t.value))
550
+ try {
551
+ e.value = s.elements?.value.create("linkAuthentication", i.options), e.value.mount(t.value), e.value.on("ready", () => {
552
+ e.value && n("ready", e.value);
553
+ }), e.value.on("change", (c) => {
554
+ n("change", c);
555
+ });
556
+ } catch (c) {
557
+ console.error("[Vue Stripe] Link authentication element creation error:", c);
558
+ }
559
+ }, p = () => {
560
+ e.value && (e.value.unmount(), e.value.destroy(), e.value = null);
561
+ };
562
+ return E(
563
+ () => s.elements?.value,
564
+ (c) => {
565
+ c && t.value && !e.value && u();
566
+ },
567
+ { immediate: !0 }
568
+ ), E(
569
+ () => i.options,
570
+ (c) => {
571
+ e.value && c && typeof e.value.update == "function" && e.value.update(c);
572
+ },
573
+ { deep: !0 }
574
+ ), I(() => {
575
+ s.elements?.value && t.value && u();
576
+ }), A(() => {
577
+ p();
578
+ }), a({
579
+ element: e,
580
+ focus: () => e.value?.focus(),
581
+ blur: () => e.value?.blur(),
582
+ clear: () => e.value?.clear()
583
+ }), (c, r) => (h(), f("div", {
584
+ ref_key: "elementRef",
585
+ ref: t,
586
+ class: "vue-stripe-link-auth-element"
587
+ }, null, 512));
588
+ }
589
+ }), ze = /* @__PURE__ */ C(Ee, [["__scopeId", "data-v-b79076eb"]]), Se = w({
590
+ name: "VueStripeAddressElement",
591
+ props: {
592
+ options: {
593
+ type: Object,
594
+ default: () => ({
595
+ mode: "shipping"
596
+ })
597
+ }
598
+ },
599
+ emits: ["ready", "change", "blur", "focus", "escape", "loadError"],
600
+ setup(l, { emit: a, expose: o }) {
601
+ const i = d(), n = d(null), s = S(V);
602
+ if (!s)
603
+ throw new k("VueStripeAddressElement must be used within VueStripeElements");
604
+ const t = () => {
605
+ a("ready");
606
+ }, e = (F) => {
607
+ a("change", F);
608
+ }, u = () => {
609
+ a("blur");
610
+ }, p = () => {
611
+ a("focus");
612
+ }, c = () => {
613
+ a("escape");
614
+ }, r = (F) => {
615
+ a("loadError", F);
616
+ }, m = () => {
617
+ !s.elements.value || !i.value || (n.value = s.elements.value.create("address", l.options), n.value.mount(i.value), n.value.on("ready", t), n.value.on("change", e), n.value.on("blur", u), n.value.on("focus", p), n.value.on("escape", c), n.value.on("loaderror", r));
618
+ }, $ = () => {
619
+ n.value && n.value.update(l.options);
620
+ }, O = () => {
621
+ n.value && (n.value.off("ready", t), n.value.off("change", e), n.value.off("blur", u), n.value.off("focus", p), n.value.off("escape", c), n.value.off("loaderror", r), n.value.destroy(), n.value = null);
622
+ }, U = async () => {
623
+ if (!n.value)
624
+ throw new k("Address element not mounted");
625
+ return n.value.getValue();
626
+ }, K = () => {
627
+ n.value?.focus();
628
+ }, N = () => {
629
+ n.value?.clear();
630
+ };
631
+ return I(() => {
632
+ m();
633
+ }), W(() => {
634
+ O();
635
+ }), E(() => l.options, () => {
636
+ $();
637
+ }, { deep: !0 }), o({
638
+ element: n,
639
+ getValue: U,
640
+ focus: K,
641
+ clear: N
642
+ }), {
643
+ addressRef: i,
644
+ element: n,
645
+ getValue: U,
646
+ focus: K,
647
+ clear: N
648
+ };
649
+ }
650
+ }), _e = { ref: "addressRef" };
651
+ function be(l, a, o, i, n, s) {
652
+ return h(), f("div", _e, null, 512);
653
+ }
654
+ const Le = /* @__PURE__ */ C(Se, [["render", be]]);
655
+ function D() {
656
+ const l = S(R);
657
+ if (!l)
658
+ throw new b(
659
+ "useStripe must be called within a VueStripeProvider component"
660
+ );
661
+ return {
662
+ stripe: _(l.stripe),
663
+ loading: _(l.loading),
664
+ error: _(l.error),
665
+ initialize: async () => {
666
+ }
667
+ };
668
+ }
669
+ const Ve = ["disabled"], ke = /* @__PURE__ */ w({
670
+ __name: "VueStripeCheckout",
671
+ props: {
672
+ sessionId: {},
673
+ priceId: {},
674
+ mode: { default: "payment" },
675
+ successUrl: {},
676
+ cancelUrl: {},
677
+ customerEmail: {},
678
+ clientReferenceId: {},
679
+ submitType: {},
680
+ options: {},
681
+ buttonText: { default: "Checkout" },
682
+ loadingText: { default: "Redirecting..." },
683
+ disabled: { type: Boolean, default: !1 },
684
+ buttonClass: { default: "vue-stripe-checkout-button" }
685
+ },
686
+ emits: ["click", "success", "error"],
687
+ setup(l, { emit: a }) {
688
+ const o = l, i = a, { stripe: n } = D(), s = d(!1), t = async () => {
689
+ if (!n.value) {
690
+ const e = new b("Stripe not initialized");
691
+ i("error", e);
692
+ return;
693
+ }
694
+ if (!o.sessionId && !o.priceId) {
695
+ const e = new b("Either sessionId or priceId is required");
696
+ i("error", e);
697
+ return;
698
+ }
699
+ try {
700
+ s.value = !0, i("click");
701
+ let e;
702
+ if (o.sessionId ? e = await n.value.redirectToCheckout({
703
+ sessionId: o.sessionId,
704
+ ...o.options
705
+ }) : e = await n.value.redirectToCheckout({
706
+ lineItems: [
707
+ {
708
+ price: o.priceId,
709
+ quantity: 1
710
+ }
711
+ ],
712
+ mode: o.mode,
713
+ successUrl: o.successUrl || window.location.origin + "/success",
714
+ cancelUrl: o.cancelUrl || window.location.origin + "/cancel",
715
+ customerEmail: o.customerEmail,
716
+ clientReferenceId: o.clientReferenceId,
717
+ submitType: o.submitType
718
+ }), e.error)
719
+ throw new b(e.error.message || "Redirect to checkout failed");
720
+ i("success");
721
+ } catch (e) {
722
+ const u = e instanceof Error ? e : new Error("Checkout failed");
723
+ i("error", u), console.error("[Vue Stripe] Checkout error:", u);
724
+ } finally {
725
+ s.value = !1;
726
+ }
727
+ };
728
+ return (e, u) => (h(), f("button", {
729
+ disabled: v(s) || l.disabled,
730
+ class: T(l.buttonClass),
731
+ onClick: t
732
+ }, [
733
+ v(s) ? g(e.$slots, "loading", { key: 1 }, () => [
734
+ u[0] || (u[0] = y("span", { class: "vue-stripe-loading-spinner" }, null, -1)),
735
+ q(" " + x(l.loadingText), 1)
736
+ ], !0) : g(e.$slots, "default", { key: 0 }, () => [
737
+ q(x(l.buttonText), 1)
738
+ ], !0)
739
+ ], 10, Ve));
740
+ }
741
+ }), Ue = /* @__PURE__ */ C(ke, [["__scopeId", "data-v-b439ab37"]]);
742
+ function Ke() {
743
+ const l = S(R), a = S(V);
744
+ if (!l)
745
+ throw new b(
746
+ "usePaymentIntent must be called within a VueStripeProvider component"
747
+ );
748
+ const o = d(!1), i = d(null);
749
+ return {
750
+ confirmPayment: async (s) => {
751
+ if (!l.stripe.value)
752
+ return i.value = "Stripe not initialized", { error: { message: "Stripe not initialized" } };
753
+ o.value = !0, i.value = null;
754
+ try {
755
+ const t = s.elements ?? a?.elements.value;
756
+ if (t && !s.skipSubmit) {
757
+ const { error: u } = await t.submit();
758
+ if (u)
759
+ return i.value = u.message || "Form validation failed", { error: u };
760
+ }
761
+ const e = await l.stripe.value.confirmPayment({
762
+ elements: t ?? void 0,
763
+ clientSecret: s.clientSecret,
764
+ confirmParams: s.confirmParams ?? {},
765
+ redirect: s.redirect ?? "if_required"
766
+ });
767
+ return e.error && (i.value = e.error.message || "Payment confirmation failed"), e;
768
+ } catch (t) {
769
+ const e = t instanceof Error ? t.message : "Payment confirmation failed";
770
+ return i.value = e, { error: { message: e } };
771
+ } finally {
772
+ o.value = !1;
773
+ }
774
+ },
775
+ loading: _(o),
776
+ error: _(i)
777
+ };
778
+ }
779
+ function Ne() {
780
+ const l = S(R), a = S(V);
781
+ if (!l)
782
+ throw new b(
783
+ "useSetupIntent must be called within a VueStripeProvider component"
784
+ );
785
+ const o = d(!1), i = d(null);
786
+ return {
787
+ confirmSetup: async (s) => {
788
+ if (!l.stripe.value)
789
+ return i.value = "Stripe not initialized", { error: { message: "Stripe not initialized" } };
790
+ o.value = !0, i.value = null;
791
+ try {
792
+ const t = s.elements ?? a?.elements.value;
793
+ if (t && !s.skipSubmit) {
794
+ const { error: u } = await t.submit();
795
+ if (u)
796
+ return i.value = u.message || "Form validation failed", { error: u };
797
+ }
798
+ const e = await l.stripe.value.confirmSetup({
799
+ elements: t ?? void 0,
800
+ clientSecret: s.clientSecret,
801
+ confirmParams: s.confirmParams ?? {},
802
+ redirect: s.redirect ?? "if_required"
803
+ });
804
+ return e.error && (i.value = e.error.message || "Setup confirmation failed"), e;
805
+ } catch (t) {
806
+ const e = t instanceof Error ? t.message : "Setup confirmation failed";
807
+ return i.value = e, { error: { message: e } };
808
+ } finally {
809
+ o.value = !1;
810
+ }
811
+ },
812
+ loading: _(o),
813
+ error: _(i)
814
+ };
815
+ }
816
+ function qe() {
817
+ const { stripe: l } = D(), a = d(!1), o = d(null);
818
+ return {
819
+ redirectToCheckout: async (n) => {
820
+ if (!l.value)
821
+ throw new b("Stripe not initialized");
822
+ try {
823
+ a.value = !0, o.value = null;
824
+ const s = await l.value.redirectToCheckout(n);
825
+ if (s.error) {
826
+ const t = s.error.message || "Checkout redirect failed";
827
+ throw o.value = t, new b(t);
828
+ }
829
+ } catch (s) {
830
+ const t = s instanceof Error ? s.message : "Checkout redirect failed";
831
+ throw o.value = t, s;
832
+ } finally {
833
+ a.value = !1;
834
+ }
835
+ },
836
+ loading: _(a),
837
+ error: _(o)
838
+ };
839
+ }
840
+ function Be() {
841
+ const l = S(V);
842
+ if (!l)
843
+ throw new k(
844
+ "Elements context not found. Make sure to wrap your component with VueStripeElements."
845
+ );
846
+ const a = async () => l.elements.value ? l.elements.value.submit() : { error: { message: "Elements not initialized" } };
847
+ return {
848
+ elements: _(l.elements),
849
+ submit: a,
850
+ loading: _(l.loading),
851
+ error: _(l.error)
852
+ };
853
+ }
854
+ function je(l) {
855
+ return {
856
+ install(a) {
857
+ a.provide("vue-stripe-config", l);
858
+ let o = null;
859
+ a.provide("vue-stripe-global", {
860
+ get stripe() {
861
+ if (!o) {
862
+ const i = {};
863
+ l.stripeAccount && (i.stripeAccount = l.stripeAccount), l.apiVersion && (i.apiVersion = l.apiVersion), l.locale && (i.locale = l.locale), o = B(l.publishableKey, i).then((n) => (n && n.registerAppInfo(j), n));
864
+ }
865
+ return o;
866
+ }
867
+ });
868
+ }
869
+ };
870
+ }
871
+ export {
872
+ Le as VueStripeAddressElement,
873
+ Fe as VueStripeCardCvcElement,
874
+ Ae as VueStripeCardElement,
875
+ Te as VueStripeCardExpiryElement,
876
+ Re as VueStripeCardNumberElement,
877
+ Ue as VueStripeCheckout,
878
+ xe as VueStripeElements,
879
+ k as VueStripeElementsError,
880
+ Me as VueStripeExpressCheckoutElement,
881
+ ze as VueStripeLinkAuthenticationElement,
882
+ X as VueStripeLoadError,
883
+ Pe as VueStripePaymentElement,
884
+ Ce as VueStripeProvider,
885
+ b as VueStripeProviderError,
886
+ je as createVueStripe,
887
+ Ie as createVueStripeError,
888
+ We as loadStripe,
889
+ qe as useCheckout,
890
+ Be as useElements,
891
+ Ke as usePaymentIntent,
892
+ Ne as useSetupIntent,
893
+ D as useStripe,
894
+ qe as useStripeCheckout,
895
+ Be as useStripeElements
896
+ };