@funnelsgrove/payments 0.1.57 → 0.1.58
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.
|
@@ -5,6 +5,7 @@ import type { RuntimeMode } from '@funnelsgrove/runtime';
|
|
|
5
5
|
import { type RemoteProjectBillingPlan } from './planCatalog.service.js';
|
|
6
6
|
export type PaywallPlan = {
|
|
7
7
|
id: string;
|
|
8
|
+
offerSetKey?: string;
|
|
8
9
|
title: string;
|
|
9
10
|
description?: string;
|
|
10
11
|
providerPlanId?: string;
|
|
@@ -45,7 +46,7 @@ export declare function resolvePaywallPlansFromProjectPlans(projectPlans: readon
|
|
|
45
46
|
export declare function getPaywallPlans(mode: RuntimeMode, planCatalog?: BillingPlanInputCatalog | readonly BillingFallbackPlanConfig[], options?: PaywallPlanResolutionOptions): Promise<readonly PaywallPlan[]>;
|
|
46
47
|
export declare function isStripeConfigured(mode: RuntimeMode): boolean;
|
|
47
48
|
export declare function getStripePromise(_mode: RuntimeMode, runtimePublishableKey?: string | null): Promise<Stripe | null> | null;
|
|
48
|
-
type CheckoutSessionPlanInput = Pick<PaywallPlan, 'amountCents' | 'analyticsPurchaseValue' | 'billingInterval' | 'billingIntervalCount' | 'description' | 'id' | 'providerPlanId' | 'title' | 'followUpProviderPlanId' | 'followUpPlanTitle' | 'followUpBillingInterval' | 'followUpBillingIntervalCount' | 'introIterations'>;
|
|
49
|
+
type CheckoutSessionPlanInput = Pick<PaywallPlan, 'amountCents' | 'analyticsPurchaseValue' | 'billingInterval' | 'billingIntervalCount' | 'description' | 'id' | 'providerPlanId' | 'title' | 'followUpProviderPlanId' | 'followUpPlanTitle' | 'followUpBillingInterval' | 'followUpBillingIntervalCount' | 'introIterations' | 'offerSetKey'>;
|
|
49
50
|
type CheckoutPlanRecurringConfig = {
|
|
50
51
|
interval: BillingPlanInterval;
|
|
51
52
|
intervalCount: number;
|
|
@@ -537,18 +537,19 @@ const normalizeCheckoutAnalyticsMetadata = (metadata, plan) => {
|
|
|
537
537
|
return Object.assign(Object.assign({}, (normalized !== null && normalized !== void 0 ? normalized : {})), { analyticsPurchaseValue });
|
|
538
538
|
};
|
|
539
539
|
export async function createStripeOneTimeCheckout(input) {
|
|
540
|
-
var _a, _b, _c, _d, _e;
|
|
540
|
+
var _a, _b, _c, _d, _e, _f;
|
|
541
541
|
return funnelSdkService.createOneTimeCheckout({
|
|
542
|
+
offerSetKey: ((_a = input.plan.offerSetKey) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
|
|
542
543
|
planId: getPaywallPlanSelectionValue(input.plan),
|
|
543
|
-
providerPlanId: ((
|
|
544
|
+
providerPlanId: ((_b = input.plan.providerPlanId) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
|
|
544
545
|
title: input.plan.title,
|
|
545
|
-
description: ((
|
|
546
|
+
description: ((_c = input.plan.description) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
|
|
546
547
|
amountCents: input.plan.amountCents,
|
|
547
|
-
couponId: ((
|
|
548
|
+
couponId: ((_d = input.couponId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
|
|
548
549
|
analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
|
|
549
|
-
customerEmail: ((
|
|
550
|
+
customerEmail: ((_e = input.customerEmail) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
|
|
550
551
|
returnUrl: input.returnUrl,
|
|
551
|
-
userId: ((
|
|
552
|
+
userId: ((_f = input.user_id) === null || _f === void 0 ? void 0 : _f.trim()) || undefined,
|
|
552
553
|
environment: input.environment,
|
|
553
554
|
runtimeConfig: input.runtimeConfig,
|
|
554
555
|
});
|
|
@@ -584,57 +585,59 @@ export async function chargeStripeOneClickPayment(input) {
|
|
|
584
585
|
});
|
|
585
586
|
}
|
|
586
587
|
export async function createStripeSubscriptionCheckout(input) {
|
|
587
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
588
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
588
589
|
const recurring = resolveCheckoutPlanRecurringConfig(input.plan);
|
|
589
590
|
if (!recurring) {
|
|
590
591
|
throw new Error('Unable to resolve the recurring interval for the selected plan');
|
|
591
592
|
}
|
|
592
593
|
return funnelSdkService.createSubscriptionCheckout({
|
|
594
|
+
offerSetKey: ((_a = input.plan.offerSetKey) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
|
|
593
595
|
planId: getPaywallPlanSelectionValue(input.plan),
|
|
594
|
-
providerPlanId: ((
|
|
596
|
+
providerPlanId: ((_b = input.plan.providerPlanId) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
|
|
595
597
|
title: input.plan.title,
|
|
596
|
-
description: ((
|
|
598
|
+
description: ((_c = input.plan.description) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
|
|
597
599
|
amountCents: input.plan.amountCents,
|
|
598
600
|
billingInterval: recurring.interval,
|
|
599
601
|
billingIntervalCount: recurring.intervalCount,
|
|
600
|
-
followUpProviderPlanId: ((
|
|
601
|
-
followUpPlanTitle: ((
|
|
602
|
+
followUpProviderPlanId: ((_d = input.plan.followUpProviderPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
|
|
603
|
+
followUpPlanTitle: ((_e = input.plan.followUpPlanTitle) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
|
|
602
604
|
followUpBillingInterval: input.plan.followUpBillingInterval,
|
|
603
605
|
followUpBillingIntervalCount: input.plan.followUpBillingIntervalCount,
|
|
604
606
|
introIterations: input.plan.introIterations,
|
|
605
|
-
couponId: ((
|
|
607
|
+
couponId: ((_f = input.couponId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined,
|
|
606
608
|
analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
|
|
607
|
-
customerEmail: ((
|
|
609
|
+
customerEmail: ((_g = input.customerEmail) === null || _g === void 0 ? void 0 : _g.trim()) || undefined,
|
|
608
610
|
returnUrl: input.returnUrl,
|
|
609
|
-
userId: ((
|
|
611
|
+
userId: ((_h = input.user_id) === null || _h === void 0 ? void 0 : _h.trim()) || undefined,
|
|
610
612
|
environment: input.environment,
|
|
611
613
|
runtimeConfig: input.runtimeConfig,
|
|
612
614
|
});
|
|
613
615
|
}
|
|
614
616
|
export async function updateStripeSubscriptionCheckoutPlan(input) {
|
|
615
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
617
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
616
618
|
const recurring = resolveCheckoutPlanRecurringConfig(input.plan);
|
|
617
619
|
if (!recurring) {
|
|
618
620
|
throw new Error('Unable to resolve the recurring interval for the selected plan');
|
|
619
621
|
}
|
|
620
622
|
return funnelSdkService.updateSubscriptionCheckoutPlan({
|
|
621
623
|
checkoutSessionId: input.checkoutSessionId.trim(),
|
|
624
|
+
offerSetKey: ((_a = input.plan.offerSetKey) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
|
|
622
625
|
planId: getPaywallPlanSelectionValue(input.plan),
|
|
623
|
-
providerPlanId: ((
|
|
626
|
+
providerPlanId: ((_b = input.plan.providerPlanId) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
|
|
624
627
|
title: input.plan.title,
|
|
625
|
-
description: ((
|
|
628
|
+
description: ((_c = input.plan.description) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
|
|
626
629
|
amountCents: input.plan.amountCents,
|
|
627
630
|
billingInterval: recurring.interval,
|
|
628
631
|
billingIntervalCount: recurring.intervalCount,
|
|
629
|
-
followUpProviderPlanId: ((
|
|
630
|
-
followUpPlanTitle: ((
|
|
632
|
+
followUpProviderPlanId: ((_d = input.plan.followUpProviderPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
|
|
633
|
+
followUpPlanTitle: ((_e = input.plan.followUpPlanTitle) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
|
|
631
634
|
followUpBillingInterval: input.plan.followUpBillingInterval,
|
|
632
635
|
followUpBillingIntervalCount: input.plan.followUpBillingIntervalCount,
|
|
633
636
|
introIterations: input.plan.introIterations,
|
|
634
|
-
couponId: ((
|
|
637
|
+
couponId: ((_f = input.couponId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined,
|
|
635
638
|
analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
|
|
636
|
-
customerEmail: ((
|
|
637
|
-
userId: ((
|
|
639
|
+
customerEmail: ((_g = input.customerEmail) === null || _g === void 0 ? void 0 : _g.trim()) || undefined,
|
|
640
|
+
userId: ((_h = input.user_id) === null || _h === void 0 ? void 0 : _h.trim()) || undefined,
|
|
638
641
|
environment: input.environment,
|
|
639
642
|
runtimeConfig: input.runtimeConfig,
|
|
640
643
|
});
|
|
@@ -651,25 +654,26 @@ export async function verifyStripeSubscriptionCheckoutPayment(input) {
|
|
|
651
654
|
});
|
|
652
655
|
}
|
|
653
656
|
export async function createStripeCheckoutSession(input) {
|
|
654
|
-
var _a, _b, _c, _d, _e;
|
|
657
|
+
var _a, _b, _c, _d, _e, _f;
|
|
655
658
|
const recurring = resolveCheckoutPlanRecurringConfig(input.plan);
|
|
656
659
|
if (!recurring) {
|
|
657
660
|
throw new Error('Unable to resolve the recurring interval for the selected plan');
|
|
658
661
|
}
|
|
659
662
|
return funnelSdkService.createHostedCheckoutSession({
|
|
663
|
+
offerSetKey: ((_a = input.plan.offerSetKey) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
|
|
660
664
|
planId: getPaywallPlanSelectionValue(input.plan),
|
|
661
|
-
providerPlanId: ((
|
|
665
|
+
providerPlanId: ((_b = input.plan.providerPlanId) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
|
|
662
666
|
title: input.plan.title,
|
|
663
|
-
description: ((
|
|
667
|
+
description: ((_c = input.plan.description) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
|
|
664
668
|
amountCents: input.plan.amountCents,
|
|
665
669
|
billingInterval: recurring.interval,
|
|
666
670
|
billingIntervalCount: recurring.intervalCount,
|
|
667
|
-
couponId: ((
|
|
671
|
+
couponId: ((_d = input.couponId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
|
|
668
672
|
analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
|
|
669
673
|
successUrl: input.successUrl,
|
|
670
674
|
cancelUrl: input.cancelUrl,
|
|
671
|
-
customerEmail: ((
|
|
672
|
-
userId: ((
|
|
675
|
+
customerEmail: ((_e = input.customerEmail) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
|
|
676
|
+
userId: ((_f = input.user_id) === null || _f === void 0 ? void 0 : _f.trim()) || undefined,
|
|
673
677
|
environment: input.environment,
|
|
674
678
|
runtimeConfig: input.runtimeConfig,
|
|
675
679
|
});
|