@funnelsgrove/payments 0.22.6 → 0.23.2

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 (32) hide show
  1. package/README.md +27 -0
  2. package/dist/components/CheckoutEmailDialog.js +12 -13
  3. package/dist/config/billing.config.d.ts +3 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +1 -0
  6. package/dist/providers/solidgate/components/SolidgateCheckoutDialog.d.ts +1 -1
  7. package/dist/providers/solidgate/components/SolidgateCheckoutDialog.js +19 -10
  8. package/dist/providers/solidgate/components/SolidgateCheckoutDialog.types.d.ts +3 -1
  9. package/dist/providers/stripe/components/StripeWalletSurface.internal.d.ts +2 -1
  10. package/dist/providers/stripe/components/StripeWalletSurface.internal.js +13 -33
  11. package/dist/providers/stripe/hooks/useStripeOneTimeCheckoutSession.d.ts +3 -1
  12. package/dist/providers/stripe/hooks/useStripeOneTimeCheckoutSession.js +29 -7
  13. package/dist/providers/stripe/hooks/useStripeSubscriptionCheckoutSession.d.ts +3 -1
  14. package/dist/providers/stripe/hooks/useStripeSubscriptionCheckoutSession.js +31 -9
  15. package/dist/providers/stripe/services/checkout/requests.d.ts +39 -29
  16. package/dist/providers/stripe/services/checkout/requests.js +12 -32
  17. package/dist/providers/stripe/services/checkoutCompletionAnalytics.service.d.ts +2 -1
  18. package/dist/providers/stripe/services/checkoutCompletionAnalytics.service.js +2 -2
  19. package/dist/providers/stripe/services/hostedCheckout/requests.d.ts +12 -10
  20. package/dist/providers/stripe/services/hostedCheckout/requests.js +4 -27
  21. package/dist/providers/stripe/services/oneClick/requests.d.ts +9 -8
  22. package/dist/providers/stripe/services/oneClick/requests.js +2 -20
  23. package/dist/providers/stripe/services/oneClick/types.d.ts +3 -1
  24. package/dist/services/checkoutObservability.service.d.ts +2 -1
  25. package/dist/services/checkoutObservability.service.js +1 -1
  26. package/dist/services/paywallOffer.service.js +19 -8
  27. package/dist/services/paywallPlans/types.d.ts +4 -2
  28. package/dist/services/publishedBillingRuntime.service.d.ts +23 -2
  29. package/dist/services/publishedBillingRuntime.service.js +38 -4
  30. package/dist/services/usePinnedPublishedBillingRuntime.d.ts +10 -0
  31. package/dist/services/usePinnedPublishedBillingRuntime.js +23 -0
  32. package/package.json +5 -5
@@ -3,6 +3,13 @@ export declare const toOneTimeCheckoutRequest: (input: CreateOneTimeCheckoutInpu
3
3
  environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
4
4
  runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
5
5
  checkoutIdentityToken: string;
6
+ couponId: string | undefined;
7
+ analyticsMetadata: Record<string, unknown> | undefined;
8
+ customerEmail: string | undefined;
9
+ returnUrl: string;
10
+ userId: string | undefined;
11
+ currency?: string | undefined;
12
+ money?: import("@funnelsgrove/runtime").ProviderMoney | undefined;
6
13
  planKey: string;
7
14
  runtimeConfigRevisionId: string | null | undefined;
8
15
  paymentProfileId: string | null | undefined;
@@ -16,15 +23,17 @@ export declare const toOneTimeCheckoutRequest: (input: CreateOneTimeCheckoutInpu
16
23
  title: string;
17
24
  description: string | undefined;
18
25
  amountCents: number;
26
+ } | {
27
+ environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
28
+ runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
29
+ checkoutIdentityToken?: undefined;
19
30
  couponId: string | undefined;
20
31
  analyticsMetadata: Record<string, unknown> | undefined;
21
32
  customerEmail: string | undefined;
22
33
  returnUrl: string;
23
34
  userId: string | undefined;
24
- } | {
25
- environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
26
- runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
27
- checkoutIdentityToken?: undefined;
35
+ currency?: string | undefined;
36
+ money?: import("@funnelsgrove/runtime").ProviderMoney | undefined;
28
37
  planKey: string;
29
38
  runtimeConfigRevisionId: string | null | undefined;
30
39
  paymentProfileId: string | null | undefined;
@@ -38,29 +47,11 @@ export declare const toOneTimeCheckoutRequest: (input: CreateOneTimeCheckoutInpu
38
47
  title: string;
39
48
  description: string | undefined;
40
49
  amountCents: number;
41
- couponId: string | undefined;
42
- analyticsMetadata: Record<string, unknown> | undefined;
43
- customerEmail: string | undefined;
44
- returnUrl: string;
45
- userId: string | undefined;
46
50
  };
47
51
  export declare const toSubscriptionCheckoutRequest: (input: CreateSubscriptionCheckoutInput) => {
48
52
  environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
49
53
  runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
50
54
  checkoutIdentityToken: string;
51
- offerSetId: string | undefined;
52
- offerSetKey: string | undefined;
53
- planId: string;
54
- planKey: string;
55
- providerPlanId: string | undefined;
56
- provider: "stripe" | null | undefined;
57
- paymentProfileId: string | undefined;
58
- runtimeConfigRevisionId: string | undefined;
59
- anonymousUserId: string | undefined;
60
- idempotencyKey: string | undefined;
61
- title: string;
62
- description: string | undefined;
63
- amountCents: number;
64
55
  billingInterval: import("../../../../index.js").BillingPlanInterval;
65
56
  billingIntervalCount: number;
66
57
  followUpProviderPlanId: string | undefined;
@@ -73,10 +64,8 @@ export declare const toSubscriptionCheckoutRequest: (input: CreateSubscriptionCh
73
64
  customerEmail: string | undefined;
74
65
  returnUrl: string;
75
66
  userId: string | undefined;
76
- } | {
77
- environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
78
- runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
79
- checkoutIdentityToken?: undefined;
67
+ currency?: string | undefined;
68
+ money?: import("@funnelsgrove/runtime").ProviderMoney | undefined;
80
69
  offerSetId: string | undefined;
81
70
  offerSetKey: string | undefined;
82
71
  planId: string;
@@ -90,6 +79,10 @@ export declare const toSubscriptionCheckoutRequest: (input: CreateSubscriptionCh
90
79
  title: string;
91
80
  description: string | undefined;
92
81
  amountCents: number;
82
+ } | {
83
+ environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
84
+ runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
85
+ checkoutIdentityToken?: undefined;
93
86
  billingInterval: import("../../../../index.js").BillingPlanInterval;
94
87
  billingIntervalCount: number;
95
88
  followUpProviderPlanId: string | undefined;
@@ -102,9 +95,8 @@ export declare const toSubscriptionCheckoutRequest: (input: CreateSubscriptionCh
102
95
  customerEmail: string | undefined;
103
96
  returnUrl: string;
104
97
  userId: string | undefined;
105
- };
106
- export declare const toSubscriptionCheckoutPlanRequest: (input: UpdateSubscriptionCheckoutPlanInput) => {
107
- checkoutSessionId: string;
98
+ currency?: string | undefined;
99
+ money?: import("@funnelsgrove/runtime").ProviderMoney | undefined;
108
100
  offerSetId: string | undefined;
109
101
  offerSetKey: string | undefined;
110
102
  planId: string;
@@ -113,9 +105,13 @@ export declare const toSubscriptionCheckoutPlanRequest: (input: UpdateSubscripti
113
105
  provider: "stripe" | null | undefined;
114
106
  paymentProfileId: string | undefined;
115
107
  runtimeConfigRevisionId: string | undefined;
108
+ anonymousUserId: string | undefined;
109
+ idempotencyKey: string | undefined;
116
110
  title: string;
117
111
  description: string | undefined;
118
112
  amountCents: number;
113
+ };
114
+ export declare const toSubscriptionCheckoutPlanRequest: (input: UpdateSubscriptionCheckoutPlanInput) => {
119
115
  billingInterval: import("../../../../index.js").BillingPlanInterval;
120
116
  billingIntervalCount: number;
121
117
  followUpProviderPlanId: string | undefined;
@@ -129,6 +125,20 @@ export declare const toSubscriptionCheckoutPlanRequest: (input: UpdateSubscripti
129
125
  userId: string | undefined;
130
126
  environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
131
127
  runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
128
+ currency?: string | undefined;
129
+ money?: import("@funnelsgrove/runtime").ProviderMoney | undefined;
130
+ checkoutSessionId: string;
131
+ offerSetId: string | undefined;
132
+ offerSetKey: string | undefined;
133
+ planId: string;
134
+ planKey: string;
135
+ providerPlanId: string | undefined;
136
+ provider: "stripe" | null | undefined;
137
+ paymentProfileId: string | undefined;
138
+ runtimeConfigRevisionId: string | undefined;
139
+ title: string;
140
+ description: string | undefined;
141
+ amountCents: number;
132
142
  };
133
143
  export declare const toSubscriptionCheckoutStatusRequest: (input: VerifySubscriptionCheckoutPaymentInput) => {
134
144
  checkoutSessionId: string;
@@ -8,44 +8,24 @@ const toCheckoutIdentityRequestFields = (userId) => {
8
8
  return checkoutIdentityToken ? { checkoutIdentityToken } : {};
9
9
  };
10
10
  export const toOneTimeCheckoutRequest = (input) => {
11
- var _a, _b, _c, _d, _e, _f, _g, _h;
12
- return Object.assign(Object.assign({ planKey: ((_a = input.plan.funnelPlanKey) === null || _a === void 0 ? void 0 : _a.trim()) || input.plan.id, runtimeConfigRevisionId: input.runtimeConfigRevisionId, paymentProfileId: input.paymentProfileId, provider: input.provider, anonymousUserId: input.anonymousUserId, idempotencyKey: input.idempotencyKey, offerSetId: ((_b = input.plan.offerSetId) === null || _b === void 0 ? void 0 : _b.trim()) || undefined, offerSetKey: ((_c = input.plan.offerSetKey) === null || _c === void 0 ? void 0 : _c.trim()) || undefined, planId: getPaywallPlanRequestId(input.plan), providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined, title: input.plan.title, description: ((_e = input.plan.description) === null || _e === void 0 ? void 0 : _e.trim()) || undefined, amountCents: input.plan.amountCents, couponId: ((_f = input.couponId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined, analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan), customerEmail: ((_g = input.customerEmail) === null || _g === void 0 ? void 0 : _g.trim()) || undefined, returnUrl: input.returnUrl, userId: ((_h = input.user_id) === null || _h === void 0 ? void 0 : _h.trim()) || undefined }, toCheckoutIdentityRequestFields(input.user_id)), { environment: input.environment, runtimeConfig: input.runtimeConfig });
11
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
12
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ planKey: ((_a = input.plan.funnelPlanKey) === null || _a === void 0 ? void 0 : _a.trim()) || input.plan.id, runtimeConfigRevisionId: input.runtimeConfigRevisionId, paymentProfileId: input.paymentProfileId, provider: input.provider, anonymousUserId: input.anonymousUserId, idempotencyKey: input.idempotencyKey, offerSetId: ((_b = input.plan.offerSetId) === null || _b === void 0 ? void 0 : _b.trim()) || undefined, offerSetKey: ((_c = input.plan.offerSetKey) === null || _c === void 0 ? void 0 : _c.trim()) || undefined, planId: getPaywallPlanRequestId(input.plan), providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined, title: input.plan.title, description: ((_e = input.plan.description) === null || _e === void 0 ? void 0 : _e.trim()) || undefined, amountCents: input.plan.amountCents }, (input.plan.money ? { money: input.plan.money } : {})), (((_f = input.plan.money) === null || _f === void 0 ? void 0 : _f.currency) || input.plan.currency
13
+ ? { currency: (_h = (_g = input.plan.money) === null || _g === void 0 ? void 0 : _g.currency) !== null && _h !== void 0 ? _h : input.plan.currency }
14
+ : {})), { couponId: ((_j = input.couponId) === null || _j === void 0 ? void 0 : _j.trim()) || undefined, analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan), customerEmail: ((_k = input.customerEmail) === null || _k === void 0 ? void 0 : _k.trim()) || undefined, returnUrl: input.returnUrl, userId: ((_l = input.user_id) === null || _l === void 0 ? void 0 : _l.trim()) || undefined }), toCheckoutIdentityRequestFields(input.user_id)), { environment: input.environment, runtimeConfig: input.runtimeConfig });
13
15
  };
14
16
  export const toSubscriptionCheckoutRequest = (input) => {
15
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
17
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
16
18
  const recurring = requireCheckoutRecurringConfig(input.plan);
17
- return Object.assign(Object.assign({ offerSetId: ((_a = input.plan.offerSetId) === null || _a === void 0 ? void 0 : _a.trim()) || undefined, offerSetKey: ((_b = input.plan.offerSetKey) === null || _b === void 0 ? void 0 : _b.trim()) || undefined, planId: getPaywallPlanRequestId(input.plan), planKey: ((_c = input.plan.funnelPlanKey) === null || _c === void 0 ? void 0 : _c.trim()) || input.plan.id, providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined, provider: input.provider, paymentProfileId: ((_e = input.paymentProfileId) === null || _e === void 0 ? void 0 : _e.trim()) || undefined, runtimeConfigRevisionId: ((_f = input.runtimeConfigRevisionId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined, anonymousUserId: ((_g = input.anonymousUserId) === null || _g === void 0 ? void 0 : _g.trim()) || undefined, idempotencyKey: ((_h = input.idempotencyKey) === null || _h === void 0 ? void 0 : _h.trim()) || undefined, title: input.plan.title, description: ((_j = input.plan.description) === null || _j === void 0 ? void 0 : _j.trim()) || undefined, amountCents: input.plan.amountCents, billingInterval: recurring.interval, billingIntervalCount: recurring.intervalCount, followUpProviderPlanId: ((_k = input.plan.followUpProviderPlanId) === null || _k === void 0 ? void 0 : _k.trim()) || undefined, followUpPlanTitle: ((_l = input.plan.followUpPlanTitle) === null || _l === void 0 ? void 0 : _l.trim()) || undefined, followUpBillingInterval: input.plan.followUpBillingInterval, followUpBillingIntervalCount: input.plan.followUpBillingIntervalCount, introIterations: input.plan.introIterations, couponId: ((_m = input.couponId) === null || _m === void 0 ? void 0 : _m.trim()) || undefined, analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan), customerEmail: ((_o = input.customerEmail) === null || _o === void 0 ? void 0 : _o.trim()) || undefined, returnUrl: input.returnUrl, userId: ((_p = input.user_id) === null || _p === void 0 ? void 0 : _p.trim()) || undefined }, toCheckoutIdentityRequestFields(input.user_id)), { environment: input.environment, runtimeConfig: input.runtimeConfig });
19
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ offerSetId: ((_a = input.plan.offerSetId) === null || _a === void 0 ? void 0 : _a.trim()) || undefined, offerSetKey: ((_b = input.plan.offerSetKey) === null || _b === void 0 ? void 0 : _b.trim()) || undefined, planId: getPaywallPlanRequestId(input.plan), planKey: ((_c = input.plan.funnelPlanKey) === null || _c === void 0 ? void 0 : _c.trim()) || input.plan.id, providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined, provider: input.provider, paymentProfileId: ((_e = input.paymentProfileId) === null || _e === void 0 ? void 0 : _e.trim()) || undefined, runtimeConfigRevisionId: ((_f = input.runtimeConfigRevisionId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined, anonymousUserId: ((_g = input.anonymousUserId) === null || _g === void 0 ? void 0 : _g.trim()) || undefined, idempotencyKey: ((_h = input.idempotencyKey) === null || _h === void 0 ? void 0 : _h.trim()) || undefined, title: input.plan.title, description: ((_j = input.plan.description) === null || _j === void 0 ? void 0 : _j.trim()) || undefined, amountCents: input.plan.amountCents }, (input.plan.money ? { money: input.plan.money } : {})), (((_k = input.plan.money) === null || _k === void 0 ? void 0 : _k.currency) || input.plan.currency
20
+ ? { currency: (_m = (_l = input.plan.money) === null || _l === void 0 ? void 0 : _l.currency) !== null && _m !== void 0 ? _m : input.plan.currency }
21
+ : {})), { billingInterval: recurring.interval, billingIntervalCount: recurring.intervalCount, followUpProviderPlanId: ((_o = input.plan.followUpProviderPlanId) === null || _o === void 0 ? void 0 : _o.trim()) || undefined, followUpPlanTitle: ((_p = input.plan.followUpPlanTitle) === null || _p === void 0 ? void 0 : _p.trim()) || undefined, followUpBillingInterval: input.plan.followUpBillingInterval, followUpBillingIntervalCount: input.plan.followUpBillingIntervalCount, introIterations: input.plan.introIterations, couponId: ((_q = input.couponId) === null || _q === void 0 ? void 0 : _q.trim()) || undefined, analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan), customerEmail: ((_r = input.customerEmail) === null || _r === void 0 ? void 0 : _r.trim()) || undefined, returnUrl: input.returnUrl, userId: ((_s = input.user_id) === null || _s === void 0 ? void 0 : _s.trim()) || undefined }), toCheckoutIdentityRequestFields(input.user_id)), { environment: input.environment, runtimeConfig: input.runtimeConfig });
18
22
  };
19
23
  export const toSubscriptionCheckoutPlanRequest = (input) => {
20
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
24
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
21
25
  const recurring = requireCheckoutRecurringConfig(input.plan);
22
- return {
23
- checkoutSessionId: input.checkoutSessionId.trim(),
24
- offerSetId: ((_a = input.plan.offerSetId) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
25
- offerSetKey: ((_b = input.plan.offerSetKey) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
26
- planId: getPaywallPlanRequestId(input.plan),
27
- planKey: ((_c = input.plan.funnelPlanKey) === null || _c === void 0 ? void 0 : _c.trim()) || input.plan.id,
28
- providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
29
- provider: input.provider,
30
- paymentProfileId: ((_e = input.paymentProfileId) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
31
- runtimeConfigRevisionId: ((_f = input.runtimeConfigRevisionId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined,
32
- title: input.plan.title,
33
- description: ((_g = input.plan.description) === null || _g === void 0 ? void 0 : _g.trim()) || undefined,
34
- amountCents: input.plan.amountCents,
35
- billingInterval: recurring.interval,
36
- billingIntervalCount: recurring.intervalCount,
37
- followUpProviderPlanId: ((_h = input.plan.followUpProviderPlanId) === null || _h === void 0 ? void 0 : _h.trim()) || undefined,
38
- followUpPlanTitle: ((_j = input.plan.followUpPlanTitle) === null || _j === void 0 ? void 0 : _j.trim()) || undefined,
39
- followUpBillingInterval: input.plan.followUpBillingInterval,
40
- followUpBillingIntervalCount: input.plan.followUpBillingIntervalCount,
41
- introIterations: input.plan.introIterations,
42
- couponId: ((_k = input.couponId) === null || _k === void 0 ? void 0 : _k.trim()) || undefined,
43
- analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
44
- customerEmail: ((_l = input.customerEmail) === null || _l === void 0 ? void 0 : _l.trim()) || undefined,
45
- userId: ((_m = input.user_id) === null || _m === void 0 ? void 0 : _m.trim()) || undefined,
46
- environment: input.environment,
47
- runtimeConfig: input.runtimeConfig,
48
- };
26
+ return Object.assign(Object.assign(Object.assign({ checkoutSessionId: input.checkoutSessionId.trim(), offerSetId: ((_a = input.plan.offerSetId) === null || _a === void 0 ? void 0 : _a.trim()) || undefined, offerSetKey: ((_b = input.plan.offerSetKey) === null || _b === void 0 ? void 0 : _b.trim()) || undefined, planId: getPaywallPlanRequestId(input.plan), planKey: ((_c = input.plan.funnelPlanKey) === null || _c === void 0 ? void 0 : _c.trim()) || input.plan.id, providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined, provider: input.provider, paymentProfileId: ((_e = input.paymentProfileId) === null || _e === void 0 ? void 0 : _e.trim()) || undefined, runtimeConfigRevisionId: ((_f = input.runtimeConfigRevisionId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined, title: input.plan.title, description: ((_g = input.plan.description) === null || _g === void 0 ? void 0 : _g.trim()) || undefined, amountCents: input.plan.amountCents }, (input.plan.money ? { money: input.plan.money } : {})), (((_h = input.plan.money) === null || _h === void 0 ? void 0 : _h.currency) || input.plan.currency
27
+ ? { currency: (_k = (_j = input.plan.money) === null || _j === void 0 ? void 0 : _j.currency) !== null && _k !== void 0 ? _k : input.plan.currency }
28
+ : {})), { billingInterval: recurring.interval, billingIntervalCount: recurring.intervalCount, followUpProviderPlanId: ((_l = input.plan.followUpProviderPlanId) === null || _l === void 0 ? void 0 : _l.trim()) || undefined, followUpPlanTitle: ((_m = input.plan.followUpPlanTitle) === null || _m === void 0 ? void 0 : _m.trim()) || undefined, followUpBillingInterval: input.plan.followUpBillingInterval, followUpBillingIntervalCount: input.plan.followUpBillingIntervalCount, introIterations: input.plan.introIterations, couponId: ((_o = input.couponId) === null || _o === void 0 ? void 0 : _o.trim()) || undefined, analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan), customerEmail: ((_p = input.customerEmail) === null || _p === void 0 ? void 0 : _p.trim()) || undefined, userId: ((_q = input.user_id) === null || _q === void 0 ? void 0 : _q.trim()) || undefined, environment: input.environment, runtimeConfig: input.runtimeConfig });
49
29
  };
50
30
  export const toSubscriptionCheckoutStatusRequest = (input) => {
51
31
  const checkoutSessionId = requireCheckoutSessionId(input.checkoutSessionId);
@@ -1,9 +1,10 @@
1
1
  import type { FunnelStepType, RuntimeMode } from '@funnelsgrove/runtime';
2
+ import { type PublicAnalyticsFeatureFlags } from '@funnelsgrove/analytics';
2
3
  import type { StripeRuntimeConfigOverrides } from './shared/types.js';
3
4
  import type { ChargeOneClickPaymentResponse, CompleteStripeOneClickPaymentInput } from './oneClick/types.js';
4
5
  export type StripeSubscriptionCheckoutAnalyticsContext = {
5
6
  environment?: RuntimeMode;
6
- featureFlags?: Record<string, string | null | undefined>;
7
+ featureFlags?: PublicAnalyticsFeatureFlags;
7
8
  metadata?: Record<string, unknown> | null;
8
9
  runtimeConfig?: StripeRuntimeConfigOverrides;
9
10
  stepId: string;
@@ -176,7 +176,7 @@ export async function trackPaidStripeSubscriptionCheckoutCompleted(input) {
176
176
  }
177
177
  }
178
178
  export async function trackPaidStripeOneClickPaymentCompleted(input, payment) {
179
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
179
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
180
180
  const context = input.checkoutAnalytics;
181
181
  const paymentIntentId = (_a = payment.paymentIntentId) === null || _a === void 0 ? void 0 : _a.trim();
182
182
  if (!context || payment.status !== 'succeeded' || !paymentIntentId) {
@@ -202,7 +202,7 @@ export async function trackPaidStripeOneClickPaymentCompleted(input, payment) {
202
202
  stepContractVersion: context.stepContractVersion,
203
203
  featureFlags: context.featureFlags,
204
204
  metadata: Object.assign(Object.assign(Object.assign({}, asRecord(input.analyticsMetadata)), asRecord(context.metadata)), { userId,
205
- environment, amountCents: (_g = payment.amountCents) !== null && _g !== void 0 ? _g : input.amountCents, currency: (_j = (_h = payment.currency) !== null && _h !== void 0 ? _h : input.currency) !== null && _j !== void 0 ? _j : 'usd', planId: input.planId, providerPlanId: input.providerPlanId, payment_provider: 'stripe' }),
205
+ environment, amountCents: (_g = payment.amountCents) !== null && _g !== void 0 ? _g : input.amountCents, money: (_h = payment.money) !== null && _h !== void 0 ? _h : input.money, currency: (_o = (_l = (_k = (_j = payment.money) === null || _j === void 0 ? void 0 : _j.currency) !== null && _k !== void 0 ? _k : payment.currency) !== null && _l !== void 0 ? _l : (_m = input.money) === null || _m === void 0 ? void 0 : _m.currency) !== null && _o !== void 0 ? _o : input.currency, planId: input.planId, providerPlanId: input.providerPlanId, payment_provider: 'stripe' }),
206
206
  });
207
207
  if (eventId) {
208
208
  markCheckoutSessionTracked('checkout_completed', paymentIntentId, runtimeConfig);
@@ -1,5 +1,17 @@
1
1
  import type { CreateCheckoutSessionInput } from './types.js';
2
2
  export declare const toHostedCheckoutRequest: (input: CreateCheckoutSessionInput) => {
3
+ billingInterval: import("../../../../index.js").BillingPlanInterval;
4
+ billingIntervalCount: number;
5
+ couponId: string | undefined;
6
+ analyticsMetadata: Record<string, unknown> | undefined;
7
+ successUrl: string;
8
+ cancelUrl: string;
9
+ customerEmail: string | undefined;
10
+ userId: string | undefined;
11
+ environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
12
+ runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
13
+ currency?: string | undefined;
14
+ money?: import("@funnelsgrove/runtime").ProviderMoney | undefined;
3
15
  planKey: string;
4
16
  paymentProfileId: string | null | undefined;
5
17
  provider: "stripe" | null | undefined;
@@ -14,14 +26,4 @@ export declare const toHostedCheckoutRequest: (input: CreateCheckoutSessionInput
14
26
  title: string;
15
27
  description: string | undefined;
16
28
  amountCents: number;
17
- billingInterval: import("../../../../index.js").BillingPlanInterval;
18
- billingIntervalCount: number;
19
- couponId: string | undefined;
20
- analyticsMetadata: Record<string, unknown> | undefined;
21
- successUrl: string;
22
- cancelUrl: string;
23
- customerEmail: string | undefined;
24
- userId: string | undefined;
25
- environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
26
- runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
27
29
  };
@@ -2,32 +2,9 @@ import { requireCheckoutRecurringConfig } from '../shared/checkout.validator.js'
2
2
  import { getPaywallPlanRequestId } from '../../../../services/paywallPlans/selection.js';
3
3
  import { normalizeCheckoutAnalyticsMetadata } from '../shared/checkoutMetadata.js';
4
4
  export const toHostedCheckoutRequest = (input) => {
5
- var _a, _b, _c, _d, _e, _f, _g, _h;
5
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
6
6
  const recurring = requireCheckoutRecurringConfig(input.plan);
7
- return {
8
- planKey: ((_a = input.plan.funnelPlanKey) === null || _a === void 0 ? void 0 : _a.trim()) || input.plan.id,
9
- paymentProfileId: input.paymentProfileId,
10
- provider: input.provider,
11
- runtimeConfigRevisionId: input.runtimeConfigRevisionId,
12
- anonymousUserId: input.anonymousUserId,
13
- checkoutIdentityToken: input.checkoutIdentityToken,
14
- idempotencyKey: input.idempotencyKey,
15
- offerSetId: ((_b = input.plan.offerSetId) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
16
- offerSetKey: ((_c = input.plan.offerSetKey) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
17
- planId: getPaywallPlanRequestId(input.plan),
18
- providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
19
- title: input.plan.title,
20
- description: ((_e = input.plan.description) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
21
- amountCents: input.plan.amountCents,
22
- billingInterval: recurring.interval,
23
- billingIntervalCount: recurring.intervalCount,
24
- couponId: ((_f = input.couponId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined,
25
- analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
26
- successUrl: input.successUrl,
27
- cancelUrl: input.cancelUrl,
28
- customerEmail: ((_g = input.customerEmail) === null || _g === void 0 ? void 0 : _g.trim()) || undefined,
29
- userId: ((_h = input.user_id) === null || _h === void 0 ? void 0 : _h.trim()) || undefined,
30
- environment: input.environment,
31
- runtimeConfig: input.runtimeConfig,
32
- };
7
+ return Object.assign(Object.assign(Object.assign({ planKey: ((_a = input.plan.funnelPlanKey) === null || _a === void 0 ? void 0 : _a.trim()) || input.plan.id, paymentProfileId: input.paymentProfileId, provider: input.provider, runtimeConfigRevisionId: input.runtimeConfigRevisionId, anonymousUserId: input.anonymousUserId, checkoutIdentityToken: input.checkoutIdentityToken, idempotencyKey: input.idempotencyKey, offerSetId: ((_b = input.plan.offerSetId) === null || _b === void 0 ? void 0 : _b.trim()) || undefined, offerSetKey: ((_c = input.plan.offerSetKey) === null || _c === void 0 ? void 0 : _c.trim()) || undefined, planId: getPaywallPlanRequestId(input.plan), providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined, title: input.plan.title, description: ((_e = input.plan.description) === null || _e === void 0 ? void 0 : _e.trim()) || undefined, amountCents: input.plan.amountCents }, (input.plan.money ? { money: input.plan.money } : {})), (((_f = input.plan.money) === null || _f === void 0 ? void 0 : _f.currency) || input.plan.currency
8
+ ? { currency: (_h = (_g = input.plan.money) === null || _g === void 0 ? void 0 : _g.currency) !== null && _h !== void 0 ? _h : input.plan.currency }
9
+ : {})), { billingInterval: recurring.interval, billingIntervalCount: recurring.intervalCount, couponId: ((_j = input.couponId) === null || _j === void 0 ? void 0 : _j.trim()) || undefined, analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan), successUrl: input.successUrl, cancelUrl: input.cancelUrl, customerEmail: ((_k = input.customerEmail) === null || _k === void 0 ? void 0 : _k.trim()) || undefined, userId: ((_l = input.user_id) === null || _l === void 0 ? void 0 : _l.trim()) || undefined, environment: input.environment, runtimeConfig: input.runtimeConfig });
33
10
  };
@@ -1,13 +1,5 @@
1
1
  import type { ChargeOneClickPaymentInput } from './types.js';
2
2
  export declare const toOneClickPaymentRequest: (input: ChargeOneClickPaymentInput) => {
3
- planKey: string | null | undefined;
4
- offerSetId: string | null | undefined;
5
- runtimeConfigRevisionId: string | null | undefined;
6
- paymentProfileId: string | null | undefined;
7
- provider: "stripe" | null | undefined;
8
- planId: string;
9
- providerPlanId: string | undefined;
10
- amountCents: number;
11
3
  currency: string | undefined;
12
4
  description: string | undefined;
13
5
  analyticsMetadata: Record<string, unknown> | undefined;
@@ -17,4 +9,13 @@ export declare const toOneClickPaymentRequest: (input: ChargeOneClickPaymentInpu
17
9
  idempotencyKey: string | undefined;
18
10
  environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
19
11
  runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
12
+ money?: import("@funnelsgrove/runtime").ProviderMoney | undefined;
13
+ planKey: string | null | undefined;
14
+ offerSetId: string | null | undefined;
15
+ runtimeConfigRevisionId: string | null | undefined;
16
+ paymentProfileId: string | null | undefined;
17
+ provider: "stripe" | null | undefined;
18
+ planId: string;
19
+ providerPlanId: string | undefined;
20
+ amountCents: number;
20
21
  };
@@ -1,23 +1,5 @@
1
1
  import { normalizeAnalyticsMetadata } from '../shared/checkoutMetadata.js';
2
2
  export const toOneClickPaymentRequest = (input) => {
3
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4
- return {
5
- planKey: input.planKey,
6
- offerSetId: input.offerSetId,
7
- runtimeConfigRevisionId: input.runtimeConfigRevisionId,
8
- paymentProfileId: input.paymentProfileId,
9
- provider: input.provider,
10
- planId: input.planId,
11
- providerPlanId: ((_a = input.providerPlanId) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
12
- amountCents: input.amountCents,
13
- currency: ((_b = input.currency) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
14
- description: ((_c = input.description) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
15
- analyticsMetadata: normalizeAnalyticsMetadata(input.analyticsMetadata),
16
- userId: ((_d = input.userId) === null || _d === void 0 ? void 0 : _d.trim()) || ((_e = input.user_id) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
17
- stripeCustomerId: ((_f = input.stripeCustomerId) === null || _f === void 0 ? void 0 : _f.trim()) || ((_g = input.stripe_customer_id) === null || _g === void 0 ? void 0 : _g.trim()) || undefined,
18
- checkoutSessionId: ((_h = input.checkoutSessionId) === null || _h === void 0 ? void 0 : _h.trim()) || undefined,
19
- idempotencyKey: ((_j = input.idempotencyKey) === null || _j === void 0 ? void 0 : _j.trim()) || undefined,
20
- environment: input.environment,
21
- runtimeConfig: input.runtimeConfig,
22
- };
3
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
4
+ return Object.assign(Object.assign({ planKey: input.planKey, offerSetId: input.offerSetId, runtimeConfigRevisionId: input.runtimeConfigRevisionId, paymentProfileId: input.paymentProfileId, provider: input.provider, planId: input.planId, providerPlanId: ((_a = input.providerPlanId) === null || _a === void 0 ? void 0 : _a.trim()) || undefined, amountCents: input.amountCents }, (input.money ? { money: input.money } : {})), { currency: (_c = (_b = input.money) === null || _b === void 0 ? void 0 : _b.currency) !== null && _c !== void 0 ? _c : (((_d = input.currency) === null || _d === void 0 ? void 0 : _d.trim()) || undefined), description: ((_e = input.description) === null || _e === void 0 ? void 0 : _e.trim()) || undefined, analyticsMetadata: normalizeAnalyticsMetadata(input.analyticsMetadata), userId: ((_f = input.userId) === null || _f === void 0 ? void 0 : _f.trim()) || ((_g = input.user_id) === null || _g === void 0 ? void 0 : _g.trim()) || undefined, stripeCustomerId: ((_h = input.stripeCustomerId) === null || _h === void 0 ? void 0 : _h.trim()) || ((_j = input.stripe_customer_id) === null || _j === void 0 ? void 0 : _j.trim()) || undefined, checkoutSessionId: ((_k = input.checkoutSessionId) === null || _k === void 0 ? void 0 : _k.trim()) || undefined, idempotencyKey: ((_l = input.idempotencyKey) === null || _l === void 0 ? void 0 : _l.trim()) || undefined, environment: input.environment, runtimeConfig: input.runtimeConfig });
23
5
  };
@@ -1,4 +1,4 @@
1
- import type { RuntimeMode } from '@funnelsgrove/runtime';
1
+ import type { ProviderMoney, RuntimeMode } from '@funnelsgrove/runtime';
2
2
  import type { StripeRuntimeConfigOverrides } from '../shared/types.js';
3
3
  import type { StripeSubscriptionCheckoutAnalyticsContext } from '../checkoutCompletionAnalytics.service.js';
4
4
  export type ChargeOneClickPaymentInput = {
@@ -10,6 +10,7 @@ export type ChargeOneClickPaymentInput = {
10
10
  provider?: 'stripe' | null;
11
11
  providerPlanId?: string | null;
12
12
  amountCents: number;
13
+ money?: ProviderMoney;
13
14
  analyticsMetadata?: Record<string, unknown> | null;
14
15
  checkoutSessionId?: string | null;
15
16
  currency?: string | null;
@@ -28,6 +29,7 @@ export type ChargeOneClickPaymentResponse = {
28
29
  paymentIntentId: string;
29
30
  status: string;
30
31
  amountCents?: number;
32
+ money?: ProviderMoney;
31
33
  clientSecret?: string;
32
34
  currency?: string;
33
35
  environment?: 'test' | 'live';
@@ -1,7 +1,8 @@
1
+ import { type PublicAnalyticsFeatureFlags } from '@funnelsgrove/analytics';
1
2
  import { type FunnelSdkRuntimeConfigOverrides, type FunnelStepType, type RuntimeMode } from '@funnelsgrove/runtime';
2
3
  export type CheckoutObservabilityAnalyticsContext = {
3
4
  environment?: RuntimeMode;
4
- featureFlags?: Record<string, string | null | undefined>;
5
+ featureFlags?: PublicAnalyticsFeatureFlags;
5
6
  metadata?: Record<string, unknown> | null;
6
7
  runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
7
8
  stepId?: string;
@@ -1,4 +1,4 @@
1
- import { publicAnalyticsSdk } from '@funnelsgrove/analytics';
1
+ import { publicAnalyticsSdk, } from '@funnelsgrove/analytics';
2
2
  import { buildMainApiUrl, buildSdkHeaders, FUNNEL_ID, FUNNEL_VERSION_ID, } from '@funnelsgrove/runtime';
3
3
  import { toAnalyticsPaymentMethod } from './paymentMethodAnalytics.service.js';
4
4
  const asNonEmptyString = (value) => typeof value === 'string' && value.trim() ? value.trim() : null;
@@ -1,3 +1,5 @@
1
+ import { formatProviderMoney } from '@funnelsgrove/runtime';
2
+ const withAmountMinor = (money, amountMinor) => (Object.assign(Object.assign({}, money), { amountMinor }));
1
3
  const isBillingDiscountList = (discounts) => {
2
4
  return Array.isArray(discounts);
3
5
  };
@@ -259,21 +261,30 @@ export const buildDiscountedPaywallPlans = (input) => {
259
261
  const currency = ((_a = input.currency) === null || _a === void 0 ? void 0 : _a.trim()) || 'USD';
260
262
  const locale = ((_b = input.locale) === null || _b === void 0 ? void 0 : _b.trim()) || 'en-US';
261
263
  return input.plans.map((plan) => {
262
- var _a, _b;
264
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
263
265
  const billingDays = getBillingDays(plan);
266
+ const planCurrency = ((_b = (_a = plan.money) === null || _a === void 0 ? void 0 : _a.currency) !== null && _b !== void 0 ? _b : (_c = plan.currency) === null || _c === void 0 ? void 0 : _c.trim()) || currency;
264
267
  const fixed = input.amountOffMinor !== undefined;
265
268
  const hasActiveDiscount = Boolean(input.couponId) && (fixed
266
269
  ? Number.isSafeInteger(input.amountOffMinor) && input.amountOffMinor > 0
267
- && ((_a = input.discountCurrency) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === currency.toUpperCase()
270
+ && ((_d = input.discountCurrency) === null || _d === void 0 ? void 0 : _d.toUpperCase()) === planCurrency.toUpperCase()
268
271
  : typeof input.discountPercent === 'number');
269
- const discountedAmountCents = !hasActiveDiscount ? plan.amountCents : fixed
270
- ? Math.max(0, plan.amountCents - input.amountOffMinor)
271
- : getDiscountedAmountCents(plan.amountCents, (_b = input.discountPercent) !== null && _b !== void 0 ? _b : 0);
272
+ const baseAmountMinor = (_f = (_e = plan.money) === null || _e === void 0 ? void 0 : _e.amountMinor) !== null && _f !== void 0 ? _f : plan.amountCents;
273
+ const discountedAmountCents = !hasActiveDiscount ? baseAmountMinor : fixed
274
+ ? Math.max(0, baseAmountMinor - input.amountOffMinor)
275
+ : getDiscountedAmountCents(baseAmountMinor, (_g = input.discountPercent) !== null && _g !== void 0 ? _g : 0);
276
+ const discountedMoney = plan.money
277
+ ? withAmountMinor(plan.money, discountedAmountCents)
278
+ : undefined;
272
279
  const discountedPerDayAmount = billingDays && billingDays > 0
273
- ? formatMoneyFromCents(Math.round(discountedAmountCents / billingDays), currency, locale)
280
+ ? discountedMoney
281
+ ? formatProviderMoney(withAmountMinor(discountedMoney, Math.round(discountedMoney.amountMinor / billingDays)), locale)
282
+ : formatMoneyFromCents(Math.round(discountedAmountCents / billingDays), planCurrency, locale)
274
283
  : plan.perDayAmount;
275
- return Object.assign(Object.assign({}, plan), { amountCents: discountedAmountCents, priceLabel: hasActiveDiscount
276
- ? formatMoneyFromCents(discountedAmountCents, currency, locale)
284
+ return Object.assign(Object.assign({}, plan), { amountCents: discountedAmountCents, money: discountedMoney, currency: (_j = (_h = plan.money) === null || _h === void 0 ? void 0 : _h.currency) !== null && _j !== void 0 ? _j : plan.currency, priceLabel: hasActiveDiscount
285
+ ? discountedMoney
286
+ ? formatProviderMoney(discountedMoney, locale)
287
+ : formatMoneyFromCents(discountedAmountCents, planCurrency, locale)
277
288
  : plan.priceLabel, oldPriceLabel: hasActiveDiscount ? plan.priceLabel : undefined, perDayAmount: hasActiveDiscount ? discountedPerDayAmount : plan.perDayAmount, baseAmountCents: plan.amountCents, basePriceLabel: plan.priceLabel, basePerDayAmount: plan.perDayAmount, oldPerDayAmount: hasActiveDiscount ? plan.perDayAmount : null, couponId: hasActiveDiscount ? input.couponId : null, hasActiveDiscount });
278
289
  });
279
290
  };
@@ -1,5 +1,5 @@
1
1
  import type { BillingFallbackPlanConfig, BillingPlanInterval } from '../../config/billing.config.js';
2
- import type { ResolvedCountryPricing } from '@funnelsgrove/runtime';
2
+ import type { ProviderMoney, ResolvedCountryPricing } from '@funnelsgrove/runtime';
3
3
  export type PaywallPlan = {
4
4
  id: string;
5
5
  funnelPlanKey?: string;
@@ -15,6 +15,8 @@ export type PaywallPlan = {
15
15
  perDayAmount: string;
16
16
  perDayLabel: string;
17
17
  amountCents: number;
18
+ money?: ProviderMoney;
19
+ currency?: string;
18
20
  analyticsPurchaseValue?: number;
19
21
  comparison?: BillingFallbackPlanConfig['comparison'];
20
22
  checkoutOriginalAmountCents?: number;
@@ -32,7 +34,7 @@ export type PaywallPlanResolutionOptions = {
32
34
  locale?: string | null;
33
35
  pricing?: ResolvedCountryPricing<string> | null;
34
36
  };
35
- export type CheckoutSessionPlanInput = Pick<PaywallPlan, 'amountCents' | 'analyticsPurchaseValue' | 'billingInterval' | 'billingIntervalCount' | 'description' | 'funnelPlanKey' | 'id' | 'providerPlanId' | 'title' | 'followUpProviderPlanId' | 'followUpPlanTitle' | 'followUpBillingInterval' | 'followUpBillingIntervalCount' | 'introIterations' | 'offerSetId' | 'offerSetKey'>;
37
+ export type CheckoutSessionPlanInput = Pick<PaywallPlan, 'amountCents' | 'money' | 'currency' | 'analyticsPurchaseValue' | 'billingInterval' | 'billingIntervalCount' | 'description' | 'funnelPlanKey' | 'id' | 'providerPlanId' | 'title' | 'followUpProviderPlanId' | 'followUpPlanTitle' | 'followUpBillingInterval' | 'followUpBillingIntervalCount' | 'introIterations' | 'offerSetId' | 'offerSetKey'>;
36
38
  export type CheckoutPlanRecurringConfig = {
37
39
  interval: BillingPlanInterval;
38
40
  intervalCount: number;
@@ -4,6 +4,7 @@ import { type PaywallPlan } from './paywallPlans.service.js';
4
4
  export type PublishedBillingPlan = BillingFallbackPlanConfig & OfferSetRuntimePlanOverrides;
5
5
  export type ResolvedPublishedBillingRuntime = {
6
6
  revisionId: string | null;
7
+ sourceVersionId: string | null;
7
8
  paymentsApiVersion: 'v2';
8
9
  mode: RuntimeMode;
9
10
  offerSetId: string;
@@ -12,6 +13,8 @@ export type ResolvedPublishedBillingRuntime = {
12
13
  stripePublishableKey: string | null;
13
14
  experimentId: string | null;
14
15
  variantKey: string | null;
16
+ locale: string | null;
17
+ featureFlags: Readonly<Record<string, string | boolean>>;
15
18
  experiments: readonly FunnelExperimentDefinition[];
16
19
  flowExperiments: readonly FunnelManifestExperiment[];
17
20
  plans: readonly PaywallPlan[];
@@ -20,14 +23,32 @@ export type ResolvedPublishedBillingRuntime = {
20
23
  discounts: BillingDiscountCatalog | null;
21
24
  upsells: readonly PublishedBillingPlan[];
22
25
  downsells: readonly PublishedBillingPlan[];
26
+ /** Published plan keys withheld because this mode has no chargeable price for them. */
27
+ unavailablePlanKeys: readonly string[];
23
28
  };
24
- export declare const resolvePublishedBillingRuntime: ({ config, featureFlags, mode, search, defaultOfferSetId, baseCatalogsByMode, fallbackDiscounts, resolvedExperiments, }: {
29
+ export declare const EMPTY_PUBLISHED_BILLING_RUNTIME: ResolvedPublishedBillingRuntime;
30
+ export declare const resolvePublishedBillingRuntime: ({ config, featureFlags, mode, search, defaultOfferSetId, locale, baseCatalogsByMode, fallbackDiscounts, resolvedExperiments, }: {
25
31
  config: ResolvedFunnelRuntimeConfig | null;
26
- featureFlags: Readonly<Record<string, string>>;
32
+ featureFlags: Readonly<Record<string, string | boolean>>;
27
33
  mode: RuntimeMode;
28
34
  search?: string;
29
35
  defaultOfferSetId?: string;
36
+ locale?: string | null;
30
37
  baseCatalogsByMode?: Partial<Record<RuntimeMode, BillingPlanCatalog>>;
31
38
  fallbackDiscounts?: BillingDiscountList;
32
39
  resolvedExperiments?: ResolvedPublishedExperiments;
33
40
  }) => ResolvedPublishedBillingRuntime;
41
+ export type PublishedBillingRuntimeResolution = {
42
+ status: 'pending';
43
+ runtime: null;
44
+ error: null;
45
+ } | {
46
+ status: 'resolved';
47
+ runtime: ResolvedPublishedBillingRuntime;
48
+ error: null;
49
+ } | {
50
+ status: 'error';
51
+ runtime: null;
52
+ error: Error;
53
+ };
54
+ export declare const resolvePublishedBillingRuntimeState: (input: Parameters<typeof resolvePublishedBillingRuntime>[0], ready?: boolean) => PublishedBillingRuntimeResolution;
@@ -1,8 +1,16 @@
1
1
  import { resolveGeneratedOfferSetRuntime, resolvePublishedOfferSetSelection, resolvePublishedRuntimeExperiments, } from '@funnelsgrove/runtime';
2
2
  import { buildBillingDiscountCatalog } from './paywallOffer.service.js';
3
3
  import { buildConfigPaywallPlans, } from './paywallPlans.service.js';
4
- export const resolvePublishedBillingRuntime = ({ config, featureFlags, mode, search = '', defaultOfferSetId, baseCatalogsByMode, fallbackDiscounts, resolvedExperiments = resolvePublishedRuntimeExperiments(config), }) => {
5
- var _a, _b, _c, _d, _e, _f, _g;
4
+ export const EMPTY_PUBLISHED_BILLING_RUNTIME = Object.freeze({
5
+ revisionId: null, sourceVersionId: null, paymentsApiVersion: 'v2', mode: 'live',
6
+ offerSetId: '', paymentProfileId: null, provider: 'stripe', stripePublishableKey: null,
7
+ experimentId: null, variantKey: null, locale: null, experiments: [], flowExperiments: [],
8
+ featureFlags: Object.freeze({}),
9
+ plans: [], planCatalog: {}, defaultPlanKey: '', discounts: null, upsells: [], downsells: [],
10
+ unavailablePlanKeys: [],
11
+ });
12
+ export const resolvePublishedBillingRuntime = ({ config, featureFlags, mode, search = '', defaultOfferSetId, locale, baseCatalogsByMode, fallbackDiscounts, resolvedExperiments = resolvePublishedRuntimeExperiments(config), }) => {
13
+ var _a, _b, _c, _d, _e, _f, _g, _h;
6
14
  const offerSets = (_a = config === null || config === void 0 ? void 0 : config.offerSets) !== null && _a !== void 0 ? _a : [];
7
15
  const selection = resolvePublishedOfferSetSelection({
8
16
  offerSets,
@@ -10,7 +18,12 @@ export const resolvePublishedBillingRuntime = ({ config, featureFlags, mode, sea
10
18
  featureFlags,
11
19
  search,
12
20
  defaultOfferSetId: defaultOfferSetId || (config === null || config === void 0 ? void 0 : config.defaultOfferSetId) || undefined,
21
+ locale,
22
+ localeContractVersion: config === null || config === void 0 ? void 0 : config.localeContractVersion,
13
23
  });
24
+ if ((config === null || config === void 0 ? void 0 : config.localeContractVersion) === 1 && offerSets.length > 0 && !selection.offerSetId) {
25
+ throw new Error('Published billing runtime has no valid offer set selection');
26
+ }
14
27
  const runtime = resolveGeneratedOfferSetRuntime({
15
28
  offerSets,
16
29
  offerSetId: selection.offerSetId,
@@ -24,18 +37,24 @@ export const resolvePublishedBillingRuntime = ({ config, featureFlags, mode, sea
24
37
  const discountList = runtime.getDiscountList(mode);
25
38
  const provider = runtime.getPaymentProvider(mode);
26
39
  const paymentProviderConfig = (_c = (_b = runtime.offerSet) === null || _b === void 0 ? void 0 : _b.paymentProviderConfigByMode) === null || _c === void 0 ? void 0 : _c[mode];
40
+ const pinnedFeatureFlags = Object.assign(Object.assign({}, featureFlags), (selection.experimentId && selection.variantKey
41
+ ? { [selection.experimentId]: selection.variantKey }
42
+ : {}));
27
43
  return {
28
44
  revisionId: (_d = config === null || config === void 0 ? void 0 : config.revisionId) !== null && _d !== void 0 ? _d : null,
45
+ sourceVersionId: (_e = config === null || config === void 0 ? void 0 : config.sourceVersionId) !== null && _e !== void 0 ? _e : null,
29
46
  paymentsApiVersion: 'v2',
30
47
  mode,
31
48
  offerSetId: selection.offerSetId,
32
- paymentProfileId: ((_f = (_e = runtime.offerSet) === null || _e === void 0 ? void 0 : _e.paymentProfileId) === null || _f === void 0 ? void 0 : _f.trim()) || null,
49
+ paymentProfileId: ((_g = (_f = runtime.offerSet) === null || _f === void 0 ? void 0 : _f.paymentProfileId) === null || _g === void 0 ? void 0 : _g.trim()) || null,
33
50
  provider,
34
51
  stripePublishableKey: provider === 'stripe' && (paymentProviderConfig === null || paymentProviderConfig === void 0 ? void 0 : paymentProviderConfig.provider) === 'stripe'
35
- ? ((_g = paymentProviderConfig === null || paymentProviderConfig === void 0 ? void 0 : paymentProviderConfig.stripePublishableKey) === null || _g === void 0 ? void 0 : _g.trim()) || null
52
+ ? ((_h = paymentProviderConfig === null || paymentProviderConfig === void 0 ? void 0 : paymentProviderConfig.stripePublishableKey) === null || _h === void 0 ? void 0 : _h.trim()) || null
36
53
  : null,
37
54
  experimentId: selection.experimentId,
38
55
  variantKey: selection.variantKey,
56
+ locale: selection.locale,
57
+ featureFlags: Object.freeze(pinnedFeatureFlags),
39
58
  experiments: resolvedExperiments.experiments,
40
59
  flowExperiments: resolvedExperiments.flowExperiments,
41
60
  plans: buildConfigPaywallPlans(planCatalog, runtime.planKeys),
@@ -44,5 +63,20 @@ export const resolvePublishedBillingRuntime = ({ config, featureFlags, mode, sea
44
63
  discounts: discountList.length > 0 ? buildBillingDiscountCatalog(discountList) : null,
45
64
  upsells: getPlans(runtime.upsellPlanKeys),
46
65
  downsells: getPlans(runtime.downsellPlanKeys),
66
+ unavailablePlanKeys: runtime.getUnavailablePlanKeys(mode),
47
67
  };
48
68
  };
69
+ export const resolvePublishedBillingRuntimeState = (input, ready = true) => {
70
+ if (!ready)
71
+ return { status: 'pending', runtime: null, error: null };
72
+ try {
73
+ return { status: 'resolved', runtime: resolvePublishedBillingRuntime(input), error: null };
74
+ }
75
+ catch (error) {
76
+ return {
77
+ status: 'error',
78
+ runtime: null,
79
+ error: error instanceof Error ? error : new Error('Unable to resolve published billing runtime'),
80
+ };
81
+ }
82
+ };