@funnelsgrove/payments 0.1.22 → 0.1.24

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.
@@ -238,18 +238,27 @@ const manageSubscriptionStyles = `
238
238
  .manage-subscription {
239
239
  position: absolute;
240
240
  inset: 0;
241
+ max-width: 100%;
241
242
  overflow-y: auto;
242
243
  box-sizing: border-box;
243
- max-width: 100%;
244
244
  background: color-mix(in srgb, var(--color-primary, #4db53f) 8%, var(--color-surface, #fff) 92%);
245
245
  color: var(--color-text, #262729);
246
246
  font-family: var(--font-family-base, Inter, sans-serif);
247
247
  }
248
248
 
249
- .manage-subscription-inner {
250
- box-sizing: border-box;
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 {
251
256
  min-width: 0;
252
257
  max-width: 100%;
258
+ }
259
+
260
+ .manage-subscription-inner {
261
+ box-sizing: border-box;
253
262
  min-height: 100%;
254
263
  padding: 22px 12px 32px;
255
264
  }
@@ -273,8 +282,6 @@ const manageSubscriptionStyles = `
273
282
  }
274
283
 
275
284
  .manage-subscription-section {
276
- min-width: 0;
277
- max-width: 100%;
278
285
  margin-top: 22px;
279
286
  }
280
287
 
@@ -301,18 +308,15 @@ const manageSubscriptionStyles = `
301
308
  display: grid;
302
309
  gap: 8px;
303
310
  list-style: none;
304
- min-width: 0;
305
- max-width: 100%;
306
311
  }
307
312
 
308
313
  .manage-subscription-row {
309
314
  width: 100%;
310
- min-width: 0;
311
- max-width: 100%;
312
315
  min-height: 118px;
313
316
  border: 0;
314
317
  border-left: 4px solid var(--color-primary, #4db53f);
315
318
  border-radius: 6px;
319
+ box-sizing: border-box;
316
320
  background: var(--color-surface, #fff);
317
321
  color: var(--color-text, #262729);
318
322
  display: grid;
@@ -346,8 +350,6 @@ const manageSubscriptionStyles = `
346
350
 
347
351
  .manage-subscription-row-heading {
348
352
  width: 100%;
349
- min-width: 0;
350
- max-width: 100%;
351
353
  display: flex;
352
354
  align-items: center;
353
355
  justify-content: space-between;
@@ -382,10 +384,8 @@ const manageSubscriptionStyles = `
382
384
 
383
385
  .manage-subscription-row-meta {
384
386
  width: 100%;
385
- min-width: 0;
386
- max-width: 100%;
387
387
  display: grid;
388
- grid-template-columns: 1fr 1fr;
388
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
389
389
  gap: 8px;
390
390
  color: color-mix(in srgb, var(--color-text, #262729) 68%, transparent);
391
391
  font-size: 11px;
@@ -403,8 +403,6 @@ const manageSubscriptionStyles = `
403
403
  }
404
404
 
405
405
  .manage-subscription-support {
406
- min-width: 0;
407
- max-width: 100%;
408
406
  margin: 30px 0 0;
409
407
  color: var(--color-text, #262729);
410
408
  font-size: 15px;
@@ -477,6 +475,7 @@ const manageSubscriptionStyles = `
477
475
  min-height: 68px;
478
476
  border: 0;
479
477
  border-radius: 10px;
478
+ box-sizing: border-box;
480
479
  background: var(--color-surface, #fff);
481
480
  color: var(--color-text, #262729);
482
481
  display: grid;
@@ -508,6 +507,7 @@ const manageSubscriptionStyles = `
508
507
  min-height: 56px;
509
508
  border: 0;
510
509
  border-radius: 5px;
510
+ box-sizing: border-box;
511
511
  background: var(--color-primary, #4db53f);
512
512
  color: var(--color-primary-text, #fff);
513
513
  font-size: 19px;
@@ -21,7 +21,7 @@ export type SharedStripeCheckoutDialogProps = {
21
21
  onCustomerEmailChange?: (value: string) => void;
22
22
  onCustomerEmailCommit?: (email: string) => Promise<string | null | void>;
23
23
  onError?: (message: string | null) => void;
24
- onSuccess?: () => void;
24
+ onSuccess?: () => void | Promise<void>;
25
25
  paymentMethodLabels?: readonly string[];
26
26
  poweredByLabel: string;
27
27
  processingLabel: string;
@@ -210,7 +210,7 @@ function SharedStripeCheckoutForm({ amountCents, clientSecret, closeAriaLabel, c
210
210
  }
211
211
  if (typeof window !== 'undefined' &&
212
212
  isSuccessfulIntentStatus((_a = result.paymentIntent) === null || _a === void 0 ? void 0 : _a.status)) {
213
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
213
+ await (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess());
214
214
  window.location.assign(returnUrl);
215
215
  return;
216
216
  }
@@ -22,7 +22,7 @@ export type SharedStripeCheckoutV2DialogProps = {
22
22
  onCustomerEmailCommit?: (email: string) => Promise<string | null | void>;
23
23
  onError?: (message: string | null) => void;
24
24
  onInactiveCheckoutSession?: () => void;
25
- onSuccess?: () => void;
25
+ onSuccess?: () => void | Promise<void>;
26
26
  paymentMethodLabels?: readonly string[];
27
27
  paypalButtonLabel: string;
28
28
  paypalLabel: string;
@@ -228,7 +228,7 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
228
228
  return;
229
229
  }
230
230
  if (typeof window !== 'undefined') {
231
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
231
+ await (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess());
232
232
  window.location.assign(returnUrl);
233
233
  return;
234
234
  }
@@ -15,6 +15,6 @@ export type StripeCheckoutExpressCheckoutButtonProps = {
15
15
  onServerUpdate?: () => Promise<boolean>;
16
16
  onAvailabilityChange?: (available: boolean) => void;
17
17
  onError?: (message: string | null) => void;
18
- onSuccess?: () => void;
18
+ onSuccess?: () => void | Promise<void>;
19
19
  };
20
20
  export declare function StripeCheckoutExpressCheckoutButton({ beforeConfirm, returnUrl, customerEmail, className, options, availabilityPaymentMethods, initialAvailable, keepInitialAvailableOnReady, serverUpdateKey, onServerUpdate, onAvailabilityChange, onError, onSuccess, }: StripeCheckoutExpressCheckoutButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -135,7 +135,7 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, returnUrl,
135
135
  }
136
136
  onError === null || onError === void 0 ? void 0 : onError(null);
137
137
  if (typeof window !== 'undefined') {
138
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
138
+ await (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess());
139
139
  window.location.assign(returnUrl);
140
140
  }
141
141
  };
@@ -13,6 +13,6 @@ export type StripeExpressCheckoutButtonProps = {
13
13
  keepInitialAvailableOnReady?: boolean;
14
14
  onAvailabilityChange?: (available: boolean) => void;
15
15
  onError?: (message: string | null) => void;
16
- onSuccess?: () => void;
16
+ onSuccess?: () => void | Promise<void>;
17
17
  };
18
18
  export declare function StripeExpressCheckoutButton({ amountCents, beforeConfirm, summaryLabel, returnUrl, customerEmail, customerName, className, options, availabilityPaymentMethods, initialAvailable, keepInitialAvailableOnReady, onAvailabilityChange, onError, onSuccess, }: StripeExpressCheckoutButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -129,7 +129,7 @@ export function StripeExpressCheckoutButton({ amountCents, beforeConfirm, summar
129
129
  onError === null || onError === void 0 ? void 0 : onError(null);
130
130
  if (typeof window !== 'undefined' &&
131
131
  isSuccessfulIntentStatus((_a = result.paymentIntent) === null || _a === void 0 ? void 0 : _a.status)) {
132
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
132
+ await (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess());
133
133
  window.location.assign(returnUrl);
134
134
  }
135
135
  };
@@ -18,7 +18,7 @@ export type WalletSubscriptionCheckoutSlotProps = {
18
18
  expressCheckoutAllowed?: boolean;
19
19
  onAvailabilityChange?: (available: boolean) => void;
20
20
  onError?: (message: string | null) => void;
21
- onSuccess?: () => void;
21
+ onSuccess?: () => void | Promise<void>;
22
22
  onUnavailableClick?: () => Promise<void> | void;
23
23
  options?: Partial<StripeCheckoutExpressCheckoutElementOptions>;
24
24
  placeholderLabel: string;
@@ -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.22",
3
+ "version": "0.1.24",
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.6",
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",