@solvapay/react 1.0.8-preview.8 → 1.0.8-preview.9

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 (99) hide show
  1. package/dist/index.cjs +2 -6
  2. package/dist/index.js +2 -6
  3. package/package.json +2 -2
  4. package/dist/CancelPlanButton-BKH_yv1d.d.ts +0 -1113
  5. package/dist/CancelPlanButton-Bb7cvym9.d.cts +0 -1105
  6. package/dist/CancelPlanButton-Cq117t7h.d.ts +0 -1105
  7. package/dist/CancelPlanButton-DQXUTHmF.d.cts +0 -1113
  8. package/dist/PaymentForm-B5dw0i1X.d.ts +0 -934
  9. package/dist/PaymentForm-CesoRQWu.d.cts +0 -934
  10. package/dist/chunk-5FZBOPIW.js +0 -4763
  11. package/dist/chunk-C7SKOENW.js +0 -1889
  12. package/dist/chunk-ISYAH4ZL.js +0 -1889
  13. package/dist/chunk-Q7GPX6X4.js +0 -4748
  14. package/dist/chunk-TP4JPKE2.js +0 -3126
  15. package/dist/chunk-VTGIXJQU.js +0 -4755
  16. package/dist/chunk-XMQ4GBWQ.js +0 -4752
  17. package/dist/index-DLl3UwO3.d.ts +0 -798
  18. package/dist/index-Sj2lHLl8.d.cts +0 -798
  19. package/dist/src/PaymentForm.d.ts +0 -56
  20. package/dist/src/PaymentForm.d.ts.map +0 -1
  21. package/dist/src/PaymentForm.js +0 -212
  22. package/dist/src/PaymentForm.js.map +0 -1
  23. package/dist/src/SolvaPayProvider.d.ts +0 -84
  24. package/dist/src/SolvaPayProvider.d.ts.map +0 -1
  25. package/dist/src/SolvaPayProvider.js +0 -537
  26. package/dist/src/SolvaPayProvider.js.map +0 -1
  27. package/dist/src/adapters/auth.d.ts +0 -43
  28. package/dist/src/adapters/auth.d.ts.map +0 -1
  29. package/dist/src/adapters/auth.js +0 -38
  30. package/dist/src/adapters/auth.js.map +0 -1
  31. package/dist/src/components/PlanBadge.d.ts +0 -31
  32. package/dist/src/components/PlanBadge.d.ts.map +0 -1
  33. package/dist/src/components/PlanBadge.js +0 -119
  34. package/dist/src/components/PlanBadge.js.map +0 -1
  35. package/dist/src/components/PlanSelector.d.ts +0 -49
  36. package/dist/src/components/PlanSelector.d.ts.map +0 -1
  37. package/dist/src/components/PlanSelector.js +0 -82
  38. package/dist/src/components/PlanSelector.js.map +0 -1
  39. package/dist/src/components/Spinner.d.ts +0 -10
  40. package/dist/src/components/Spinner.d.ts.map +0 -1
  41. package/dist/src/components/Spinner.js +0 -14
  42. package/dist/src/components/Spinner.js.map +0 -1
  43. package/dist/src/components/StripePaymentFormWrapper.d.ts +0 -17
  44. package/dist/src/components/StripePaymentFormWrapper.d.ts.map +0 -1
  45. package/dist/src/components/StripePaymentFormWrapper.js +0 -158
  46. package/dist/src/components/StripePaymentFormWrapper.js.map +0 -1
  47. package/dist/src/components/SubscriptionGate.d.ts +0 -21
  48. package/dist/src/components/SubscriptionGate.d.ts.map +0 -1
  49. package/dist/src/components/SubscriptionGate.js +0 -32
  50. package/dist/src/components/SubscriptionGate.js.map +0 -1
  51. package/dist/src/hooks/__tests__/useSubscription.test.d.ts +0 -2
  52. package/dist/src/hooks/__tests__/useSubscription.test.d.ts.map +0 -1
  53. package/dist/src/hooks/__tests__/useSubscription.test.js +0 -554
  54. package/dist/src/hooks/__tests__/useSubscription.test.js.map +0 -1
  55. package/dist/src/hooks/__tests__/useSubscriptionStatus.test.d.ts +0 -2
  56. package/dist/src/hooks/__tests__/useSubscriptionStatus.test.d.ts.map +0 -1
  57. package/dist/src/hooks/__tests__/useSubscriptionStatus.test.js +0 -719
  58. package/dist/src/hooks/__tests__/useSubscriptionStatus.test.js.map +0 -1
  59. package/dist/src/hooks/useCheckout.d.ts +0 -59
  60. package/dist/src/hooks/useCheckout.d.ts.map +0 -1
  61. package/dist/src/hooks/useCheckout.js +0 -138
  62. package/dist/src/hooks/useCheckout.js.map +0 -1
  63. package/dist/src/hooks/useCustomer.d.ts +0 -43
  64. package/dist/src/hooks/useCustomer.d.ts.map +0 -1
  65. package/dist/src/hooks/useCustomer.js +0 -31
  66. package/dist/src/hooks/useCustomer.js.map +0 -1
  67. package/dist/src/hooks/usePlans.d.ts +0 -28
  68. package/dist/src/hooks/usePlans.d.ts.map +0 -1
  69. package/dist/src/hooks/usePlans.js +0 -181
  70. package/dist/src/hooks/usePlans.js.map +0 -1
  71. package/dist/src/hooks/useSolvaPay.d.ts +0 -44
  72. package/dist/src/hooks/useSolvaPay.d.ts.map +0 -1
  73. package/dist/src/hooks/useSolvaPay.js +0 -52
  74. package/dist/src/hooks/useSolvaPay.js.map +0 -1
  75. package/dist/src/hooks/useSubscription.d.ts +0 -46
  76. package/dist/src/hooks/useSubscription.d.ts.map +0 -1
  77. package/dist/src/hooks/useSubscription.js +0 -50
  78. package/dist/src/hooks/useSubscription.js.map +0 -1
  79. package/dist/src/hooks/useSubscriptionStatus.d.ts +0 -19
  80. package/dist/src/hooks/useSubscriptionStatus.d.ts.map +0 -1
  81. package/dist/src/hooks/useSubscriptionStatus.js +0 -68
  82. package/dist/src/hooks/useSubscriptionStatus.js.map +0 -1
  83. package/dist/src/index.d.ts +0 -24
  84. package/dist/src/index.d.ts.map +0 -1
  85. package/dist/src/index.js +0 -26
  86. package/dist/src/index.js.map +0 -1
  87. package/dist/src/types/index.d.ts +0 -339
  88. package/dist/src/types/index.d.ts.map +0 -1
  89. package/dist/src/types/index.js +0 -5
  90. package/dist/src/types/index.js.map +0 -1
  91. package/dist/src/utils/__tests__/subscriptions.test.d.ts +0 -2
  92. package/dist/src/utils/__tests__/subscriptions.test.d.ts.map +0 -1
  93. package/dist/src/utils/__tests__/subscriptions.test.js +0 -121
  94. package/dist/src/utils/__tests__/subscriptions.test.js.map +0 -1
  95. package/dist/src/utils/subscriptions.d.ts +0 -57
  96. package/dist/src/utils/subscriptions.d.ts.map +0 -1
  97. package/dist/src/utils/subscriptions.js +0 -85
  98. package/dist/src/utils/subscriptions.js.map +0 -1
  99. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,56 +0,0 @@
1
- import React from 'react';
2
- import type { PaymentFormProps } from './types';
3
- /**
4
- * Payment form component for handling Stripe checkout.
5
- *
6
- * This component provides a complete payment form with Stripe integration,
7
- * including card input, plan selection, and payment processing. It handles
8
- * the entire checkout flow including payment intent creation and confirmation.
9
- *
10
- * Features:
11
- * - Automatic Stripe Elements initialization
12
- * - Payment intent creation on mount
13
- * - Card input and validation
14
- * - Payment processing with error handling
15
- * - Automatic subscription refresh after payment
16
- *
17
- * @param props - Payment form configuration
18
- * @param props.planRef - Plan reference to subscribe to (required)
19
- * @param props.agentRef - Agent reference for usage tracking (required)
20
- * @param props.onSuccess - Callback when payment succeeds
21
- * @param props.onError - Callback when payment fails
22
- * @param props.returnUrl - Optional return URL after payment (for redirects)
23
- * @param props.submitButtonText - Custom text for submit button (default: 'Pay Now')
24
- * @param props.className - Custom CSS class for the form container
25
- * @param props.buttonClassName - Custom CSS class for the submit button
26
- *
27
- * @example
28
- * ```tsx
29
- * import { PaymentForm } from '@solvapay/react';
30
- * import { useRouter } from 'next/navigation';
31
- *
32
- * function CheckoutPage() {
33
- * const router = useRouter();
34
- *
35
- * return (
36
- * <PaymentForm
37
- * planRef="pln_premium"
38
- * agentRef="agt_myapi"
39
- * onSuccess={() => {
40
- * console.log('Payment successful!');
41
- * router.push('/dashboard');
42
- * }}
43
- * onError={(error) => {
44
- * console.error('Payment failed:', error);
45
- * }}
46
- * />
47
- * );
48
- * }
49
- * ```
50
- *
51
- * @see {@link useCheckout} for programmatic checkout handling
52
- * @see {@link SolvaPayProvider} for required context provider
53
- * @since 1.0.0
54
- */
55
- export declare const PaymentForm: React.FC<PaymentFormProps>;
56
- //# sourceMappingURL=PaymentForm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaymentForm.d.ts","sourceRoot":"","sources":["../../src/PaymentForm.tsx"],"names":[],"mappings":"AACA,OAAO,KAA4D,MAAM,OAAO,CAAA;AAQhF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA6NlD,CAAA"}
@@ -1,212 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useEffect, useCallback, useRef, useMemo, useState } from 'react';
4
- import { Elements } from '@stripe/react-stripe-js';
5
- import { useCheckout } from './hooks/useCheckout';
6
- import { useSubscription } from './hooks/useSubscription';
7
- import { useSolvaPay } from './hooks/useSolvaPay';
8
- import { useCustomer } from './hooks/useCustomer';
9
- import { Spinner } from './components/Spinner';
10
- import { StripePaymentFormWrapper } from './components/StripePaymentFormWrapper';
11
- /**
12
- * Payment form component for handling Stripe checkout.
13
- *
14
- * This component provides a complete payment form with Stripe integration,
15
- * including card input, plan selection, and payment processing. It handles
16
- * the entire checkout flow including payment intent creation and confirmation.
17
- *
18
- * Features:
19
- * - Automatic Stripe Elements initialization
20
- * - Payment intent creation on mount
21
- * - Card input and validation
22
- * - Payment processing with error handling
23
- * - Automatic subscription refresh after payment
24
- *
25
- * @param props - Payment form configuration
26
- * @param props.planRef - Plan reference to subscribe to (required)
27
- * @param props.agentRef - Agent reference for usage tracking (required)
28
- * @param props.onSuccess - Callback when payment succeeds
29
- * @param props.onError - Callback when payment fails
30
- * @param props.returnUrl - Optional return URL after payment (for redirects)
31
- * @param props.submitButtonText - Custom text for submit button (default: 'Pay Now')
32
- * @param props.className - Custom CSS class for the form container
33
- * @param props.buttonClassName - Custom CSS class for the submit button
34
- *
35
- * @example
36
- * ```tsx
37
- * import { PaymentForm } from '@solvapay/react';
38
- * import { useRouter } from 'next/navigation';
39
- *
40
- * function CheckoutPage() {
41
- * const router = useRouter();
42
- *
43
- * return (
44
- * <PaymentForm
45
- * planRef="pln_premium"
46
- * agentRef="agt_myapi"
47
- * onSuccess={() => {
48
- * console.log('Payment successful!');
49
- * router.push('/dashboard');
50
- * }}
51
- * onError={(error) => {
52
- * console.error('Payment failed:', error);
53
- * }}
54
- * />
55
- * );
56
- * }
57
- * ```
58
- *
59
- * @see {@link useCheckout} for programmatic checkout handling
60
- * @see {@link SolvaPayProvider} for required context provider
61
- * @since 1.0.0
62
- */
63
- export const PaymentForm = ({ planRef, agentRef, onSuccess, onError, returnUrl, submitButtonText = 'Pay Now', className, buttonClassName, }) => {
64
- // CRITICAL: Always call hooks unconditionally FIRST, before any early returns
65
- // Use a safe fallback for planRef to ensure hooks always receive valid input
66
- const validPlanRef = planRef && typeof planRef === 'string' ? planRef : '';
67
- const checkout = useCheckout(validPlanRef, agentRef);
68
- const { refetch } = useSubscription();
69
- const { processPayment, customerRef } = useSolvaPay();
70
- const customer = useCustomer();
71
- const hasInitializedRef = useRef(false);
72
- // Auto-start checkout on mount - only once
73
- useEffect(() => {
74
- if (!hasInitializedRef.current &&
75
- validPlanRef &&
76
- !checkout.loading &&
77
- !checkout.error &&
78
- !checkout.clientSecret) {
79
- hasInitializedRef.current = true;
80
- checkout.startCheckout().catch(() => {
81
- // Error handled by useCheckout hook
82
- hasInitializedRef.current = false; // Allow retry on error
83
- });
84
- }
85
- // Reset initialization flag if planRef changes
86
- if (validPlanRef && checkout.clientSecret) {
87
- hasInitializedRef.current = true;
88
- }
89
- }, [
90
- validPlanRef,
91
- checkout.loading,
92
- checkout.error,
93
- checkout.clientSecret,
94
- checkout.startCheckout,
95
- ]);
96
- // Handle successful payment
97
- const handleSuccess = useCallback(async (paymentIntent) => {
98
- let processingTimeout = false;
99
- let processingResult = null;
100
- // Process payment if we have the necessary data (customerRef is handled internally)
101
- if (processPayment && agentRef) {
102
- try {
103
- const result = await processPayment({
104
- paymentIntentId: paymentIntent.id,
105
- agentRef: agentRef,
106
- planRef: planRef,
107
- });
108
- processingResult = result;
109
- // Check if the result indicates a timeout
110
- // The API can return status: 'timeout' even though TypeScript types say 'completed'
111
- const isTimeout = result?.status === 'timeout';
112
- processingTimeout = isTimeout;
113
- if (isTimeout) {
114
- // Poll for subscription up to 5 times with increasing delays
115
- for (let attempt = 1; attempt <= 5; attempt++) {
116
- const delay = attempt * 1000; // 1s, 2s, 3s, 4s, 5s
117
- await new Promise(resolve => setTimeout(resolve, delay));
118
- await refetch();
119
- }
120
- // Call onSuccess with timeout info first (so CheckoutPage can show failure page)
121
- if (onSuccess) {
122
- await onSuccess({
123
- ...paymentIntent,
124
- _processingTimeout: processingTimeout,
125
- _processingResult: processingResult,
126
- });
127
- }
128
- // Then throw error to signal timeout to StripePaymentFormWrapper
129
- // This will show error state in the form instead of success
130
- throw new Error('Payment processing timed out');
131
- }
132
- else {
133
- await refetch();
134
- }
135
- }
136
- catch (error) {
137
- console.error('[PaymentForm] Failed to process payment:', error);
138
- // Call onSuccess with error info so CheckoutPage can show failure page
139
- if (onSuccess) {
140
- try {
141
- await onSuccess({
142
- ...paymentIntent,
143
- _processingError: error,
144
- });
145
- }
146
- catch (callbackError) {
147
- // Ignore callback errors
148
- }
149
- }
150
- // Re-throw the error so StripePaymentFormWrapper can show error state
151
- throw error;
152
- }
153
- }
154
- else {
155
- // No processPayment available, refetch anyway (webhook might have processed)
156
- await refetch();
157
- }
158
- // Call onSuccess callback (only if we haven't already called it for timeout case)
159
- if (onSuccess && !processingTimeout) {
160
- await onSuccess({
161
- ...paymentIntent,
162
- _processingTimeout: processingTimeout,
163
- _processingResult: processingResult,
164
- });
165
- }
166
- }, [processPayment, agentRef, planRef, refetch, onSuccess]);
167
- // Handle payment error
168
- const handleError = useCallback((err) => {
169
- if (onError) {
170
- onError(err);
171
- }
172
- }, [onError]);
173
- // Auto-detect return URL if not provided
174
- const finalReturnUrl = returnUrl || (typeof window !== 'undefined' ? window.location.href : '/');
175
- // Validate planRef AFTER all hooks are called
176
- const isValidPlanRef = planRef && typeof planRef === 'string';
177
- // Determine render state
178
- const hasError = !!checkout.error;
179
- const hasStripeData = !!(checkout.stripePromise && checkout.clientSecret);
180
- // Memoize Elements options to maintain stable identity while clientSecret stays the same
181
- const elementsOptions = useMemo(() => {
182
- if (!checkout.clientSecret)
183
- return undefined;
184
- return { clientSecret: checkout.clientSecret };
185
- }, [checkout.clientSecret]);
186
- // Track if Elements has ever been mounted for this planRef to prevent unmounting
187
- // Reset when planRef changes (component will remount due to key prop)
188
- const [hasMountedElements, setHasMountedElements] = useState(false);
189
- // Update state when Stripe data becomes available
190
- useEffect(() => {
191
- if (hasStripeData) {
192
- setHasMountedElements(true);
193
- }
194
- }, [hasStripeData]);
195
- // Only mount Elements once we have both stripePromise and clientSecret
196
- // Once mounted, keep it mounted to maintain hook consistency
197
- const shouldRenderElements = hasStripeData || (hasMountedElements && checkout.stripePromise && checkout.clientSecret);
198
- // Always return the same JSX structure to maintain hook consistency
199
- // Once Elements is rendered, it should never unmount to avoid hook count issues
200
- return (_jsx("div", { className: className, children: !isValidPlanRef ? (_jsx("div", { children: "PaymentForm: planRef is required and must be a string" })) : hasError ? (_jsxs("div", { children: [_jsx("div", { children: "Payment initialization failed" }), _jsx("div", { children: checkout.error?.message || 'Unknown error' })] })) : shouldRenderElements && checkout.stripePromise && elementsOptions ? (
201
- // Once we have Stripe data, always render Elements to maintain hook consistency
202
- // This prevents hook count mismatches when transitioning between states
203
- _jsx(Elements, { stripe: checkout.stripePromise, options: elementsOptions, children: _jsx(StripePaymentFormWrapper, { onSuccess: handleSuccess, onError: handleError, returnUrl: finalReturnUrl, submitButtonText: submitButtonText, buttonClassName: buttonClassName, clientSecret: checkout.clientSecret }) }, checkout.clientSecret)) : (
204
- // Loading state before Stripe data is available
205
- _jsxs("div", { children: [_jsx("div", { style: {
206
- minHeight: '40px',
207
- display: 'flex',
208
- alignItems: 'center',
209
- justifyContent: 'center',
210
- }, children: _jsx(Spinner, { size: "md" }) }), _jsx("button", { type: "submit", disabled: true, className: buttonClassName, "aria-busy": "false", "aria-disabled": "true", children: submitButtonText })] })) }));
211
- };
212
- //# sourceMappingURL=P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ACjB,EACN,iBACE,IAAI,EAAC,QAAQ,EACb,QAAQ,QACR,SAAS,EAAE,eAAe,eAChB,OAAO,mBACH,MAAM,YAEnB,gBAAgB,GACV,IACL,CACP,GACG,CACP,CAAA;AACH,CAAC,CAAA"}
@@ -1,84 +0,0 @@
1
- import React from 'react';
2
- import type { SolvaPayProviderProps, SolvaPayContextValue } from './types';
3
- export declare const SolvaPayContext: React.Context<SolvaPayContextValue | null>;
4
- /**
5
- * SolvaPay Provider - Headless Context Provider for React.
6
- *
7
- * Provides subscription state, payment methods, and customer data to child components
8
- * via React Context. This is the root component that must wrap your app to use
9
- * SolvaPay React hooks and components.
10
- *
11
- * Features:
12
- * - Automatic subscription status checking
13
- * - Customer reference caching in localStorage
14
- * - Payment intent creation and processing
15
- * - Authentication adapter support (Supabase, custom, etc.)
16
- * - Zero-config with sensible defaults, or full customization
17
- *
18
- * @param props - Provider configuration
19
- * @param props.config - Configuration object for API routes and authentication
20
- * @param props.config.api - API route configuration (optional, uses defaults if not provided)
21
- * @param props.config.api.checkSubscription - Endpoint for checking subscription status (default: '/api/check-subscription')
22
- * @param props.config.api.createPayment - Endpoint for creating payment intents (default: '/api/create-payment-intent')
23
- * @param props.config.api.processPayment - Endpoint for processing payments (default: '/api/process-payment')
24
- * @param props.config.auth - Authentication configuration (optional)
25
- * @param props.config.auth.adapter - Auth adapter for extracting user ID and token
26
- * @param props.children - React children components
27
- *
28
- * @example
29
- * ```tsx
30
- * import { SolvaPayProvider } from '@solvapay/react';
31
- *
32
- * // Zero config (uses defaults)
33
- * function App() {
34
- * return (
35
- * <SolvaPayProvider>
36
- * <YourApp />
37
- * </SolvaPayProvider>
38
- * );
39
- * }
40
- *
41
- * // Custom API routes
42
- * function App() {
43
- * return (
44
- * <SolvaPayProvider
45
- * config={{
46
- * api: {
47
- * checkSubscription: '/custom/api/subscription',
48
- * createPayment: '/custom/api/payment'
49
- * }
50
- * }}
51
- * >
52
- * <YourApp />
53
- * </SolvaPayProvider>
54
- * );
55
- * }
56
- *
57
- * // With Supabase auth adapter
58
- * import { createSupabaseAuthAdapter } from '@solvapay/react-supabase';
59
- *
60
- * function App() {
61
- * const adapter = createSupabaseAuthAdapter({
62
- * supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
63
- * supabaseAnonKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
64
- * });
65
- *
66
- * return (
67
- * <SolvaPayProvider
68
- * config={{
69
- * auth: { adapter }
70
- * }}
71
- * >
72
- * <YourApp />
73
- * </SolvaPayProvider>
74
- * );
75
- * }
76
- * ```
77
- *
78
- * @see {@link useSubscription} for accessing subscription data
79
- * @see {@link useCheckout} for payment checkout flow
80
- * @see {@link useSolvaPay} for accessing provider methods
81
- * @since 1.0.0
82
- */
83
- export declare const SolvaPayProvider: React.FC<SolvaPayProviderProps>;
84
- //# sourceMappingURL=SolvaPayProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SolvaPayProvider.d.ts","sourceRoot":"","sources":["../../src/SolvaPayProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2E,MAAM,OAAO,CAAA;AAC/F,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EAKrB,MAAM,SAAS,CAAA;AAShB,eAAO,MAAM,eAAe,4CAAmD,CAAA;AAmG/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAoe5D,CAAA"}