@funnelsgrove/payments 0.6.0 → 0.7.1
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
|
@@ -74,6 +74,7 @@ When a live funnel still uses one of these, migrate the funnel deliberately with
|
|
|
74
74
|
## Public Surfaces
|
|
75
75
|
|
|
76
76
|
- `config/billing.config`: billing catalog, mapping, plan, and discount contracts.
|
|
77
|
+
- `services/publishedBillingRuntime.service`: resolves one published runtime artifact into component-ready plans, defaults, upsells, downsells, discounts, and flow experiments.
|
|
77
78
|
- `services/planCatalog.service`: plan resolution and selection helpers.
|
|
78
79
|
- `services/runtimeBillingPlanCatalog.service`: test/live runtime catalog selection.
|
|
79
80
|
- `services/paywallOffer.service`: timed discount and display-plan helpers.
|
|
@@ -82,6 +83,8 @@ When a live funnel still uses one of these, migrate the funnel deliberately with
|
|
|
82
83
|
- `components/shared/*`: plan selector, checkout dialogs, Express Checkout wrappers, wallet placeholders, and trust assets.
|
|
83
84
|
- `testing/walletCheckoutSmoke`: wallet checkout smoke assertions.
|
|
84
85
|
|
|
86
|
+
Funnels should call `resolvePublishedBillingRuntime` once at their runtime-provider boundary. Screens consume its resolved view and should not parse offer sets or pricing-experiment variants themselves.
|
|
87
|
+
|
|
85
88
|
## Engineering Rules
|
|
86
89
|
|
|
87
90
|
- Keep provider-specific implementation under `src/providers/<provider>`.
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './services/preview-frame.service.js';
|
|
|
3
3
|
export * from './services/runtime-mode.service.js';
|
|
4
4
|
export * from './services/planCatalog.service.js';
|
|
5
5
|
export * from './services/runtimeBillingPlanCatalog.service.js';
|
|
6
|
+
export * from './services/publishedBillingRuntime.service.js';
|
|
6
7
|
export * from './services/paywallOffer.service.js';
|
|
7
8
|
export * from './services/stripe.service.js';
|
|
8
9
|
export * from './services/checkoutCompletionAnalytics.service.js';
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from './services/preview-frame.service.js';
|
|
|
4
4
|
export * from './services/runtime-mode.service.js';
|
|
5
5
|
export * from './services/planCatalog.service.js';
|
|
6
6
|
export * from './services/runtimeBillingPlanCatalog.service.js';
|
|
7
|
+
export * from './services/publishedBillingRuntime.service.js';
|
|
7
8
|
export * from './services/paywallOffer.service.js';
|
|
8
9
|
// Stripe API clients and checkout completion handoff.
|
|
9
10
|
export * from './services/stripe.service.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type FunnelExperimentDefinition, type FunnelManifestExperiment, type OfferSetRuntimePlanOverrides, type ResolvedFunnelRuntimeConfig, type ResolvedPublishedExperiments, type RuntimeMode } from '@funnelsgrove/runtime';
|
|
2
|
+
import type { BillingDiscountCatalog, BillingDiscountList, BillingFallbackPlanConfig, BillingPlanCatalog } from '../config/billing.config.js';
|
|
3
|
+
import { type PaywallPlan } from './stripe.service.js';
|
|
4
|
+
export type PublishedBillingPlan = BillingFallbackPlanConfig & OfferSetRuntimePlanOverrides;
|
|
5
|
+
export type ResolvedPublishedBillingRuntime = {
|
|
6
|
+
revisionId: string | null;
|
|
7
|
+
mode: RuntimeMode;
|
|
8
|
+
offerSetId: string;
|
|
9
|
+
experimentId: string | null;
|
|
10
|
+
variantKey: string | null;
|
|
11
|
+
experiments: readonly FunnelExperimentDefinition[];
|
|
12
|
+
flowExperiments: readonly FunnelManifestExperiment[];
|
|
13
|
+
plans: readonly PaywallPlan[];
|
|
14
|
+
planCatalog: Record<string, PublishedBillingPlan>;
|
|
15
|
+
defaultPlanKey: string;
|
|
16
|
+
discounts: BillingDiscountCatalog | null;
|
|
17
|
+
upsells: readonly PublishedBillingPlan[];
|
|
18
|
+
downsells: readonly PublishedBillingPlan[];
|
|
19
|
+
};
|
|
20
|
+
export declare const resolvePublishedBillingRuntime: ({ config, featureFlags, mode, search, defaultOfferSetId, baseCatalogsByMode, fallbackDiscounts, resolvedExperiments, }: {
|
|
21
|
+
config: ResolvedFunnelRuntimeConfig | null;
|
|
22
|
+
featureFlags: Readonly<Record<string, string>>;
|
|
23
|
+
mode: RuntimeMode;
|
|
24
|
+
search?: string;
|
|
25
|
+
defaultOfferSetId?: string;
|
|
26
|
+
baseCatalogsByMode?: Partial<Record<RuntimeMode, BillingPlanCatalog>>;
|
|
27
|
+
fallbackDiscounts?: BillingDiscountList;
|
|
28
|
+
resolvedExperiments?: ResolvedPublishedExperiments;
|
|
29
|
+
}) => ResolvedPublishedBillingRuntime;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { resolveGeneratedOfferSetRuntime, resolvePublishedOfferSetSelection, resolvePublishedRuntimeExperiments, } from '@funnelsgrove/runtime';
|
|
2
|
+
import { buildBillingDiscountCatalog } from './paywallOffer.service.js';
|
|
3
|
+
import { buildConfigPaywallPlans } from './stripe.service.js';
|
|
4
|
+
export const resolvePublishedBillingRuntime = ({ config, featureFlags, mode, search = '', defaultOfferSetId, baseCatalogsByMode, fallbackDiscounts, resolvedExperiments = resolvePublishedRuntimeExperiments(config), }) => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const offerSets = (_a = config === null || config === void 0 ? void 0 : config.offerSets) !== null && _a !== void 0 ? _a : [];
|
|
7
|
+
const selection = resolvePublishedOfferSetSelection({
|
|
8
|
+
offerSets,
|
|
9
|
+
pricingExperiments: resolvedExperiments.pricingExperiments,
|
|
10
|
+
featureFlags,
|
|
11
|
+
search,
|
|
12
|
+
defaultOfferSetId,
|
|
13
|
+
});
|
|
14
|
+
const runtime = resolveGeneratedOfferSetRuntime({
|
|
15
|
+
offerSets,
|
|
16
|
+
offerSetId: selection.offerSetId,
|
|
17
|
+
baseCatalogsByMode,
|
|
18
|
+
fallbackDiscounts,
|
|
19
|
+
});
|
|
20
|
+
const planCatalog = runtime.getPlanCatalog(mode);
|
|
21
|
+
const getPlans = (keys) => keys
|
|
22
|
+
.map((key) => planCatalog[key])
|
|
23
|
+
.filter((plan) => Boolean(plan));
|
|
24
|
+
const discountList = runtime.getDiscountList(mode);
|
|
25
|
+
return {
|
|
26
|
+
revisionId: (_b = config === null || config === void 0 ? void 0 : config.revisionId) !== null && _b !== void 0 ? _b : null,
|
|
27
|
+
mode,
|
|
28
|
+
offerSetId: selection.offerSetId,
|
|
29
|
+
experimentId: selection.experimentId,
|
|
30
|
+
variantKey: selection.variantKey,
|
|
31
|
+
experiments: resolvedExperiments.experiments,
|
|
32
|
+
flowExperiments: resolvedExperiments.flowExperiments,
|
|
33
|
+
plans: buildConfigPaywallPlans(planCatalog, runtime.planKeys),
|
|
34
|
+
planCatalog,
|
|
35
|
+
defaultPlanKey: runtime.defaultPlanKey,
|
|
36
|
+
discounts: discountList.length > 0 ? buildBillingDiscountCatalog(discountList) : null,
|
|
37
|
+
upsells: getPlans(runtime.upsellPlanKeys),
|
|
38
|
+
downsells: getPlans(runtime.downsellPlanKeys),
|
|
39
|
+
};
|
|
40
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnelsgrove/payments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@funnelsgrove/analytics": "^0.1.28",
|
|
36
|
-
"@funnelsgrove/runtime": "^0.
|
|
36
|
+
"@funnelsgrove/runtime": "^0.7.1",
|
|
37
37
|
"@stripe/react-stripe-js": "^5.6.0",
|
|
38
38
|
"@stripe/stripe-js": "^8.7.0",
|
|
39
39
|
"react": "19.2.3",
|