@solvapay/react 1.0.0-preview.3 → 1.0.0-preview.5
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 +148 -15
- package/dist/index.cjs +432 -171
- package/dist/index.d.cts +216 -60
- package/dist/index.d.ts +216 -60
- package/dist/index.js +427 -171
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,84 +1,240 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Stripe } from '@stripe/stripe-js';
|
|
1
|
+
import React$1 from 'react';
|
|
2
|
+
import { PaymentIntent, Stripe } from '@stripe/stripe-js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* TypeScript type definitions for @solvapay/react
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface SubscriptionInfo {
|
|
9
|
+
reference: string;
|
|
10
|
+
planName: string;
|
|
11
|
+
agentName: string;
|
|
12
|
+
status: string;
|
|
13
|
+
startDate: string;
|
|
14
|
+
}
|
|
15
|
+
interface CustomerSubscriptionData {
|
|
16
|
+
customerRef?: string;
|
|
17
|
+
email?: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
subscriptions: SubscriptionInfo[];
|
|
20
|
+
}
|
|
21
|
+
interface PaymentIntentResult {
|
|
22
|
+
clientSecret: string;
|
|
23
|
+
publishableKey: string;
|
|
24
|
+
accountId?: string;
|
|
25
|
+
customerRef?: string;
|
|
26
|
+
}
|
|
27
|
+
interface SubscriptionStatus {
|
|
28
|
+
loading: boolean;
|
|
29
|
+
customerRef?: string;
|
|
30
|
+
email?: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
subscriptions: SubscriptionInfo[];
|
|
33
|
+
hasActiveSubscription: boolean;
|
|
34
|
+
hasPlan: (planName: string) => boolean;
|
|
35
|
+
}
|
|
36
|
+
interface SolvaPayContextValue {
|
|
37
|
+
subscription: SubscriptionStatus;
|
|
38
|
+
refetchSubscription: () => Promise<void>;
|
|
39
|
+
createPayment: (params: {
|
|
40
|
+
planRef: string;
|
|
41
|
+
customerRef: string;
|
|
42
|
+
}) => Promise<PaymentIntentResult>;
|
|
43
|
+
customerRef?: string;
|
|
44
|
+
updateCustomerRef?: (newCustomerRef: string) => void;
|
|
45
|
+
}
|
|
4
46
|
interface SolvaPayProviderProps {
|
|
47
|
+
createPayment: (params: {
|
|
48
|
+
planRef: string;
|
|
49
|
+
customerRef: string;
|
|
50
|
+
}) => Promise<PaymentIntentResult>;
|
|
51
|
+
checkSubscription: (customerRef: string) => Promise<CustomerSubscriptionData>;
|
|
52
|
+
customerRef?: string;
|
|
53
|
+
onCustomerRefUpdate?: (newCustomerRef: string) => void;
|
|
5
54
|
children: React.ReactNode;
|
|
6
|
-
|
|
7
|
-
|
|
55
|
+
}
|
|
56
|
+
interface PlanBadgeProps {
|
|
57
|
+
children?: (props: {
|
|
58
|
+
subscriptions: SubscriptionInfo[];
|
|
59
|
+
loading: boolean;
|
|
60
|
+
}) => React.ReactNode;
|
|
61
|
+
as?: React.ElementType;
|
|
62
|
+
className?: string | ((props: {
|
|
63
|
+
subscriptions: SubscriptionInfo[];
|
|
64
|
+
}) => string);
|
|
65
|
+
}
|
|
66
|
+
interface SubscriptionGateProps {
|
|
67
|
+
requirePlan?: string;
|
|
68
|
+
children: (props: {
|
|
69
|
+
hasAccess: boolean;
|
|
70
|
+
subscriptions: SubscriptionInfo[];
|
|
71
|
+
loading: boolean;
|
|
72
|
+
}) => React.ReactNode;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Error type for payment operations
|
|
76
|
+
*/
|
|
77
|
+
interface PaymentError extends Error {
|
|
78
|
+
code?: string;
|
|
79
|
+
type?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Payment form props with proper Stripe types
|
|
83
|
+
*/
|
|
84
|
+
interface PaymentFormProps {
|
|
85
|
+
/**
|
|
86
|
+
* Plan reference to checkout. PaymentForm handles the entire checkout flow internally
|
|
87
|
+
* including Stripe initialization and payment intent creation.
|
|
88
|
+
*/
|
|
8
89
|
planRef: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
90
|
+
onSuccess?: (paymentIntent: PaymentIntent) => void;
|
|
91
|
+
onError?: (error: Error) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Return URL after payment completion. Defaults to current page URL if not provided.
|
|
94
|
+
*/
|
|
95
|
+
returnUrl?: string;
|
|
96
|
+
submitButtonText?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Optional className for the form container (wraps form, messages, and cancel button)
|
|
99
|
+
*/
|
|
100
|
+
className?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Optional className for the submit button
|
|
103
|
+
*/
|
|
104
|
+
buttonClassName?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Text for the initial checkout button. If provided, shows a button first instead of
|
|
107
|
+
* auto-starting checkout.
|
|
108
|
+
*/
|
|
109
|
+
initialButtonText?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Text for the cancel button. Set to empty string to hide cancel button.
|
|
112
|
+
*/
|
|
113
|
+
cancelButtonText?: string;
|
|
12
114
|
}
|
|
115
|
+
|
|
13
116
|
/**
|
|
14
|
-
* SolvaPay
|
|
117
|
+
* SolvaPay Provider - Headless Context Provider
|
|
118
|
+
*
|
|
119
|
+
* Provides subscription state and payment methods to child components.
|
|
120
|
+
* This is a headless provider that manages state without rendering UI.
|
|
15
121
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```tsx
|
|
124
|
+
* <SolvaPayProvider
|
|
125
|
+
* customerRef={user?.id}
|
|
126
|
+
* createPayment={async ({ planRef, customerRef }) => {
|
|
127
|
+
* const res = await fetch('/api/payments/create', {
|
|
128
|
+
* method: 'POST',
|
|
129
|
+
* body: JSON.stringify({ planRef, customerRef })
|
|
130
|
+
* });
|
|
131
|
+
* return res.json();
|
|
132
|
+
* }}
|
|
133
|
+
* checkSubscription={async (customerRef) => {
|
|
134
|
+
* const res = await fetch(`/api/subscriptions/${customerRef}`);
|
|
135
|
+
* return res.json();
|
|
136
|
+
* }}
|
|
137
|
+
* >
|
|
138
|
+
* <App />
|
|
139
|
+
* </SolvaPayProvider>
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
declare const SolvaPayProvider: React$1.FC<SolvaPayProviderProps>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* SolvaPay Payment Form Component
|
|
18
146
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* 4. Wraps children in Stripe Elements provider
|
|
147
|
+
* Handles the entire checkout flow internally including Stripe initialization,
|
|
148
|
+
* payment intent creation, and form rendering. Simply provide a planRef and
|
|
149
|
+
* handle success/error callbacks.
|
|
23
150
|
*
|
|
24
151
|
* @example
|
|
25
152
|
* ```tsx
|
|
26
|
-
*
|
|
27
|
-
* import { SolvaPayProvider, PaymentForm } from '@solvapay/react';
|
|
153
|
+
* import { PaymentForm } from '@solvapay/react';
|
|
28
154
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* }}
|
|
39
|
-
* >
|
|
40
|
-
* <PaymentForm />
|
|
41
|
-
* </SolvaPayProvider>
|
|
42
|
-
* );
|
|
43
|
-
* }
|
|
155
|
+
* <PaymentForm
|
|
156
|
+
* planRef="pro_plan"
|
|
157
|
+
* onSuccess={(paymentIntent) => {
|
|
158
|
+
* console.log('Payment successful!');
|
|
159
|
+
* }}
|
|
160
|
+
* onError={(error) => {
|
|
161
|
+
* console.error('Payment failed:', error);
|
|
162
|
+
* }}
|
|
163
|
+
* />
|
|
44
164
|
* ```
|
|
45
165
|
*/
|
|
46
|
-
declare const
|
|
166
|
+
declare const PaymentForm: React$1.FC<PaymentFormProps>;
|
|
47
167
|
|
|
48
|
-
interface PaymentFormProps {
|
|
49
|
-
onSuccess?: (paymentIntent: any) => void;
|
|
50
|
-
onError?: (error: Error) => void;
|
|
51
|
-
returnUrl?: string;
|
|
52
|
-
submitButtonText?: string;
|
|
53
|
-
className?: string;
|
|
54
|
-
}
|
|
55
168
|
/**
|
|
56
|
-
*
|
|
169
|
+
* Headless Plan Badge Component
|
|
57
170
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
171
|
+
* Displays subscription status with complete styling control.
|
|
172
|
+
* Supports render props, custom components, or className patterns.
|
|
60
173
|
*
|
|
61
174
|
* @example
|
|
62
175
|
* ```tsx
|
|
63
|
-
*
|
|
176
|
+
* // Render prop pattern
|
|
177
|
+
* <PlanBadge>
|
|
178
|
+
* {({ subscriptions, loading }) => (
|
|
179
|
+
* <div>
|
|
180
|
+
* {subscriptions.map(sub => <span key={sub.reference}>{sub.planName}</span>)}
|
|
181
|
+
* </div>
|
|
182
|
+
* )}
|
|
183
|
+
* </PlanBadge>
|
|
184
|
+
*
|
|
185
|
+
* //ClassName pattern
|
|
186
|
+
* <PlanBadge className="badge badge-primary" />
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
declare const PlanBadge: React$1.FC<PlanBadgeProps>;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Headless Subscription Gate Component
|
|
64
193
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* </SolvaPayProvider>
|
|
78
|
-
* );
|
|
79
|
-
* }
|
|
194
|
+
* Controls access to content based on subscription status.
|
|
195
|
+
* Uses render props to give developers full control over locked/unlocked states.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```tsx
|
|
199
|
+
* <SubscriptionGate requirePlan="Pro Plan">
|
|
200
|
+
* {({ hasAccess, loading }) => {
|
|
201
|
+
* if (loading) return <Skeleton />;
|
|
202
|
+
* if (!hasAccess) return <Paywall />;
|
|
203
|
+
* return <PremiumContent />;
|
|
204
|
+
* }}
|
|
205
|
+
* </SubscriptionGate>
|
|
80
206
|
* ```
|
|
81
207
|
*/
|
|
82
|
-
declare const
|
|
208
|
+
declare const SubscriptionGate: React$1.FC<SubscriptionGateProps>;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Hook to access subscription status
|
|
212
|
+
* Returns the current subscription state and a refetch function
|
|
213
|
+
*/
|
|
214
|
+
declare function useSubscription(): SubscriptionStatus & {
|
|
215
|
+
refetch: () => Promise<void>;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
interface UseCheckoutReturn {
|
|
219
|
+
loading: boolean;
|
|
220
|
+
error: Error | null;
|
|
221
|
+
stripePromise: Promise<Stripe | null> | null;
|
|
222
|
+
clientSecret: string | null;
|
|
223
|
+
startCheckout: () => Promise<void>;
|
|
224
|
+
reset: () => void;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Hook to manage checkout flow
|
|
228
|
+
* Handles payment intent creation and Stripe initialization
|
|
229
|
+
*
|
|
230
|
+
* @param planRef - The plan reference to checkout
|
|
231
|
+
*/
|
|
232
|
+
declare function useCheckout(planRef: string): UseCheckoutReturn;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Hook to access SolvaPay context
|
|
236
|
+
* Must be used within a SolvaPayProvider
|
|
237
|
+
*/
|
|
238
|
+
declare function useSolvaPay(): SolvaPayContextValue;
|
|
83
239
|
|
|
84
|
-
export { PaymentForm, type PaymentFormProps, SolvaPayProvider, type SolvaPayProviderProps };
|
|
240
|
+
export { type CustomerSubscriptionData, type PaymentError, PaymentForm, type PaymentFormProps, type PaymentIntentResult, PlanBadge, type PlanBadgeProps, type SolvaPayContextValue, SolvaPayProvider, type SolvaPayProviderProps, SubscriptionGate, type SubscriptionGateProps, type SubscriptionInfo, type SubscriptionStatus, useCheckout, useSolvaPay, useSubscription };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,84 +1,240 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Stripe } from '@stripe/stripe-js';
|
|
1
|
+
import React$1 from 'react';
|
|
2
|
+
import { PaymentIntent, Stripe } from '@stripe/stripe-js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* TypeScript type definitions for @solvapay/react
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface SubscriptionInfo {
|
|
9
|
+
reference: string;
|
|
10
|
+
planName: string;
|
|
11
|
+
agentName: string;
|
|
12
|
+
status: string;
|
|
13
|
+
startDate: string;
|
|
14
|
+
}
|
|
15
|
+
interface CustomerSubscriptionData {
|
|
16
|
+
customerRef?: string;
|
|
17
|
+
email?: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
subscriptions: SubscriptionInfo[];
|
|
20
|
+
}
|
|
21
|
+
interface PaymentIntentResult {
|
|
22
|
+
clientSecret: string;
|
|
23
|
+
publishableKey: string;
|
|
24
|
+
accountId?: string;
|
|
25
|
+
customerRef?: string;
|
|
26
|
+
}
|
|
27
|
+
interface SubscriptionStatus {
|
|
28
|
+
loading: boolean;
|
|
29
|
+
customerRef?: string;
|
|
30
|
+
email?: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
subscriptions: SubscriptionInfo[];
|
|
33
|
+
hasActiveSubscription: boolean;
|
|
34
|
+
hasPlan: (planName: string) => boolean;
|
|
35
|
+
}
|
|
36
|
+
interface SolvaPayContextValue {
|
|
37
|
+
subscription: SubscriptionStatus;
|
|
38
|
+
refetchSubscription: () => Promise<void>;
|
|
39
|
+
createPayment: (params: {
|
|
40
|
+
planRef: string;
|
|
41
|
+
customerRef: string;
|
|
42
|
+
}) => Promise<PaymentIntentResult>;
|
|
43
|
+
customerRef?: string;
|
|
44
|
+
updateCustomerRef?: (newCustomerRef: string) => void;
|
|
45
|
+
}
|
|
4
46
|
interface SolvaPayProviderProps {
|
|
47
|
+
createPayment: (params: {
|
|
48
|
+
planRef: string;
|
|
49
|
+
customerRef: string;
|
|
50
|
+
}) => Promise<PaymentIntentResult>;
|
|
51
|
+
checkSubscription: (customerRef: string) => Promise<CustomerSubscriptionData>;
|
|
52
|
+
customerRef?: string;
|
|
53
|
+
onCustomerRefUpdate?: (newCustomerRef: string) => void;
|
|
5
54
|
children: React.ReactNode;
|
|
6
|
-
|
|
7
|
-
|
|
55
|
+
}
|
|
56
|
+
interface PlanBadgeProps {
|
|
57
|
+
children?: (props: {
|
|
58
|
+
subscriptions: SubscriptionInfo[];
|
|
59
|
+
loading: boolean;
|
|
60
|
+
}) => React.ReactNode;
|
|
61
|
+
as?: React.ElementType;
|
|
62
|
+
className?: string | ((props: {
|
|
63
|
+
subscriptions: SubscriptionInfo[];
|
|
64
|
+
}) => string);
|
|
65
|
+
}
|
|
66
|
+
interface SubscriptionGateProps {
|
|
67
|
+
requirePlan?: string;
|
|
68
|
+
children: (props: {
|
|
69
|
+
hasAccess: boolean;
|
|
70
|
+
subscriptions: SubscriptionInfo[];
|
|
71
|
+
loading: boolean;
|
|
72
|
+
}) => React.ReactNode;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Error type for payment operations
|
|
76
|
+
*/
|
|
77
|
+
interface PaymentError extends Error {
|
|
78
|
+
code?: string;
|
|
79
|
+
type?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Payment form props with proper Stripe types
|
|
83
|
+
*/
|
|
84
|
+
interface PaymentFormProps {
|
|
85
|
+
/**
|
|
86
|
+
* Plan reference to checkout. PaymentForm handles the entire checkout flow internally
|
|
87
|
+
* including Stripe initialization and payment intent creation.
|
|
88
|
+
*/
|
|
8
89
|
planRef: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
90
|
+
onSuccess?: (paymentIntent: PaymentIntent) => void;
|
|
91
|
+
onError?: (error: Error) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Return URL after payment completion. Defaults to current page URL if not provided.
|
|
94
|
+
*/
|
|
95
|
+
returnUrl?: string;
|
|
96
|
+
submitButtonText?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Optional className for the form container (wraps form, messages, and cancel button)
|
|
99
|
+
*/
|
|
100
|
+
className?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Optional className for the submit button
|
|
103
|
+
*/
|
|
104
|
+
buttonClassName?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Text for the initial checkout button. If provided, shows a button first instead of
|
|
107
|
+
* auto-starting checkout.
|
|
108
|
+
*/
|
|
109
|
+
initialButtonText?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Text for the cancel button. Set to empty string to hide cancel button.
|
|
112
|
+
*/
|
|
113
|
+
cancelButtonText?: string;
|
|
12
114
|
}
|
|
115
|
+
|
|
13
116
|
/**
|
|
14
|
-
* SolvaPay
|
|
117
|
+
* SolvaPay Provider - Headless Context Provider
|
|
118
|
+
*
|
|
119
|
+
* Provides subscription state and payment methods to child components.
|
|
120
|
+
* This is a headless provider that manages state without rendering UI.
|
|
15
121
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```tsx
|
|
124
|
+
* <SolvaPayProvider
|
|
125
|
+
* customerRef={user?.id}
|
|
126
|
+
* createPayment={async ({ planRef, customerRef }) => {
|
|
127
|
+
* const res = await fetch('/api/payments/create', {
|
|
128
|
+
* method: 'POST',
|
|
129
|
+
* body: JSON.stringify({ planRef, customerRef })
|
|
130
|
+
* });
|
|
131
|
+
* return res.json();
|
|
132
|
+
* }}
|
|
133
|
+
* checkSubscription={async (customerRef) => {
|
|
134
|
+
* const res = await fetch(`/api/subscriptions/${customerRef}`);
|
|
135
|
+
* return res.json();
|
|
136
|
+
* }}
|
|
137
|
+
* >
|
|
138
|
+
* <App />
|
|
139
|
+
* </SolvaPayProvider>
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
declare const SolvaPayProvider: React$1.FC<SolvaPayProviderProps>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* SolvaPay Payment Form Component
|
|
18
146
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* 4. Wraps children in Stripe Elements provider
|
|
147
|
+
* Handles the entire checkout flow internally including Stripe initialization,
|
|
148
|
+
* payment intent creation, and form rendering. Simply provide a planRef and
|
|
149
|
+
* handle success/error callbacks.
|
|
23
150
|
*
|
|
24
151
|
* @example
|
|
25
152
|
* ```tsx
|
|
26
|
-
*
|
|
27
|
-
* import { SolvaPayProvider, PaymentForm } from '@solvapay/react';
|
|
153
|
+
* import { PaymentForm } from '@solvapay/react';
|
|
28
154
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* }}
|
|
39
|
-
* >
|
|
40
|
-
* <PaymentForm />
|
|
41
|
-
* </SolvaPayProvider>
|
|
42
|
-
* );
|
|
43
|
-
* }
|
|
155
|
+
* <PaymentForm
|
|
156
|
+
* planRef="pro_plan"
|
|
157
|
+
* onSuccess={(paymentIntent) => {
|
|
158
|
+
* console.log('Payment successful!');
|
|
159
|
+
* }}
|
|
160
|
+
* onError={(error) => {
|
|
161
|
+
* console.error('Payment failed:', error);
|
|
162
|
+
* }}
|
|
163
|
+
* />
|
|
44
164
|
* ```
|
|
45
165
|
*/
|
|
46
|
-
declare const
|
|
166
|
+
declare const PaymentForm: React$1.FC<PaymentFormProps>;
|
|
47
167
|
|
|
48
|
-
interface PaymentFormProps {
|
|
49
|
-
onSuccess?: (paymentIntent: any) => void;
|
|
50
|
-
onError?: (error: Error) => void;
|
|
51
|
-
returnUrl?: string;
|
|
52
|
-
submitButtonText?: string;
|
|
53
|
-
className?: string;
|
|
54
|
-
}
|
|
55
168
|
/**
|
|
56
|
-
*
|
|
169
|
+
* Headless Plan Badge Component
|
|
57
170
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
171
|
+
* Displays subscription status with complete styling control.
|
|
172
|
+
* Supports render props, custom components, or className patterns.
|
|
60
173
|
*
|
|
61
174
|
* @example
|
|
62
175
|
* ```tsx
|
|
63
|
-
*
|
|
176
|
+
* // Render prop pattern
|
|
177
|
+
* <PlanBadge>
|
|
178
|
+
* {({ subscriptions, loading }) => (
|
|
179
|
+
* <div>
|
|
180
|
+
* {subscriptions.map(sub => <span key={sub.reference}>{sub.planName}</span>)}
|
|
181
|
+
* </div>
|
|
182
|
+
* )}
|
|
183
|
+
* </PlanBadge>
|
|
184
|
+
*
|
|
185
|
+
* //ClassName pattern
|
|
186
|
+
* <PlanBadge className="badge badge-primary" />
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
declare const PlanBadge: React$1.FC<PlanBadgeProps>;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Headless Subscription Gate Component
|
|
64
193
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* </SolvaPayProvider>
|
|
78
|
-
* );
|
|
79
|
-
* }
|
|
194
|
+
* Controls access to content based on subscription status.
|
|
195
|
+
* Uses render props to give developers full control over locked/unlocked states.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```tsx
|
|
199
|
+
* <SubscriptionGate requirePlan="Pro Plan">
|
|
200
|
+
* {({ hasAccess, loading }) => {
|
|
201
|
+
* if (loading) return <Skeleton />;
|
|
202
|
+
* if (!hasAccess) return <Paywall />;
|
|
203
|
+
* return <PremiumContent />;
|
|
204
|
+
* }}
|
|
205
|
+
* </SubscriptionGate>
|
|
80
206
|
* ```
|
|
81
207
|
*/
|
|
82
|
-
declare const
|
|
208
|
+
declare const SubscriptionGate: React$1.FC<SubscriptionGateProps>;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Hook to access subscription status
|
|
212
|
+
* Returns the current subscription state and a refetch function
|
|
213
|
+
*/
|
|
214
|
+
declare function useSubscription(): SubscriptionStatus & {
|
|
215
|
+
refetch: () => Promise<void>;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
interface UseCheckoutReturn {
|
|
219
|
+
loading: boolean;
|
|
220
|
+
error: Error | null;
|
|
221
|
+
stripePromise: Promise<Stripe | null> | null;
|
|
222
|
+
clientSecret: string | null;
|
|
223
|
+
startCheckout: () => Promise<void>;
|
|
224
|
+
reset: () => void;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Hook to manage checkout flow
|
|
228
|
+
* Handles payment intent creation and Stripe initialization
|
|
229
|
+
*
|
|
230
|
+
* @param planRef - The plan reference to checkout
|
|
231
|
+
*/
|
|
232
|
+
declare function useCheckout(planRef: string): UseCheckoutReturn;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Hook to access SolvaPay context
|
|
236
|
+
* Must be used within a SolvaPayProvider
|
|
237
|
+
*/
|
|
238
|
+
declare function useSolvaPay(): SolvaPayContextValue;
|
|
83
239
|
|
|
84
|
-
export { PaymentForm, type PaymentFormProps, SolvaPayProvider, type SolvaPayProviderProps };
|
|
240
|
+
export { type CustomerSubscriptionData, type PaymentError, PaymentForm, type PaymentFormProps, type PaymentIntentResult, PlanBadge, type PlanBadgeProps, type SolvaPayContextValue, SolvaPayProvider, type SolvaPayProviderProps, SubscriptionGate, type SubscriptionGateProps, type SubscriptionInfo, type SubscriptionStatus, useCheckout, useSolvaPay, useSubscription };
|