@funnelsgrove/payments 0.1.29 → 0.1.30
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.
|
@@ -30,7 +30,8 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMe
|
|
|
30
30
|
normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelVersionId),
|
|
31
31
|
normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelSdkPublishableKey),
|
|
32
32
|
].join('|');
|
|
33
|
-
const
|
|
33
|
+
const customerEmailSignature = normalizeRuntimeConfigValue(customerEmail);
|
|
34
|
+
const userIdSignature = normalizeRuntimeConfigValue(userId);
|
|
34
35
|
const configured = enabled &&
|
|
35
36
|
(isStripeConfigured(checkoutMode) ||
|
|
36
37
|
Boolean(normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelSdkPublishableKey)));
|
|
@@ -38,7 +39,8 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMe
|
|
|
38
39
|
'stripe',
|
|
39
40
|
checkoutMode,
|
|
40
41
|
runtimeConfigSignature,
|
|
41
|
-
|
|
42
|
+
customerEmailSignature,
|
|
43
|
+
userIdSignature,
|
|
42
44
|
(couponId === null || couponId === void 0 ? void 0 : couponId.trim()) || '',
|
|
43
45
|
returnUrl.trim(),
|
|
44
46
|
].join('|');
|
|
@@ -14,6 +14,7 @@ export type PaywallPlan = {
|
|
|
14
14
|
perDayAmount: string;
|
|
15
15
|
perDayLabel: string;
|
|
16
16
|
amountCents: number;
|
|
17
|
+
analyticsPurchaseValue?: number;
|
|
17
18
|
comparison?: BillingFallbackPlanConfig['comparison'];
|
|
18
19
|
checkoutOriginalAmountCents?: number;
|
|
19
20
|
checkoutSummaryLabel?: string;
|
|
@@ -68,6 +68,17 @@ const asPositiveIntOrNull = (value) => {
|
|
|
68
68
|
}
|
|
69
69
|
return Math.round(numeric);
|
|
70
70
|
};
|
|
71
|
+
const asNonNegativeNumberOrNull = (value) => {
|
|
72
|
+
const numeric = typeof value === 'number'
|
|
73
|
+
? value
|
|
74
|
+
: typeof value === 'string' && value.trim()
|
|
75
|
+
? Number(value.trim())
|
|
76
|
+
: null;
|
|
77
|
+
if (numeric === null || !Number.isFinite(numeric) || numeric < 0) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return Math.round(numeric * 100) / 100;
|
|
81
|
+
};
|
|
71
82
|
const asBillingPlanIntervalOrNull = (value) => {
|
|
72
83
|
var _a;
|
|
73
84
|
const normalized = (_a = asTrimmedStringOrNull(value)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
@@ -230,6 +241,7 @@ const toRemoteProjectBillingPlan = (rawPlan) => {
|
|
|
230
241
|
};
|
|
231
242
|
};
|
|
232
243
|
const toPlanFromRemoteProjectPlan = (rawPlan, options, planIdOverride) => {
|
|
244
|
+
var _a;
|
|
233
245
|
const planId = (planIdOverride === null || planIdOverride === void 0 ? void 0 : planIdOverride.trim()) || rawPlan.id || rawPlan.key || rawPlan.providerPlanId;
|
|
234
246
|
if (!planId) {
|
|
235
247
|
return null;
|
|
@@ -266,6 +278,7 @@ const toPlanFromRemoteProjectPlan = (rawPlan, options, planIdOverride) => {
|
|
|
266
278
|
perDayAmount,
|
|
267
279
|
perDayLabel: 'per day',
|
|
268
280
|
amountCents: amountMinor,
|
|
281
|
+
analyticsPurchaseValue: (_a = asNonNegativeNumberOrNull(metadata.analyticsPurchaseValue)) !== null && _a !== void 0 ? _a : undefined,
|
|
269
282
|
comparison: intervalDays
|
|
270
283
|
? {
|
|
271
284
|
perDay: `${perDayAmount}/day`,
|