@stripe-sdk/core 1.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.
@@ -0,0 +1,198 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { StripeElementsOptions } from '@stripe/stripe-js';
3
+ import { ReactNode } from 'react';
4
+
5
+ interface StripeContextValue {
6
+ publishableKey: string;
7
+ }
8
+ declare function useStripeConfig(): StripeContextValue;
9
+ interface StripeProviderProps {
10
+ publishableKey: string;
11
+ children: ReactNode;
12
+ options?: StripeElementsOptions;
13
+ locale?: string;
14
+ }
15
+ declare function StripeProvider({ publishableKey, children, options, locale, }: StripeProviderProps): react_jsx_runtime.JSX.Element;
16
+ /**
17
+ * Provider for embedding Stripe Elements with a client secret.
18
+ * Use this to wrap payment forms after creating a PaymentIntent or SetupIntent.
19
+ */
20
+ interface StripeElementsProviderProps {
21
+ publishableKey: string;
22
+ clientSecret: string;
23
+ children: ReactNode;
24
+ appearance?: StripeElementsOptions['appearance'];
25
+ locale?: string;
26
+ loader?: 'auto' | 'always' | 'never';
27
+ }
28
+ declare function StripeElementsProvider({ publishableKey, clientSecret, children, appearance, locale, loader, }: StripeElementsProviderProps): react_jsx_runtime.JSX.Element;
29
+
30
+ interface UsePaymentOptions {
31
+ onSuccess?: (paymentIntentId: string) => void;
32
+ onError?: (error: string) => void;
33
+ returnUrl?: string;
34
+ }
35
+ declare function usePayment(options?: UsePaymentOptions): {
36
+ processPayment: (overrides?: {
37
+ returnUrl?: string;
38
+ }) => Promise<{
39
+ success: boolean;
40
+ error: string;
41
+ paymentIntentId?: undefined;
42
+ status?: undefined;
43
+ } | {
44
+ success: boolean;
45
+ paymentIntentId: string;
46
+ error?: undefined;
47
+ status?: undefined;
48
+ } | {
49
+ success: boolean;
50
+ status: "canceled" | "processing" | "requires_action" | "requires_capture" | "requires_confirmation" | "requires_payment_method";
51
+ error?: undefined;
52
+ paymentIntentId?: undefined;
53
+ }>;
54
+ reset: () => void;
55
+ isReady: boolean;
56
+ isProcessing: boolean;
57
+ isSuccess: boolean;
58
+ error: string | null;
59
+ paymentIntentId: string | null;
60
+ };
61
+
62
+ interface UseSetupIntentOptions {
63
+ onSuccess?: (setupIntentId: string, paymentMethodId: string) => void;
64
+ onError?: (error: string) => void;
65
+ returnUrl?: string;
66
+ }
67
+ declare function useSetupIntent(options?: UseSetupIntentOptions): {
68
+ confirmSetup: (overrides?: {
69
+ returnUrl?: string;
70
+ }) => Promise<{
71
+ success: boolean;
72
+ error: string;
73
+ setupIntentId?: undefined;
74
+ paymentMethodId?: undefined;
75
+ status?: undefined;
76
+ } | {
77
+ success: boolean;
78
+ setupIntentId: string;
79
+ paymentMethodId: string | null;
80
+ error?: undefined;
81
+ status?: undefined;
82
+ } | {
83
+ success: boolean;
84
+ status: "canceled" | "processing" | "requires_action" | "requires_confirmation" | "requires_payment_method";
85
+ error?: undefined;
86
+ setupIntentId?: undefined;
87
+ paymentMethodId?: undefined;
88
+ }>;
89
+ reset: () => void;
90
+ isReady: boolean;
91
+ isProcessing: boolean;
92
+ isSuccess: boolean;
93
+ error: string | null;
94
+ setupIntentId: string | null;
95
+ paymentMethodId: string | null;
96
+ };
97
+
98
+ interface UseCheckoutOptions {
99
+ publishableKey: string;
100
+ onError?: (error: string) => void;
101
+ }
102
+ declare function useCheckout(options: UseCheckoutOptions): {
103
+ redirectToCheckout: (sessionId: string) => Promise<{
104
+ success: boolean;
105
+ error: string;
106
+ } | {
107
+ success: boolean;
108
+ error?: undefined;
109
+ }>;
110
+ redirectToPortal: (portalUrl: string) => void;
111
+ isLoading: boolean;
112
+ error: string | null;
113
+ };
114
+
115
+ interface CheckoutFormProps {
116
+ onSuccess?: (paymentIntentId: string) => void;
117
+ onError?: (error: string) => void;
118
+ returnUrl?: string;
119
+ submitLabel?: string;
120
+ showEmail?: boolean;
121
+ className?: string;
122
+ buttonClassName?: string;
123
+ errorClassName?: string;
124
+ children?: ReactNode;
125
+ layout?: 'tabs' | 'accordion' | 'auto';
126
+ }
127
+ declare function CheckoutForm({ onSuccess, onError, returnUrl, submitLabel, showEmail, className, buttonClassName, errorClassName, children, layout, }: CheckoutFormProps): react_jsx_runtime.JSX.Element;
128
+
129
+ interface SetupFormProps {
130
+ onSuccess?: (setupIntentId: string, paymentMethodId: string) => void;
131
+ onError?: (error: string) => void;
132
+ returnUrl?: string;
133
+ submitLabel?: string;
134
+ className?: string;
135
+ buttonClassName?: string;
136
+ errorClassName?: string;
137
+ successContent?: ReactNode;
138
+ layout?: 'tabs' | 'accordion' | 'auto';
139
+ }
140
+ declare function SetupForm({ onSuccess, onError, returnUrl, submitLabel, className, buttonClassName, errorClassName, successContent, layout, }: SetupFormProps): react_jsx_runtime.JSX.Element;
141
+
142
+ interface PricingPlan {
143
+ id: string;
144
+ name: string;
145
+ description?: string;
146
+ priceId: string;
147
+ amount: number;
148
+ currency: string;
149
+ interval?: 'month' | 'year' | 'week' | 'day';
150
+ features: string[];
151
+ highlighted?: boolean;
152
+ badge?: string;
153
+ trialDays?: number;
154
+ }
155
+ interface PricingTableProps {
156
+ plans: PricingPlan[];
157
+ onSelectPlan: (plan: PricingPlan) => void;
158
+ isLoading?: boolean;
159
+ currentPlanId?: string;
160
+ buttonLabel?: string;
161
+ currentPlanLabel?: string;
162
+ className?: string;
163
+ planClassName?: string;
164
+ highlightedClassName?: string;
165
+ buttonClassName?: string;
166
+ formatPrice?: (amount: number, currency: string) => string;
167
+ renderFeature?: (feature: string) => ReactNode;
168
+ }
169
+ declare function PricingTable({ plans, onSelectPlan, isLoading, currentPlanId, buttonLabel, currentPlanLabel, className, planClassName, highlightedClassName, buttonClassName, formatPrice, renderFeature, }: PricingTableProps): react_jsx_runtime.JSX.Element;
170
+
171
+ interface SubscriptionInfo {
172
+ id: string;
173
+ status: string;
174
+ planName: string;
175
+ amount: number;
176
+ currency: string;
177
+ interval: string;
178
+ currentPeriodEnd: string | Date;
179
+ cancelAtPeriodEnd: boolean;
180
+ trialEnd?: string | Date | null;
181
+ }
182
+ interface SubscriptionManagerProps {
183
+ subscription: SubscriptionInfo;
184
+ onCancel: (subscriptionId: string) => Promise<void>;
185
+ onResume?: (subscriptionId: string) => Promise<void>;
186
+ onChangePlan?: (subscriptionId: string) => void;
187
+ onManageBilling?: () => void;
188
+ className?: string;
189
+ formatPrice?: (amount: number, currency: string) => string;
190
+ cancelLabel?: string;
191
+ resumeLabel?: string;
192
+ changePlanLabel?: string;
193
+ manageBillingLabel?: string;
194
+ children?: ReactNode;
195
+ }
196
+ declare function SubscriptionManager({ subscription, onCancel, onResume, onChangePlan, onManageBilling, className, formatPrice, cancelLabel, resumeLabel, changePlanLabel, manageBillingLabel, }: SubscriptionManagerProps): react_jsx_runtime.JSX.Element;
197
+
198
+ export { CheckoutForm, type CheckoutFormProps, type PricingPlan, PricingTable, type PricingTableProps, SetupForm, type SetupFormProps, StripeElementsProvider, type StripeElementsProviderProps, StripeProvider, type StripeProviderProps, type SubscriptionInfo, SubscriptionManager, type SubscriptionManagerProps, useCheckout, usePayment, useSetupIntent, useStripeConfig };
@@ -0,0 +1,198 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { StripeElementsOptions } from '@stripe/stripe-js';
3
+ import { ReactNode } from 'react';
4
+
5
+ interface StripeContextValue {
6
+ publishableKey: string;
7
+ }
8
+ declare function useStripeConfig(): StripeContextValue;
9
+ interface StripeProviderProps {
10
+ publishableKey: string;
11
+ children: ReactNode;
12
+ options?: StripeElementsOptions;
13
+ locale?: string;
14
+ }
15
+ declare function StripeProvider({ publishableKey, children, options, locale, }: StripeProviderProps): react_jsx_runtime.JSX.Element;
16
+ /**
17
+ * Provider for embedding Stripe Elements with a client secret.
18
+ * Use this to wrap payment forms after creating a PaymentIntent or SetupIntent.
19
+ */
20
+ interface StripeElementsProviderProps {
21
+ publishableKey: string;
22
+ clientSecret: string;
23
+ children: ReactNode;
24
+ appearance?: StripeElementsOptions['appearance'];
25
+ locale?: string;
26
+ loader?: 'auto' | 'always' | 'never';
27
+ }
28
+ declare function StripeElementsProvider({ publishableKey, clientSecret, children, appearance, locale, loader, }: StripeElementsProviderProps): react_jsx_runtime.JSX.Element;
29
+
30
+ interface UsePaymentOptions {
31
+ onSuccess?: (paymentIntentId: string) => void;
32
+ onError?: (error: string) => void;
33
+ returnUrl?: string;
34
+ }
35
+ declare function usePayment(options?: UsePaymentOptions): {
36
+ processPayment: (overrides?: {
37
+ returnUrl?: string;
38
+ }) => Promise<{
39
+ success: boolean;
40
+ error: string;
41
+ paymentIntentId?: undefined;
42
+ status?: undefined;
43
+ } | {
44
+ success: boolean;
45
+ paymentIntentId: string;
46
+ error?: undefined;
47
+ status?: undefined;
48
+ } | {
49
+ success: boolean;
50
+ status: "canceled" | "processing" | "requires_action" | "requires_capture" | "requires_confirmation" | "requires_payment_method";
51
+ error?: undefined;
52
+ paymentIntentId?: undefined;
53
+ }>;
54
+ reset: () => void;
55
+ isReady: boolean;
56
+ isProcessing: boolean;
57
+ isSuccess: boolean;
58
+ error: string | null;
59
+ paymentIntentId: string | null;
60
+ };
61
+
62
+ interface UseSetupIntentOptions {
63
+ onSuccess?: (setupIntentId: string, paymentMethodId: string) => void;
64
+ onError?: (error: string) => void;
65
+ returnUrl?: string;
66
+ }
67
+ declare function useSetupIntent(options?: UseSetupIntentOptions): {
68
+ confirmSetup: (overrides?: {
69
+ returnUrl?: string;
70
+ }) => Promise<{
71
+ success: boolean;
72
+ error: string;
73
+ setupIntentId?: undefined;
74
+ paymentMethodId?: undefined;
75
+ status?: undefined;
76
+ } | {
77
+ success: boolean;
78
+ setupIntentId: string;
79
+ paymentMethodId: string | null;
80
+ error?: undefined;
81
+ status?: undefined;
82
+ } | {
83
+ success: boolean;
84
+ status: "canceled" | "processing" | "requires_action" | "requires_confirmation" | "requires_payment_method";
85
+ error?: undefined;
86
+ setupIntentId?: undefined;
87
+ paymentMethodId?: undefined;
88
+ }>;
89
+ reset: () => void;
90
+ isReady: boolean;
91
+ isProcessing: boolean;
92
+ isSuccess: boolean;
93
+ error: string | null;
94
+ setupIntentId: string | null;
95
+ paymentMethodId: string | null;
96
+ };
97
+
98
+ interface UseCheckoutOptions {
99
+ publishableKey: string;
100
+ onError?: (error: string) => void;
101
+ }
102
+ declare function useCheckout(options: UseCheckoutOptions): {
103
+ redirectToCheckout: (sessionId: string) => Promise<{
104
+ success: boolean;
105
+ error: string;
106
+ } | {
107
+ success: boolean;
108
+ error?: undefined;
109
+ }>;
110
+ redirectToPortal: (portalUrl: string) => void;
111
+ isLoading: boolean;
112
+ error: string | null;
113
+ };
114
+
115
+ interface CheckoutFormProps {
116
+ onSuccess?: (paymentIntentId: string) => void;
117
+ onError?: (error: string) => void;
118
+ returnUrl?: string;
119
+ submitLabel?: string;
120
+ showEmail?: boolean;
121
+ className?: string;
122
+ buttonClassName?: string;
123
+ errorClassName?: string;
124
+ children?: ReactNode;
125
+ layout?: 'tabs' | 'accordion' | 'auto';
126
+ }
127
+ declare function CheckoutForm({ onSuccess, onError, returnUrl, submitLabel, showEmail, className, buttonClassName, errorClassName, children, layout, }: CheckoutFormProps): react_jsx_runtime.JSX.Element;
128
+
129
+ interface SetupFormProps {
130
+ onSuccess?: (setupIntentId: string, paymentMethodId: string) => void;
131
+ onError?: (error: string) => void;
132
+ returnUrl?: string;
133
+ submitLabel?: string;
134
+ className?: string;
135
+ buttonClassName?: string;
136
+ errorClassName?: string;
137
+ successContent?: ReactNode;
138
+ layout?: 'tabs' | 'accordion' | 'auto';
139
+ }
140
+ declare function SetupForm({ onSuccess, onError, returnUrl, submitLabel, className, buttonClassName, errorClassName, successContent, layout, }: SetupFormProps): react_jsx_runtime.JSX.Element;
141
+
142
+ interface PricingPlan {
143
+ id: string;
144
+ name: string;
145
+ description?: string;
146
+ priceId: string;
147
+ amount: number;
148
+ currency: string;
149
+ interval?: 'month' | 'year' | 'week' | 'day';
150
+ features: string[];
151
+ highlighted?: boolean;
152
+ badge?: string;
153
+ trialDays?: number;
154
+ }
155
+ interface PricingTableProps {
156
+ plans: PricingPlan[];
157
+ onSelectPlan: (plan: PricingPlan) => void;
158
+ isLoading?: boolean;
159
+ currentPlanId?: string;
160
+ buttonLabel?: string;
161
+ currentPlanLabel?: string;
162
+ className?: string;
163
+ planClassName?: string;
164
+ highlightedClassName?: string;
165
+ buttonClassName?: string;
166
+ formatPrice?: (amount: number, currency: string) => string;
167
+ renderFeature?: (feature: string) => ReactNode;
168
+ }
169
+ declare function PricingTable({ plans, onSelectPlan, isLoading, currentPlanId, buttonLabel, currentPlanLabel, className, planClassName, highlightedClassName, buttonClassName, formatPrice, renderFeature, }: PricingTableProps): react_jsx_runtime.JSX.Element;
170
+
171
+ interface SubscriptionInfo {
172
+ id: string;
173
+ status: string;
174
+ planName: string;
175
+ amount: number;
176
+ currency: string;
177
+ interval: string;
178
+ currentPeriodEnd: string | Date;
179
+ cancelAtPeriodEnd: boolean;
180
+ trialEnd?: string | Date | null;
181
+ }
182
+ interface SubscriptionManagerProps {
183
+ subscription: SubscriptionInfo;
184
+ onCancel: (subscriptionId: string) => Promise<void>;
185
+ onResume?: (subscriptionId: string) => Promise<void>;
186
+ onChangePlan?: (subscriptionId: string) => void;
187
+ onManageBilling?: () => void;
188
+ className?: string;
189
+ formatPrice?: (amount: number, currency: string) => string;
190
+ cancelLabel?: string;
191
+ resumeLabel?: string;
192
+ changePlanLabel?: string;
193
+ manageBillingLabel?: string;
194
+ children?: ReactNode;
195
+ }
196
+ declare function SubscriptionManager({ subscription, onCancel, onResume, onChangePlan, onManageBilling, className, formatPrice, cancelLabel, resumeLabel, changePlanLabel, manageBillingLabel, }: SubscriptionManagerProps): react_jsx_runtime.JSX.Element;
197
+
198
+ export { CheckoutForm, type CheckoutFormProps, type PricingPlan, PricingTable, type PricingTableProps, SetupForm, type SetupFormProps, StripeElementsProvider, type StripeElementsProviderProps, StripeProvider, type StripeProviderProps, type SubscriptionInfo, SubscriptionManager, type SubscriptionManagerProps, useCheckout, usePayment, useSetupIntent, useStripeConfig };