@vue-stripe/vue-stripe 4.5.0 → 5.1.1

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