@solvapay/react 1.0.1-preview.3 → 1.0.1-preview.4

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 CHANGED
@@ -321,4 +321,5 @@ import type { PaymentFormProps, PurchaseStatus, PaymentIntentResult } from '@sol
321
321
 
322
322
  ## More Information
323
323
 
324
- See [`docs/guides/architecture.md`](../../docs/guides/architecture.md) for detailed architecture documentation.
324
+ See [`docs/contributing/architecture.md`](../../docs/contributing/architecture.md) for contributor
325
+ architecture documentation.
package/dist/index.cjs CHANGED
@@ -1096,7 +1096,7 @@ function usePlans(options) {
1096
1096
  setLoading(false);
1097
1097
  setError(null);
1098
1098
  if (autoSelectFirstPaidRef.current && processedPlans.length > 0) {
1099
- const firstPaidIndex = processedPlans.findIndex((plan) => plan.price && plan.price > 0);
1099
+ const firstPaidIndex = processedPlans.findIndex((plan) => plan.requiresPayment !== false);
1100
1100
  setSelectedPlanIndex(firstPaidIndex >= 0 ? firstPaidIndex : 0);
1101
1101
  }
1102
1102
  return;
@@ -1112,7 +1112,7 @@ function usePlans(options) {
1112
1112
  setPlans(processedPlans);
1113
1113
  setError(null);
1114
1114
  if (autoSelectFirstPaidRef.current && processedPlans.length > 0) {
1115
- const firstPaidIndex = processedPlans.findIndex((plan) => plan.price && plan.price > 0);
1115
+ const firstPaidIndex = processedPlans.findIndex((plan) => plan.requiresPayment !== false);
1116
1116
  setSelectedPlanIndex(firstPaidIndex >= 0 ? firstPaidIndex : 0);
1117
1117
  }
1118
1118
  } catch (err) {
@@ -1143,7 +1143,7 @@ function usePlans(options) {
1143
1143
  }
1144
1144
  setPlans(processedPlans);
1145
1145
  if (autoSelectFirstPaidRef.current && processedPlans.length > 0) {
1146
- const firstPaidIndex = processedPlans.findIndex((plan) => plan.price && plan.price > 0);
1146
+ const firstPaidIndex = processedPlans.findIndex((plan) => plan.requiresPayment !== false);
1147
1147
  setSelectedPlanIndex(firstPaidIndex >= 0 ? firstPaidIndex : 0);
1148
1148
  }
1149
1149
  } catch (err) {
@@ -1205,7 +1205,7 @@ var PricingSelector = ({
1205
1205
  const isPaidPlan = (0, import_react8.useCallback)(
1206
1206
  (planRef) => {
1207
1207
  const plan = plans.find((p) => p.reference === planRef);
1208
- return plan ? (plan.price ?? 0) > 0 && !plan.isFreeTier : true;
1208
+ return plan ? plan.requiresPayment !== false : true;
1209
1209
  },
1210
1210
  [plans]
1211
1211
  );
package/dist/index.d.cts CHANGED
@@ -218,15 +218,39 @@ interface PaymentError extends Error {
218
218
  type?: string;
219
219
  }
220
220
  /**
221
- * Plan interface for plans
221
+ * Plan returned by the SolvaPay API.
222
+ *
223
+ * All fields are optional except `reference` so the type stays compatible
224
+ * with partial JSON responses from custom fetcher functions.
222
225
  */
223
226
  interface Plan {
227
+ type?: 'recurring' | 'one-time' | 'usage-based';
228
+ id?: string;
224
229
  reference: string;
230
+ name?: string;
231
+ description?: string;
225
232
  price?: number;
226
233
  currency?: string;
234
+ currencySymbol?: string;
235
+ freeUnits?: number;
236
+ setupFee?: number;
237
+ trialDays?: number;
238
+ billingCycle?: string;
239
+ billingModel?: 'pre-paid' | 'post-paid';
240
+ pricePerUnit?: number;
241
+ measures?: string;
242
+ limit?: number;
243
+ rolloverUnusedUnits?: boolean;
244
+ limits?: Record<string, unknown>;
245
+ features?: Record<string, unknown> | string[];
246
+ requiresPayment?: boolean;
247
+ isActive?: boolean;
248
+ maxActiveUsers?: number;
249
+ accessExpiryDays?: number;
250
+ status?: string;
251
+ createdAt?: string;
252
+ updatedAt?: string;
227
253
  interval?: string;
228
- features?: string[];
229
- isFreeTier?: boolean;
230
254
  metadata?: Record<string, unknown>;
231
255
  }
232
256
  /**
package/dist/index.d.ts CHANGED
@@ -218,15 +218,39 @@ interface PaymentError extends Error {
218
218
  type?: string;
219
219
  }
220
220
  /**
221
- * Plan interface for plans
221
+ * Plan returned by the SolvaPay API.
222
+ *
223
+ * All fields are optional except `reference` so the type stays compatible
224
+ * with partial JSON responses from custom fetcher functions.
222
225
  */
223
226
  interface Plan {
227
+ type?: 'recurring' | 'one-time' | 'usage-based';
228
+ id?: string;
224
229
  reference: string;
230
+ name?: string;
231
+ description?: string;
225
232
  price?: number;
226
233
  currency?: string;
234
+ currencySymbol?: string;
235
+ freeUnits?: number;
236
+ setupFee?: number;
237
+ trialDays?: number;
238
+ billingCycle?: string;
239
+ billingModel?: 'pre-paid' | 'post-paid';
240
+ pricePerUnit?: number;
241
+ measures?: string;
242
+ limit?: number;
243
+ rolloverUnusedUnits?: boolean;
244
+ limits?: Record<string, unknown>;
245
+ features?: Record<string, unknown> | string[];
246
+ requiresPayment?: boolean;
247
+ isActive?: boolean;
248
+ maxActiveUsers?: number;
249
+ accessExpiryDays?: number;
250
+ status?: string;
251
+ createdAt?: string;
252
+ updatedAt?: string;
227
253
  interval?: string;
228
- features?: string[];
229
- isFreeTier?: boolean;
230
254
  metadata?: Record<string, unknown>;
231
255
  }
232
256
  /**
package/dist/index.js CHANGED
@@ -1021,7 +1021,7 @@ function usePlans(options) {
1021
1021
  setLoading(false);
1022
1022
  setError(null);
1023
1023
  if (autoSelectFirstPaidRef.current && processedPlans.length > 0) {
1024
- const firstPaidIndex = processedPlans.findIndex((plan) => plan.price && plan.price > 0);
1024
+ const firstPaidIndex = processedPlans.findIndex((plan) => plan.requiresPayment !== false);
1025
1025
  setSelectedPlanIndex(firstPaidIndex >= 0 ? firstPaidIndex : 0);
1026
1026
  }
1027
1027
  return;
@@ -1037,7 +1037,7 @@ function usePlans(options) {
1037
1037
  setPlans(processedPlans);
1038
1038
  setError(null);
1039
1039
  if (autoSelectFirstPaidRef.current && processedPlans.length > 0) {
1040
- const firstPaidIndex = processedPlans.findIndex((plan) => plan.price && plan.price > 0);
1040
+ const firstPaidIndex = processedPlans.findIndex((plan) => plan.requiresPayment !== false);
1041
1041
  setSelectedPlanIndex(firstPaidIndex >= 0 ? firstPaidIndex : 0);
1042
1042
  }
1043
1043
  } catch (err) {
@@ -1068,7 +1068,7 @@ function usePlans(options) {
1068
1068
  }
1069
1069
  setPlans(processedPlans);
1070
1070
  if (autoSelectFirstPaidRef.current && processedPlans.length > 0) {
1071
- const firstPaidIndex = processedPlans.findIndex((plan) => plan.price && plan.price > 0);
1071
+ const firstPaidIndex = processedPlans.findIndex((plan) => plan.requiresPayment !== false);
1072
1072
  setSelectedPlanIndex(firstPaidIndex >= 0 ? firstPaidIndex : 0);
1073
1073
  }
1074
1074
  } catch (err) {
@@ -1130,7 +1130,7 @@ var PricingSelector = ({
1130
1130
  const isPaidPlan = useCallback5(
1131
1131
  (planRef) => {
1132
1132
  const plan = plans.find((p) => p.reference === planRef);
1133
- return plan ? (plan.price ?? 0) > 0 && !plan.isFreeTier : true;
1133
+ return plan ? plan.requiresPayment !== false : true;
1134
1134
  },
1135
1135
  [plans]
1136
1136
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solvapay/react",
3
- "version": "1.0.1-preview.3",
3
+ "version": "1.0.1-preview.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -51,7 +51,7 @@
51
51
  "react-dom": "^19.2.4",
52
52
  "typescript": "^5.9.3",
53
53
  "vitest": "^4.1.2",
54
- "@solvapay/server": "1.0.1-preview.3",
54
+ "@solvapay/server": "1.0.1-preview.4",
55
55
  "@solvapay/test-utils": "0.0.0"
56
56
  },
57
57
  "scripts": {