@vue-stripe/vue-stripe 5.0.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.
- package/README.md +36 -9
- package/dist/cjs/index.js +1 -1
- package/dist/es/index.js +582 -535
- package/dist/types/components/VueStripeCheckout.vue.d.ts +34 -10
- package/dist/types/components/VueStripeCheckout.vue.d.ts.map +1 -1
- package/dist/types/composables/useStripeCheckout.d.ts +65 -2
- package/dist/types/composables/useStripeCheckout.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/vue-stripe.css +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue-demi';
|
|
1
|
+
import { DefineComponent, Ref, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue-demi';
|
|
3
2
|
interface Props {
|
|
3
|
+
/**
|
|
4
|
+
* Checkout Session ID (starts with cs_).
|
|
5
|
+
* When provided, redirects to the session's checkout page.
|
|
6
|
+
*/
|
|
4
7
|
sessionId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Checkout Session URL from Stripe API.
|
|
10
|
+
* For @stripe/stripe-js v8.x compatibility where redirectToCheckout is removed.
|
|
11
|
+
* When provided, this takes precedence over sessionId.
|
|
12
|
+
*/
|
|
13
|
+
sessionUrl?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Price ID for client-side session creation (legacy, requires redirectToCheckout).
|
|
16
|
+
* @deprecated Use sessionUrl with server-side session creation for v8.x compatibility.
|
|
17
|
+
*/
|
|
5
18
|
priceId?: string;
|
|
6
19
|
mode?: 'payment' | 'subscription';
|
|
7
20
|
successUrl?: string;
|
|
@@ -9,7 +22,6 @@ interface Props {
|
|
|
9
22
|
customerEmail?: string;
|
|
10
23
|
clientReferenceId?: string;
|
|
11
24
|
submitType?: 'auto' | 'book' | 'donate' | 'pay';
|
|
12
|
-
options?: Partial<RedirectToCheckoutOptions>;
|
|
13
25
|
buttonText?: string;
|
|
14
26
|
loadingText?: string;
|
|
15
27
|
disabled?: boolean;
|
|
@@ -18,28 +30,40 @@ interface Props {
|
|
|
18
30
|
declare function __VLS_template(): {
|
|
19
31
|
attrs: Partial<{}>;
|
|
20
32
|
slots: {
|
|
21
|
-
default?(_: {
|
|
22
|
-
|
|
33
|
+
default?(_: {
|
|
34
|
+
checkout: () => Promise<void>;
|
|
35
|
+
loading: boolean;
|
|
36
|
+
disabled: boolean | undefined;
|
|
37
|
+
}): any;
|
|
23
38
|
};
|
|
24
39
|
refs: {};
|
|
25
|
-
rootEl:
|
|
40
|
+
rootEl: any;
|
|
26
41
|
};
|
|
27
42
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
28
|
-
declare const __VLS_component: DefineComponent<Props, {
|
|
43
|
+
declare const __VLS_component: DefineComponent<Props, {
|
|
44
|
+
checkout: () => Promise<void>;
|
|
45
|
+
loading: Ref<boolean, boolean>;
|
|
46
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
|
|
29
47
|
error: (error: Error) => any;
|
|
30
|
-
|
|
48
|
+
checkout: () => any;
|
|
31
49
|
success: () => any;
|
|
50
|
+
"before-redirect": (data: {
|
|
51
|
+
url: string;
|
|
52
|
+
}) => any;
|
|
32
53
|
}, string, PublicProps, Readonly<Props> & Readonly<{
|
|
33
54
|
onError?: (error: Error) => any;
|
|
34
|
-
|
|
55
|
+
onCheckout?: () => any;
|
|
35
56
|
onSuccess?: () => any;
|
|
57
|
+
"onBefore-redirect"?: (data: {
|
|
58
|
+
url: string;
|
|
59
|
+
}) => any;
|
|
36
60
|
}>, {
|
|
37
61
|
mode: "payment" | "subscription";
|
|
38
62
|
buttonText: string;
|
|
39
63
|
loadingText: string;
|
|
40
64
|
disabled: boolean;
|
|
41
65
|
buttonClass: string;
|
|
42
|
-
}, {}, {}, {}, string, ComponentProvideOptions, false, {},
|
|
66
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
43
67
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
44
68
|
export default _default;
|
|
45
69
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VueStripeCheckout.vue.d.ts","sourceRoot":"","sources":["../../../src/components/VueStripeCheckout.vue"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"VueStripeCheckout.vue.d.ts","sourceRoot":"","sources":["../../../src/components/VueStripeCheckout.vue"],"names":[],"mappings":";AAsPA,UAAU,KAAK;IACb;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,SAAS,GAAG,cAAc,CAAA;IACjC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAkJD,iBAAS,cAAc;WAoDT,OAAO,IAA6B;;;;;;YAVrB,GAAG;;;;EAe/B;AAaD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;;aAnNiB,MAAM;;;;;;;aAAN,MAAM;;;UAhBnC,SAAS,GAAG,cAAc;gBAMpB,MAAM;iBACL,MAAM;cACT,OAAO;iBACJ,MAAM;kFAmOpB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAYpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,9 +1,72 @@
|
|
|
1
1
|
import { Ref } from 'vue-demi';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Options for URL-based checkout redirect (v8.x compatible)
|
|
4
|
+
*/
|
|
5
|
+
export interface CheckoutRedirectOptions {
|
|
6
|
+
/** The checkout session URL from your server */
|
|
7
|
+
url: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Options for legacy redirectToCheckout (v7.x only)
|
|
11
|
+
* @deprecated Use CheckoutRedirectOptions with URL redirect instead
|
|
12
|
+
*/
|
|
13
|
+
export interface LegacyCheckoutOptions {
|
|
14
|
+
/** Checkout Session ID */
|
|
15
|
+
sessionId?: string;
|
|
16
|
+
/** Line items for client-side session creation */
|
|
17
|
+
lineItems?: Array<{
|
|
18
|
+
price: string;
|
|
19
|
+
quantity: number;
|
|
20
|
+
}>;
|
|
21
|
+
/** Checkout mode */
|
|
22
|
+
mode?: 'payment' | 'subscription' | 'setup';
|
|
23
|
+
/** Success redirect URL */
|
|
24
|
+
successUrl?: string;
|
|
25
|
+
/** Cancel redirect URL */
|
|
26
|
+
cancelUrl?: string;
|
|
27
|
+
}
|
|
3
28
|
export interface UseStripeCheckoutReturn {
|
|
4
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Redirect to Stripe Checkout using session URL (v8.x compatible, recommended)
|
|
31
|
+
*/
|
|
32
|
+
redirectToCheckout: (options: CheckoutRedirectOptions | LegacyCheckoutOptions) => Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Redirect to checkout using session URL (v8.x compatible)
|
|
35
|
+
*/
|
|
36
|
+
redirectToUrl: (url: string) => void;
|
|
5
37
|
loading: Readonly<Ref<boolean>>;
|
|
6
38
|
error: Readonly<Ref<string | null>>;
|
|
7
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Composable for handling Stripe Checkout redirects.
|
|
42
|
+
*
|
|
43
|
+
* Supports both @stripe/stripe-js v7.x (redirectToCheckout) and v8.x (URL redirect).
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```vue
|
|
47
|
+
* <script setup>
|
|
48
|
+
* import { useStripeCheckout } from '@vue-stripe/vue-stripe'
|
|
49
|
+
*
|
|
50
|
+
* const { redirectToCheckout, redirectToUrl, loading, error } = useStripeCheckout()
|
|
51
|
+
*
|
|
52
|
+
* // v8.x compatible (recommended)
|
|
53
|
+
* const handleCheckout = async () => {
|
|
54
|
+
* const response = await fetch('/api/create-checkout-session', {
|
|
55
|
+
* method: 'POST',
|
|
56
|
+
* body: JSON.stringify({ priceId: 'price_xxx' })
|
|
57
|
+
* })
|
|
58
|
+
* const { url } = await response.json()
|
|
59
|
+
* redirectToUrl(url)
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* // Or using redirectToCheckout with URL
|
|
63
|
+
* const handleCheckoutAlt = async () => {
|
|
64
|
+
* const response = await fetch('/api/create-checkout-session')
|
|
65
|
+
* const { url } = await response.json()
|
|
66
|
+
* await redirectToCheckout({ url })
|
|
67
|
+
* }
|
|
68
|
+
* </script>
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
8
71
|
export declare function useStripeCheckout(): UseStripeCheckoutReturn;
|
|
9
72
|
//# sourceMappingURL=useStripeCheckout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStripeCheckout.d.ts","sourceRoot":"","sources":["../../../src/composables/useStripeCheckout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,GAAG,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"useStripeCheckout.d.ts","sourceRoot":"","sources":["../../../src/composables/useStripeCheckout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,GAAG,EAAE,MAAM,UAAU,CAAA;AAIlD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kDAAkD;IAClD,SAAS,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACtD,oBAAoB;IACpB,IAAI,CAAC,EAAE,SAAS,GAAG,cAAc,GAAG,OAAO,CAAA;IAC3C,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,kBAAkB,EAAE,CAAC,OAAO,EAAE,uBAAuB,GAAG,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/F;;OAEG;IACH,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAC/B,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAA;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,iBAAiB,IAAI,uBAAuB,CAiF3D"}
|