@funnelsgrove/payments 0.1.42 → 0.1.43
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.
|
@@ -45,7 +45,7 @@ export declare function resolvePaywallPlansFromProjectPlans(projectPlans: readon
|
|
|
45
45
|
export declare function getPaywallPlans(mode: RuntimeMode, planCatalog?: BillingPlanInputCatalog | readonly BillingFallbackPlanConfig[], options?: PaywallPlanResolutionOptions): Promise<readonly PaywallPlan[]>;
|
|
46
46
|
export declare function isStripeConfigured(mode: RuntimeMode): boolean;
|
|
47
47
|
export declare function getStripePromise(mode: RuntimeMode, runtimePublishableKey?: string | null): Promise<Stripe | null> | null;
|
|
48
|
-
type CheckoutSessionPlanInput = Pick<PaywallPlan, 'amountCents' | 'billingInterval' | 'billingIntervalCount' | 'description' | 'id' | 'providerPlanId' | 'title'>;
|
|
48
|
+
type CheckoutSessionPlanInput = Pick<PaywallPlan, 'amountCents' | 'analyticsPurchaseValue' | 'billingInterval' | 'billingIntervalCount' | 'description' | 'id' | 'providerPlanId' | 'title'>;
|
|
49
49
|
type CheckoutPlanRecurringConfig = {
|
|
50
50
|
interval: BillingPlanInterval;
|
|
51
51
|
intervalCount: number;
|
|
@@ -585,6 +585,14 @@ const normalizeAnalyticsMetadata = (metadata) => {
|
|
|
585
585
|
const withCheckoutUrl = checkoutUrl ? Object.assign(Object.assign({}, normalized), { url: checkoutUrl }) : normalized;
|
|
586
586
|
return Object.keys(withCheckoutUrl).length > 0 ? withCheckoutUrl : undefined;
|
|
587
587
|
};
|
|
588
|
+
const normalizeCheckoutAnalyticsMetadata = (metadata, plan) => {
|
|
589
|
+
const normalized = normalizeAnalyticsMetadata(metadata);
|
|
590
|
+
const analyticsPurchaseValue = asNonNegativeNumberOrNull(plan.analyticsPurchaseValue);
|
|
591
|
+
if (analyticsPurchaseValue === null) {
|
|
592
|
+
return normalized;
|
|
593
|
+
}
|
|
594
|
+
return Object.assign(Object.assign({}, (normalized !== null && normalized !== void 0 ? normalized : {})), { analyticsPurchaseValue });
|
|
595
|
+
};
|
|
588
596
|
export async function createStripePaymentIntent(input) {
|
|
589
597
|
var _a, _b;
|
|
590
598
|
const runtimeConfig = resolveStripeRuntimeConfig(input.runtimeConfig);
|
|
@@ -664,7 +672,7 @@ export async function createStripeSubscriptionCheckout(input) {
|
|
|
664
672
|
billingInterval: recurring.interval,
|
|
665
673
|
billingIntervalCount: recurring.intervalCount,
|
|
666
674
|
couponId: ((_c = input.couponId) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
|
|
667
|
-
analyticsMetadata:
|
|
675
|
+
analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
|
|
668
676
|
customerEmail: ((_d = input.customerEmail) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
|
|
669
677
|
returnUrl: input.returnUrl,
|
|
670
678
|
user_id: ((_e = input.user_id) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
|
|
@@ -702,7 +710,7 @@ export async function updateStripeSubscriptionCheckoutPlan(input) {
|
|
|
702
710
|
billingInterval: recurring.interval,
|
|
703
711
|
billingIntervalCount: recurring.intervalCount,
|
|
704
712
|
couponId: ((_c = input.couponId) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
|
|
705
|
-
analyticsMetadata:
|
|
713
|
+
analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
|
|
706
714
|
customerEmail: ((_d = input.customerEmail) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
|
|
707
715
|
user_id: ((_e = input.user_id) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
|
|
708
716
|
environment: input.environment || undefined,
|
|
@@ -763,7 +771,7 @@ export async function createStripeCheckoutSession(input) {
|
|
|
763
771
|
billingInterval: recurring.interval,
|
|
764
772
|
billingIntervalCount: recurring.intervalCount,
|
|
765
773
|
couponId: ((_c = input.couponId) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
|
|
766
|
-
analyticsMetadata:
|
|
774
|
+
analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
|
|
767
775
|
successUrl: input.successUrl,
|
|
768
776
|
cancelUrl: input.cancelUrl,
|
|
769
777
|
customerEmail: ((_d = input.customerEmail) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
|