@funnelsgrove/payments 0.1.21 → 0.1.23
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/dist/components/ManageSubscriptionScreen.js +29 -1
- package/dist/providers/stripe/useStripeSubscriptionCheckoutSession.d.ts +2 -1
- package/dist/providers/stripe/useStripeSubscriptionCheckoutSession.js +7 -1
- package/dist/services/stripe.service.d.ts +4 -0
- package/dist/services/stripe.service.js +11 -0
- package/package.json +2 -2
|
@@ -231,9 +231,14 @@ function SubscriptionSection({ title, subscriptions, plans, onSelect, descriptio
|
|
|
231
231
|
: resolveBillingDateLabel(subscription, { past }) }), _jsxs("span", { children: ["Created at: ", resolveCreatedDate(subscription)] })] })] }) }, subscription.id))) })] }));
|
|
232
232
|
}
|
|
233
233
|
const manageSubscriptionStyles = `
|
|
234
|
+
.funnel-shell[data-preview-frame='true'] {
|
|
235
|
+
min-width: 0;
|
|
236
|
+
}
|
|
237
|
+
|
|
234
238
|
.manage-subscription {
|
|
235
239
|
position: absolute;
|
|
236
240
|
inset: 0;
|
|
241
|
+
max-width: 100%;
|
|
237
242
|
overflow-y: auto;
|
|
238
243
|
box-sizing: border-box;
|
|
239
244
|
background: color-mix(in srgb, var(--color-primary, #4db53f) 8%, var(--color-surface, #fff) 92%);
|
|
@@ -241,6 +246,17 @@ const manageSubscriptionStyles = `
|
|
|
241
246
|
font-family: var(--font-family-base, Inter, sans-serif);
|
|
242
247
|
}
|
|
243
248
|
|
|
249
|
+
.manage-subscription-inner,
|
|
250
|
+
.manage-subscription-section,
|
|
251
|
+
.manage-subscription-list,
|
|
252
|
+
.manage-subscription-row,
|
|
253
|
+
.manage-subscription-row-heading,
|
|
254
|
+
.manage-subscription-row-meta,
|
|
255
|
+
.manage-subscription-support {
|
|
256
|
+
min-width: 0;
|
|
257
|
+
max-width: 100%;
|
|
258
|
+
}
|
|
259
|
+
|
|
244
260
|
.manage-subscription-inner {
|
|
245
261
|
box-sizing: border-box;
|
|
246
262
|
min-height: 100%;
|
|
@@ -300,6 +316,7 @@ const manageSubscriptionStyles = `
|
|
|
300
316
|
border: 0;
|
|
301
317
|
border-left: 4px solid var(--color-primary, #4db53f);
|
|
302
318
|
border-radius: 6px;
|
|
319
|
+
box-sizing: border-box;
|
|
303
320
|
background: var(--color-surface, #fff);
|
|
304
321
|
color: var(--color-text, #262729);
|
|
305
322
|
display: grid;
|
|
@@ -343,9 +360,11 @@ const manageSubscriptionStyles = `
|
|
|
343
360
|
font-size: 15px;
|
|
344
361
|
line-height: 1.25;
|
|
345
362
|
font-weight: 800;
|
|
363
|
+
overflow-wrap: anywhere;
|
|
346
364
|
}
|
|
347
365
|
|
|
348
366
|
.manage-subscription-row-status {
|
|
367
|
+
flex-shrink: 0;
|
|
349
368
|
border-radius: 999px;
|
|
350
369
|
background: color-mix(in srgb, var(--color-warning, #f28100) 16%, var(--color-surface, #fff) 84%);
|
|
351
370
|
color: var(--color-warning, #f28100);
|
|
@@ -360,12 +379,13 @@ const manageSubscriptionStyles = `
|
|
|
360
379
|
font-size: 13px;
|
|
361
380
|
line-height: 1.2;
|
|
362
381
|
font-weight: 800;
|
|
382
|
+
overflow-wrap: anywhere;
|
|
363
383
|
}
|
|
364
384
|
|
|
365
385
|
.manage-subscription-row-meta {
|
|
366
386
|
width: 100%;
|
|
367
387
|
display: grid;
|
|
368
|
-
grid-template-columns: 1fr 1fr;
|
|
388
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
369
389
|
gap: 8px;
|
|
370
390
|
color: color-mix(in srgb, var(--color-text, #262729) 68%, transparent);
|
|
371
391
|
font-size: 11px;
|
|
@@ -373,6 +393,10 @@ const manageSubscriptionStyles = `
|
|
|
373
393
|
line-height: 1.3;
|
|
374
394
|
}
|
|
375
395
|
|
|
396
|
+
.manage-subscription-row-meta span {
|
|
397
|
+
overflow-wrap: anywhere;
|
|
398
|
+
}
|
|
399
|
+
|
|
376
400
|
.manage-subscription-row-meta .is-active-until {
|
|
377
401
|
color: var(--color-text, #262729);
|
|
378
402
|
font-weight: 800;
|
|
@@ -384,12 +408,14 @@ const manageSubscriptionStyles = `
|
|
|
384
408
|
font-size: 15px;
|
|
385
409
|
line-height: 1.35;
|
|
386
410
|
text-align: center;
|
|
411
|
+
overflow-wrap: anywhere;
|
|
387
412
|
}
|
|
388
413
|
|
|
389
414
|
.manage-subscription-support a {
|
|
390
415
|
color: var(--color-secondary, var(--color-primary, #4db53f));
|
|
391
416
|
text-decoration: underline;
|
|
392
417
|
text-underline-offset: 3px;
|
|
418
|
+
overflow-wrap: anywhere;
|
|
393
419
|
}
|
|
394
420
|
|
|
395
421
|
.manage-subscription-muted,
|
|
@@ -449,6 +475,7 @@ const manageSubscriptionStyles = `
|
|
|
449
475
|
min-height: 68px;
|
|
450
476
|
border: 0;
|
|
451
477
|
border-radius: 10px;
|
|
478
|
+
box-sizing: border-box;
|
|
452
479
|
background: var(--color-surface, #fff);
|
|
453
480
|
color: var(--color-text, #262729);
|
|
454
481
|
display: grid;
|
|
@@ -480,6 +507,7 @@ const manageSubscriptionStyles = `
|
|
|
480
507
|
min-height: 56px;
|
|
481
508
|
border: 0;
|
|
482
509
|
border-radius: 5px;
|
|
510
|
+
box-sizing: border-box;
|
|
483
511
|
background: var(--color-primary, #4db53f);
|
|
484
512
|
color: var(--color-primary-text, #fff);
|
|
485
513
|
font-size: 19px;
|
|
@@ -4,6 +4,7 @@ import { type CheckoutPreparationLoading } from '../paymentProvider.types.js';
|
|
|
4
4
|
import type { PaywallDisplayPlan } from '../../services/paywallOffer.service.js';
|
|
5
5
|
import { type PaywallPlan, type StripeRuntimeConfigOverrides } from '../../services/stripe.service.js';
|
|
6
6
|
export type StripeSubscriptionCheckoutSessionInput = {
|
|
7
|
+
analyticsMetadata?: Record<string, unknown> | null;
|
|
7
8
|
checkoutMode: RuntimeMode;
|
|
8
9
|
couponId?: string | null;
|
|
9
10
|
customerEmail?: string | null;
|
|
@@ -35,4 +36,4 @@ export type StripeSubscriptionCheckoutSession = {
|
|
|
35
36
|
updateCheckoutSessionPlan: () => Promise<boolean>;
|
|
36
37
|
};
|
|
37
38
|
export declare function isInactiveCheckoutSessionError(message?: string | null): boolean;
|
|
38
|
-
export declare function useStripeSubscriptionCheckoutSession({ checkoutMode, couponId, customerEmail, displayPlan, enabled, onError, plan, returnUrl, runtimeConfig, userId, }: StripeSubscriptionCheckoutSessionInput): StripeSubscriptionCheckoutSession;
|
|
39
|
+
export declare function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMetadata, couponId, customerEmail, displayPlan, enabled, onError, plan, returnUrl, runtimeConfig, userId, }: StripeSubscriptionCheckoutSessionInput): StripeSubscriptionCheckoutSession;
|
|
@@ -13,7 +13,7 @@ export function isInactiveCheckoutSessionError(message) {
|
|
|
13
13
|
var _a;
|
|
14
14
|
return /\bcheckout session\b.*\bno longer active\b/i.test((_a = message === null || message === void 0 ? void 0 : message.trim()) !== null && _a !== void 0 ? _a : '');
|
|
15
15
|
}
|
|
16
|
-
export function useStripeSubscriptionCheckoutSession({ checkoutMode, couponId, customerEmail, displayPlan, enabled = true, onError, plan, returnUrl, runtimeConfig, userId, }) {
|
|
16
|
+
export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMetadata, couponId, customerEmail, displayPlan, enabled = true, onError, plan, returnUrl, runtimeConfig, userId, }) {
|
|
17
17
|
var _a, _b, _c, _d, _e;
|
|
18
18
|
const [clientSecret, setClientSecret] = useState(null);
|
|
19
19
|
const [clientSecretIntentKey, setClientSecretIntentKey] = useState(null);
|
|
@@ -30,6 +30,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, couponId, c
|
|
|
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 analyticsMetadataSignature = JSON.stringify(analyticsMetadata !== null && analyticsMetadata !== void 0 ? analyticsMetadata : {});
|
|
33
34
|
const configured = enabled &&
|
|
34
35
|
(isStripeConfigured(checkoutMode) ||
|
|
35
36
|
Boolean(normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelSdkPublishableKey)));
|
|
@@ -37,6 +38,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, couponId, c
|
|
|
37
38
|
'stripe',
|
|
38
39
|
checkoutMode,
|
|
39
40
|
runtimeConfigSignature,
|
|
41
|
+
analyticsMetadataSignature,
|
|
40
42
|
(couponId === null || couponId === void 0 ? void 0 : couponId.trim()) || '',
|
|
41
43
|
returnUrl.trim(),
|
|
42
44
|
].join('|');
|
|
@@ -106,6 +108,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, couponId, c
|
|
|
106
108
|
try {
|
|
107
109
|
const response = await createStripeSubscriptionCheckout({
|
|
108
110
|
plan,
|
|
111
|
+
analyticsMetadata,
|
|
109
112
|
couponId,
|
|
110
113
|
customerEmail,
|
|
111
114
|
returnUrl,
|
|
@@ -149,6 +152,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, couponId, c
|
|
|
149
152
|
return subscriptionRequest;
|
|
150
153
|
}, [
|
|
151
154
|
activeClientSecret,
|
|
155
|
+
analyticsMetadata,
|
|
152
156
|
checkoutMode,
|
|
153
157
|
clearActiveCheckoutSession,
|
|
154
158
|
configured,
|
|
@@ -203,6 +207,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, couponId, c
|
|
|
203
207
|
await updateStripeSubscriptionCheckoutPlan({
|
|
204
208
|
checkoutSessionId: activeCheckoutSessionId,
|
|
205
209
|
plan,
|
|
210
|
+
analyticsMetadata,
|
|
206
211
|
couponId,
|
|
207
212
|
customerEmail,
|
|
208
213
|
user_id: userId,
|
|
@@ -219,6 +224,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, couponId, c
|
|
|
219
224
|
}, [
|
|
220
225
|
activeCheckoutSessionId,
|
|
221
226
|
activePlanKey,
|
|
227
|
+
analyticsMetadata,
|
|
222
228
|
checkoutMode,
|
|
223
229
|
configured,
|
|
224
230
|
couponId,
|
|
@@ -54,6 +54,7 @@ type CreatePaymentIntentInput = {
|
|
|
54
54
|
planId: string;
|
|
55
55
|
amountCents: number;
|
|
56
56
|
couponId?: string | null;
|
|
57
|
+
analyticsMetadata?: Record<string, unknown> | null;
|
|
57
58
|
user_id?: string | null;
|
|
58
59
|
environment?: RuntimeMode;
|
|
59
60
|
runtimeConfig?: StripeRuntimeConfigOverrides;
|
|
@@ -67,6 +68,7 @@ export declare function createStripePaymentIntent(input: CreatePaymentIntentInpu
|
|
|
67
68
|
type CreateSubscriptionCheckoutInput = {
|
|
68
69
|
plan: CheckoutSessionPlanInput;
|
|
69
70
|
couponId?: string | null;
|
|
71
|
+
analyticsMetadata?: Record<string, unknown> | null;
|
|
70
72
|
customerEmail?: string | null;
|
|
71
73
|
returnUrl: string;
|
|
72
74
|
user_id?: string | null;
|
|
@@ -84,6 +86,7 @@ type UpdateSubscriptionCheckoutPlanInput = {
|
|
|
84
86
|
checkoutSessionId: string;
|
|
85
87
|
plan: CheckoutSessionPlanInput;
|
|
86
88
|
couponId?: string | null;
|
|
89
|
+
analyticsMetadata?: Record<string, unknown> | null;
|
|
87
90
|
customerEmail?: string | null;
|
|
88
91
|
user_id?: string | null;
|
|
89
92
|
environment?: RuntimeMode;
|
|
@@ -100,6 +103,7 @@ type CreateCheckoutSessionInput = {
|
|
|
100
103
|
successUrl: string;
|
|
101
104
|
cancelUrl: string;
|
|
102
105
|
couponId?: string | null;
|
|
106
|
+
analyticsMetadata?: Record<string, unknown> | null;
|
|
103
107
|
customerEmail?: string | null;
|
|
104
108
|
user_id?: string | null;
|
|
105
109
|
environment?: RuntimeMode;
|
|
@@ -527,6 +527,13 @@ export const resolveCheckoutPlanRecurringConfig = (plan) => {
|
|
|
527
527
|
inferCheckoutPlanRecurringFromText(plan.id) ||
|
|
528
528
|
inferCheckoutPlanRecurringFromText(plan.description));
|
|
529
529
|
};
|
|
530
|
+
const normalizeAnalyticsMetadata = (metadata) => {
|
|
531
|
+
if (!metadata || !isRecord(metadata)) {
|
|
532
|
+
return undefined;
|
|
533
|
+
}
|
|
534
|
+
const normalized = Object.fromEntries(Object.entries(metadata).filter(([, value]) => value !== undefined && value !== null && value !== ''));
|
|
535
|
+
return Object.keys(normalized).length > 0 ? normalized : undefined;
|
|
536
|
+
};
|
|
530
537
|
export async function createStripePaymentIntent(input) {
|
|
531
538
|
var _a, _b;
|
|
532
539
|
const runtimeConfig = resolveStripeRuntimeConfig(input.runtimeConfig);
|
|
@@ -542,6 +549,7 @@ export async function createStripePaymentIntent(input) {
|
|
|
542
549
|
planId: input.planId,
|
|
543
550
|
amountCents: input.amountCents,
|
|
544
551
|
couponId: ((_a = input.couponId) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
|
|
552
|
+
analyticsMetadata: normalizeAnalyticsMetadata(input.analyticsMetadata),
|
|
545
553
|
user_id: ((_b = input.user_id) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
|
|
546
554
|
environment: input.environment || undefined,
|
|
547
555
|
}),
|
|
@@ -576,6 +584,7 @@ export async function createStripeSubscriptionCheckout(input) {
|
|
|
576
584
|
billingInterval: recurring.interval,
|
|
577
585
|
billingIntervalCount: recurring.intervalCount,
|
|
578
586
|
couponId: ((_c = input.couponId) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
|
|
587
|
+
analyticsMetadata: normalizeAnalyticsMetadata(input.analyticsMetadata),
|
|
579
588
|
customerEmail: ((_d = input.customerEmail) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
|
|
580
589
|
returnUrl: input.returnUrl,
|
|
581
590
|
user_id: ((_e = input.user_id) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
|
|
@@ -613,6 +622,7 @@ export async function updateStripeSubscriptionCheckoutPlan(input) {
|
|
|
613
622
|
billingInterval: recurring.interval,
|
|
614
623
|
billingIntervalCount: recurring.intervalCount,
|
|
615
624
|
couponId: ((_c = input.couponId) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
|
|
625
|
+
analyticsMetadata: normalizeAnalyticsMetadata(input.analyticsMetadata),
|
|
616
626
|
customerEmail: ((_d = input.customerEmail) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
|
|
617
627
|
user_id: ((_e = input.user_id) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
|
|
618
628
|
environment: input.environment || undefined,
|
|
@@ -648,6 +658,7 @@ export async function createStripeCheckoutSession(input) {
|
|
|
648
658
|
billingInterval: recurring.interval,
|
|
649
659
|
billingIntervalCount: recurring.intervalCount,
|
|
650
660
|
couponId: ((_c = input.couponId) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
|
|
661
|
+
analyticsMetadata: normalizeAnalyticsMetadata(input.analyticsMetadata),
|
|
651
662
|
successUrl: input.successUrl,
|
|
652
663
|
cancelUrl: input.cancelUrl,
|
|
653
664
|
customerEmail: ((_d = input.customerEmail) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnelsgrove/payments",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test:run": "vitest run --passWithNoTests"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@funnelsgrove/runtime": "0.1.
|
|
29
|
+
"@funnelsgrove/runtime": "0.1.14",
|
|
30
30
|
"@stripe/react-stripe-js": "^5.6.0",
|
|
31
31
|
"@stripe/stripe-js": "^8.7.0",
|
|
32
32
|
"react": "19.2.3",
|