@funnelsgrove/payments 0.53.0 → 0.54.0
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.d.ts +1 -0
- package/dist/components/ManageSubscriptionScreen.js +7 -3
- package/dist/generated/package-version.d.ts +1 -1
- package/dist/generated/package-version.js +1 -1
- package/dist/services/publishedBillingRuntime.service.d.ts +3 -1
- package/dist/services/publishedBillingRuntime.service.js +5 -2
- package/package.json +5 -5
|
@@ -51,6 +51,7 @@ export declare const __manageSubscriptionScreenTestables: {
|
|
|
51
51
|
cancelled?: boolean;
|
|
52
52
|
past?: boolean;
|
|
53
53
|
}, labels?: ManageSubscriptionLabels) => string;
|
|
54
|
+
resolvePlanLine: (subscription: ManageSubscription, plans: readonly BillingFallbackPlanConfig[], labels?: ManageSubscriptionLabels) => string;
|
|
54
55
|
resolveSubscriptionStatusLabel: (subscription: ManageSubscription, labels?: ManageSubscriptionLabels) => string;
|
|
55
56
|
};
|
|
56
57
|
export {};
|
|
@@ -43,14 +43,17 @@ const formatInterval = (interval, count, labels) => {
|
|
|
43
43
|
const pluralSuffix = normalizedCount === 1 ? '' : 's';
|
|
44
44
|
return `${normalizedCount} ${normalizedInterval}${pluralSuffix}`;
|
|
45
45
|
};
|
|
46
|
-
const formatMoney = (
|
|
46
|
+
const formatMoney = (amountMinor, currency, minorUnitExponent = 2) => {
|
|
47
47
|
const normalizedCurrency = (currency === null || currency === void 0 ? void 0 : currency.trim().toLowerCase()) || 'usd';
|
|
48
|
-
return `${(
|
|
48
|
+
return `${(amountMinor / 10 ** minorUnitExponent).toFixed(minorUnitExponent)} ${normalizedCurrency}`;
|
|
49
49
|
};
|
|
50
50
|
const resolvePlanLine = (subscription, plans, labels) => {
|
|
51
51
|
const plan = plans.find((item) => item.providerPlanId === subscription.providerPlanId);
|
|
52
52
|
if (plan) {
|
|
53
|
-
|
|
53
|
+
const price = plan.money
|
|
54
|
+
? formatMoney(plan.money.amountMinor, plan.money.currency, plan.money.minorUnitExponent)
|
|
55
|
+
: formatMoney(plan.amountCents, plan.currency);
|
|
56
|
+
return `${price} / ${formatInterval(plan.billingInterval, 1, labels)}`;
|
|
54
57
|
}
|
|
55
58
|
if (typeof subscription.amountCents === 'number' && subscription.amountCents > 0) {
|
|
56
59
|
return `${formatMoney(subscription.amountCents, subscription.currency)} / ${formatInterval(subscription.billingInterval, subscription.billingIntervalCount, labels)}`;
|
|
@@ -246,5 +249,6 @@ function SubscriptionSection({ title, subscriptions, plans, onSelect, descriptio
|
|
|
246
249
|
export const __manageSubscriptionScreenTestables = {
|
|
247
250
|
isCancelledActiveSubscription,
|
|
248
251
|
resolveBillingDateLabel,
|
|
252
|
+
resolvePlanLine,
|
|
249
253
|
resolveSubscriptionStatusLabel,
|
|
250
254
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PAYMENTS_PACKAGE_VERSION = "0.
|
|
1
|
+
export declare const PAYMENTS_PACKAGE_VERSION = "0.54.0";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by scripts/generate-package-version.mjs.
|
|
2
|
-
export const PAYMENTS_PACKAGE_VERSION = "0.
|
|
2
|
+
export const PAYMENTS_PACKAGE_VERSION = "0.54.0";
|
|
@@ -25,6 +25,7 @@ export type ResolvedPublishedBillingRuntime = {
|
|
|
25
25
|
experimentId: string | null;
|
|
26
26
|
variantKey: string | null;
|
|
27
27
|
locale: string | null;
|
|
28
|
+
country: string | null;
|
|
28
29
|
featureFlags: Readonly<Record<string, string | boolean>>;
|
|
29
30
|
experiments: readonly FunnelExperimentDefinition[];
|
|
30
31
|
flowExperiments: readonly FunnelManifestExperiment[];
|
|
@@ -40,13 +41,14 @@ export type ResolvedPublishedBillingRuntime = {
|
|
|
40
41
|
export declare const EMPTY_PUBLISHED_BILLING_RUNTIME: ResolvedPublishedBillingRuntime;
|
|
41
42
|
/** Select native terms without applying another provider's percentage to PayPal. */
|
|
42
43
|
export declare const resolvePayPalBillingOption: (runtime: Pick<ResolvedPublishedBillingRuntime, "paypalOptionsByPlanKey" | "discounts">, funnelPlanKey: string, discountKeyOrCouponId?: string | null) => PayPalBillingOption | null;
|
|
43
|
-
export declare const resolvePublishedBillingRuntime: ({ config, featureFlags, mode, search, defaultOfferSetId, locale, baseCatalogsByMode, fallbackDiscounts, resolvedExperiments, }: {
|
|
44
|
+
export declare const resolvePublishedBillingRuntime: ({ config, featureFlags, mode, search, defaultOfferSetId, locale, country, baseCatalogsByMode, fallbackDiscounts, resolvedExperiments, }: {
|
|
44
45
|
config: ResolvedFunnelRuntimeConfig | null;
|
|
45
46
|
featureFlags: Readonly<Record<string, string | boolean>>;
|
|
46
47
|
mode: RuntimeMode;
|
|
47
48
|
search?: string;
|
|
48
49
|
defaultOfferSetId?: string;
|
|
49
50
|
locale?: string | null;
|
|
51
|
+
country?: string | null;
|
|
50
52
|
baseCatalogsByMode?: Partial<Record<RuntimeMode, BillingPlanCatalog>>;
|
|
51
53
|
fallbackDiscounts?: BillingDiscountList;
|
|
52
54
|
resolvedExperiments?: ResolvedPublishedExperiments;
|
|
@@ -4,7 +4,7 @@ import { buildConfigPaywallPlans, } from './paywallPlans.service.js';
|
|
|
4
4
|
export const EMPTY_PUBLISHED_BILLING_RUNTIME = Object.freeze({
|
|
5
5
|
revisionId: null, sourceVersionId: null, paymentsApiVersion: 'v2', mode: 'live',
|
|
6
6
|
offerSetId: '', paymentProfileId: null, provider: 'stripe', stripePublishableKey: null,
|
|
7
|
-
experimentId: null, variantKey: null, locale: null, experiments: [], flowExperiments: [],
|
|
7
|
+
experimentId: null, variantKey: null, locale: null, country: null, experiments: [], flowExperiments: [],
|
|
8
8
|
featureFlags: Object.freeze({}),
|
|
9
9
|
plans: [], planCatalog: {}, defaultPlanKey: '', discounts: null, upsells: [], downsells: [],
|
|
10
10
|
unavailablePlanKeys: [],
|
|
@@ -28,7 +28,7 @@ const nativePayPalOption = (mapping, paymentProfileId, clientId) => {
|
|
|
28
28
|
return { paymentProfileId, clientId, providerPlanId: mapping.providerPlanId,
|
|
29
29
|
summary: mapping.checkoutSummaryLabel, amountMinor: mapping.amountCents, currency: mapping.currency };
|
|
30
30
|
};
|
|
31
|
-
export const resolvePublishedBillingRuntime = ({ config, featureFlags, mode, search = '', defaultOfferSetId, locale, baseCatalogsByMode, fallbackDiscounts, resolvedExperiments = resolvePublishedRuntimeExperiments(config), }) => {
|
|
31
|
+
export const resolvePublishedBillingRuntime = ({ config, featureFlags, mode, search = '', defaultOfferSetId, locale, country, baseCatalogsByMode, fallbackDiscounts, resolvedExperiments = resolvePublishedRuntimeExperiments(config), }) => {
|
|
32
32
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
33
33
|
const offerSets = (_a = config === null || config === void 0 ? void 0 : config.offerSets) !== null && _a !== void 0 ? _a : [];
|
|
34
34
|
const selection = resolvePublishedOfferSetSelection({
|
|
@@ -39,6 +39,8 @@ export const resolvePublishedBillingRuntime = ({ config, featureFlags, mode, sea
|
|
|
39
39
|
defaultOfferSetId: defaultOfferSetId || (config === null || config === void 0 ? void 0 : config.defaultOfferSetId) || undefined,
|
|
40
40
|
locale,
|
|
41
41
|
localeContractVersion: config === null || config === void 0 ? void 0 : config.localeContractVersion,
|
|
42
|
+
country,
|
|
43
|
+
mode,
|
|
42
44
|
});
|
|
43
45
|
if ((config === null || config === void 0 ? void 0 : config.localeContractVersion) === 1 && offerSets.length > 0 && !selection.offerSetId) {
|
|
44
46
|
throw new Error('Published billing runtime has no valid offer set selection');
|
|
@@ -109,6 +111,7 @@ export const resolvePublishedBillingRuntime = ({ config, featureFlags, mode, sea
|
|
|
109
111
|
experimentId: selection.experimentId,
|
|
110
112
|
variantKey: selection.variantKey,
|
|
111
113
|
locale: selection.locale,
|
|
114
|
+
country: selection.country,
|
|
112
115
|
featureFlags: Object.freeze(pinnedFeatureFlags),
|
|
113
116
|
experiments: resolvedExperiments.experiments,
|
|
114
117
|
flowExperiments: resolvedExperiments.flowExperiments,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnelsgrove/payments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"jsdom": "20.0.3",
|
|
47
47
|
"typescript": "^5",
|
|
48
48
|
"vitest": "^3.2.4",
|
|
49
|
-
"@funnelsgrove/runtime": "0.
|
|
50
|
-
"@funnelsgrove/analytics": "0.
|
|
49
|
+
"@funnelsgrove/runtime": "0.40.0",
|
|
50
|
+
"@funnelsgrove/analytics": "0.23.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@funnelsgrove/runtime": "^0.
|
|
54
|
-
"@funnelsgrove/analytics": "^0.
|
|
53
|
+
"@funnelsgrove/runtime": "^0.40.0",
|
|
54
|
+
"@funnelsgrove/analytics": "^0.23.0"
|
|
55
55
|
}
|
|
56
56
|
}
|