@funnelsgrove/payments 0.11.3 → 0.11.5

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 (61) hide show
  1. package/README.md +20 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +1 -0
  4. package/dist/providers/stripe/services/checkout/createOneTimeCheckout.d.ts +2 -0
  5. package/dist/providers/stripe/services/checkout/createOneTimeCheckout.js +5 -0
  6. package/dist/providers/stripe/services/checkout/createSubscriptionCheckout.d.ts +2 -0
  7. package/dist/providers/stripe/services/checkout/createSubscriptionCheckout.js +5 -0
  8. package/dist/providers/stripe/services/checkout/requests.d.ts +83 -0
  9. package/dist/providers/stripe/services/checkout/requests.js +99 -0
  10. package/dist/providers/stripe/services/checkout/types.d.ts +83 -0
  11. package/dist/providers/stripe/services/checkout/types.js +1 -0
  12. package/dist/providers/stripe/services/checkout/updateSubscriptionCheckoutPlan.d.ts +2 -0
  13. package/dist/providers/stripe/services/checkout/updateSubscriptionCheckoutPlan.js +5 -0
  14. package/dist/providers/stripe/services/checkout/verifySubscriptionCheckoutPayment.d.ts +2 -0
  15. package/dist/providers/stripe/services/checkout/verifySubscriptionCheckoutPayment.js +5 -0
  16. package/dist/providers/stripe/services/hostedCheckout/createCheckoutSession.d.ts +2 -0
  17. package/dist/providers/stripe/services/hostedCheckout/createCheckoutSession.js +5 -0
  18. package/dist/providers/stripe/services/hostedCheckout/redirectToCheckout.d.ts +2 -0
  19. package/dist/providers/stripe/services/hostedCheckout/redirectToCheckout.js +13 -0
  20. package/dist/providers/stripe/services/hostedCheckout/requests.d.ts +20 -0
  21. package/dist/providers/stripe/services/hostedCheckout/requests.js +26 -0
  22. package/dist/providers/stripe/services/hostedCheckout/types.d.ts +24 -0
  23. package/dist/providers/stripe/services/hostedCheckout/types.js +1 -0
  24. package/dist/providers/stripe/services/oneClick/chargePayment.d.ts +2 -0
  25. package/dist/providers/stripe/services/oneClick/chargePayment.js +5 -0
  26. package/dist/providers/stripe/services/oneClick/completePayment.d.ts +3 -0
  27. package/dist/providers/stripe/services/oneClick/completePayment.js +13 -0
  28. package/dist/providers/stripe/services/oneClick/confirmation.d.ts +6 -0
  29. package/dist/providers/stripe/services/oneClick/confirmation.js +22 -0
  30. package/dist/providers/stripe/services/oneClick/requests.d.ts +20 -0
  31. package/dist/providers/stripe/services/oneClick/requests.js +23 -0
  32. package/dist/providers/stripe/services/oneClick/types.d.ts +40 -0
  33. package/dist/providers/stripe/services/oneClick/types.js +1 -0
  34. package/dist/providers/stripe/services/paymentIntent/createPaymentIntent.d.ts +5 -0
  35. package/dist/providers/stripe/services/paymentIntent/createPaymentIntent.js +8 -0
  36. package/dist/providers/stripe/services/paymentIntent/requests.d.ts +12 -0
  37. package/dist/providers/stripe/services/paymentIntent/requests.js +15 -0
  38. package/dist/providers/stripe/services/paymentIntent/types.d.ts +18 -0
  39. package/dist/providers/stripe/services/paymentIntent/types.js +1 -0
  40. package/dist/providers/stripe/services/shared/checkout.validator.d.ts +3 -0
  41. package/dist/providers/stripe/services/shared/checkout.validator.js +15 -0
  42. package/dist/providers/stripe/services/shared/checkoutMetadata.d.ts +3 -0
  43. package/dist/providers/stripe/services/shared/checkoutMetadata.js +107 -0
  44. package/dist/providers/stripe/services/shared/types.d.ts +2 -0
  45. package/dist/providers/stripe/services/shared/types.js +1 -0
  46. package/dist/providers/stripe/services/stripe.service.d.ts +29 -221
  47. package/dist/providers/stripe/services/stripe.service.js +20 -512
  48. package/dist/providers/stripe/services/stripeClient.d.ts +4 -0
  49. package/dist/providers/stripe/services/stripeClient.js +19 -0
  50. package/dist/services/paywallOffer.service.d.ts +1 -1
  51. package/dist/services/paywallPlans/recurring.d.ts +2 -0
  52. package/dist/services/paywallPlans/recurring.js +72 -0
  53. package/dist/services/paywallPlans/selection.d.ts +11 -0
  54. package/dist/services/paywallPlans/selection.js +144 -0
  55. package/dist/services/paywallPlans/types.d.ts +39 -0
  56. package/dist/services/paywallPlans/types.js +1 -0
  57. package/dist/services/paywallPlans.service.d.ts +10 -0
  58. package/dist/services/paywallPlans.service.js +8 -0
  59. package/dist/services/publishedBillingRuntime.service.d.ts +1 -1
  60. package/dist/services/publishedBillingRuntime.service.js +1 -1
  61. package/package.json +3 -3
package/README.md CHANGED
@@ -102,6 +102,26 @@ When a live funnel still uses one of these, migrate the funnel deliberately with
102
102
 
103
103
  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. Pass the resolved `stripePublishableKey` into shared Stripe checkout hooks so Stripe.js can load while the Checkout Session request is still in flight; the key returned by that request remains the compatibility fallback.
104
104
 
105
+ ## Client implementation structure
106
+
107
+ Provider-neutral plan types, selection and recurrence live in
108
+ `services/paywallPlans/`, exposed through `paywallPlans.service.ts`.
109
+ `publishedBillingRuntime` and timed-offer helpers must not import a provider
110
+ service just to resolve or display plans. Shared config/services are checked for
111
+ provider dependencies in `paymentBoundaries.test.ts`.
112
+
113
+ Stripe browser operations live in `providers/stripe/services/checkout/`,
114
+ `hostedCheckout/`, `oneClick/` and the compatibility-only `paymentIntent/`.
115
+ Keep request mappers (`requests.ts`) beside the short async operation functions;
116
+ common validation and metadata normalization belong in the local `shared/` folder.
117
+ `stripeClient.ts` owns the Stripe.js cache. One-click orchestration calls the
118
+ charge and confirmation functions in its own folder, without a workflow layer.
119
+
120
+ `stripe.service.ts` remains a compatibility export facade. All existing root
121
+ exports, signatures, SDK payloads, errors and confirmation behavior remain intact.
122
+ HTTP transport and V1/V2 endpoint choice belong to the runtime SDK, not payments.
123
+ No automatic charge retry, V1 fallback, or extra conversion event is introduced.
124
+
105
125
  ## Engineering Rules
106
126
 
107
127
  - Keep every provider-specific component, hook, service, and test helper under `src/providers/<provider>`. Add future providers as sibling folders; do not place provider SDK imports in root `components`, `hooks`, or `services`.
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from './config/billing.config.js';
2
2
  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
+ export * from './services/paywallPlans.service.js';
5
6
  export * from './services/runtimeBillingPlanCatalog.service.js';
6
7
  export * from './services/publishedBillingRuntime.service.js';
7
8
  export * from './services/paywallOffer.service.js';
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ export * from './config/billing.config.js';
3
3
  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
+ export * from './services/paywallPlans.service.js';
6
7
  export * from './services/runtimeBillingPlanCatalog.service.js';
7
8
  export * from './services/publishedBillingRuntime.service.js';
8
9
  export * from './services/paywallOffer.service.js';
@@ -0,0 +1,2 @@
1
+ import type { CreateOneTimeCheckoutInput, CreateOneTimeCheckoutResponse } from './types.js';
2
+ export declare function createStripeOneTimeCheckout(input: CreateOneTimeCheckoutInput): Promise<CreateOneTimeCheckoutResponse>;
@@ -0,0 +1,5 @@
1
+ import { funnelSdkService } from '@funnelsgrove/runtime';
2
+ import { toOneTimeCheckoutRequest } from './requests.js';
3
+ export async function createStripeOneTimeCheckout(input) {
4
+ return funnelSdkService.createOneTimeCheckout(toOneTimeCheckoutRequest(input));
5
+ }
@@ -0,0 +1,2 @@
1
+ import type { CreateSubscriptionCheckoutInput, CreateSubscriptionCheckoutResponse } from './types.js';
2
+ export declare function createStripeSubscriptionCheckout(input: CreateSubscriptionCheckoutInput): Promise<CreateSubscriptionCheckoutResponse>;
@@ -0,0 +1,5 @@
1
+ import { funnelSdkService } from '@funnelsgrove/runtime';
2
+ import { toSubscriptionCheckoutRequest } from './requests.js';
3
+ export async function createStripeSubscriptionCheckout(input) {
4
+ return funnelSdkService.createSubscriptionCheckout(toSubscriptionCheckoutRequest(input));
5
+ }
@@ -0,0 +1,83 @@
1
+ import type { CreateOneTimeCheckoutInput, CreateSubscriptionCheckoutInput, UpdateSubscriptionCheckoutPlanInput, VerifySubscriptionCheckoutPaymentInput } from './types.js';
2
+ export declare const toOneTimeCheckoutRequest: (input: CreateOneTimeCheckoutInput) => {
3
+ planKey: string;
4
+ runtimeConfigRevisionId: string | null | undefined;
5
+ paymentProfileId: string | null | undefined;
6
+ provider: "stripe" | null | undefined;
7
+ anonymousUserId: string | null | undefined;
8
+ idempotencyKey: string | null | undefined;
9
+ offerSetId: string | undefined;
10
+ offerSetKey: string | undefined;
11
+ planId: string;
12
+ providerPlanId: string | undefined;
13
+ title: string;
14
+ description: string | undefined;
15
+ amountCents: number;
16
+ couponId: string | undefined;
17
+ analyticsMetadata: Record<string, unknown> | undefined;
18
+ customerEmail: string | undefined;
19
+ returnUrl: string;
20
+ userId: string | undefined;
21
+ environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
22
+ runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
23
+ };
24
+ export declare const toSubscriptionCheckoutRequest: (input: CreateSubscriptionCheckoutInput) => {
25
+ offerSetId: string | undefined;
26
+ offerSetKey: string | undefined;
27
+ planId: string;
28
+ planKey: string;
29
+ providerPlanId: string | undefined;
30
+ provider: "stripe" | null | undefined;
31
+ paymentProfileId: string | undefined;
32
+ runtimeConfigRevisionId: string | undefined;
33
+ anonymousUserId: string | undefined;
34
+ title: string;
35
+ description: string | undefined;
36
+ amountCents: number;
37
+ billingInterval: import("../../../../index.js").BillingPlanInterval;
38
+ billingIntervalCount: number;
39
+ followUpProviderPlanId: string | undefined;
40
+ followUpPlanTitle: string | undefined;
41
+ followUpBillingInterval: import("../../../../index.js").BillingPlanInterval | undefined;
42
+ followUpBillingIntervalCount: number | undefined;
43
+ introIterations: number | undefined;
44
+ couponId: string | undefined;
45
+ analyticsMetadata: Record<string, unknown> | undefined;
46
+ customerEmail: string | undefined;
47
+ returnUrl: string;
48
+ userId: string | undefined;
49
+ environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
50
+ runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
51
+ };
52
+ export declare const toSubscriptionCheckoutPlanRequest: (input: UpdateSubscriptionCheckoutPlanInput) => {
53
+ checkoutSessionId: string;
54
+ offerSetId: string | undefined;
55
+ offerSetKey: string | undefined;
56
+ planId: string;
57
+ planKey: string;
58
+ providerPlanId: string | undefined;
59
+ provider: "stripe" | null | undefined;
60
+ paymentProfileId: string | undefined;
61
+ runtimeConfigRevisionId: string | undefined;
62
+ title: string;
63
+ description: string | undefined;
64
+ amountCents: number;
65
+ billingInterval: import("../../../../index.js").BillingPlanInterval;
66
+ billingIntervalCount: number;
67
+ followUpProviderPlanId: string | undefined;
68
+ followUpPlanTitle: string | undefined;
69
+ followUpBillingInterval: import("../../../../index.js").BillingPlanInterval | undefined;
70
+ followUpBillingIntervalCount: number | undefined;
71
+ introIterations: number | undefined;
72
+ couponId: string | undefined;
73
+ analyticsMetadata: Record<string, unknown> | undefined;
74
+ customerEmail: string | undefined;
75
+ userId: string | undefined;
76
+ environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
77
+ runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
78
+ };
79
+ export declare const toSubscriptionCheckoutStatusRequest: (input: VerifySubscriptionCheckoutPaymentInput) => {
80
+ checkoutSessionId: string;
81
+ environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
82
+ runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
83
+ };
@@ -0,0 +1,99 @@
1
+ import { getPaywallPlanRequestId } from '../../../../services/paywallPlans/selection.js';
2
+ import { normalizeCheckoutAnalyticsMetadata } from '../shared/checkoutMetadata.js';
3
+ import { requireCheckoutRecurringConfig, requireCheckoutSessionId, } from '../shared/checkout.validator.js';
4
+ export const toOneTimeCheckoutRequest = (input) => {
5
+ var _a, _b, _c, _d, _e, _f, _g, _h;
6
+ return {
7
+ planKey: ((_a = input.plan.funnelPlanKey) === null || _a === void 0 ? void 0 : _a.trim()) || input.plan.id,
8
+ runtimeConfigRevisionId: input.runtimeConfigRevisionId,
9
+ paymentProfileId: input.paymentProfileId,
10
+ provider: input.provider,
11
+ anonymousUserId: input.anonymousUserId,
12
+ idempotencyKey: input.idempotencyKey,
13
+ offerSetId: ((_b = input.plan.offerSetId) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
14
+ offerSetKey: ((_c = input.plan.offerSetKey) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
15
+ planId: getPaywallPlanRequestId(input.plan),
16
+ providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
17
+ title: input.plan.title,
18
+ description: ((_e = input.plan.description) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
19
+ amountCents: input.plan.amountCents,
20
+ couponId: ((_f = input.couponId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined,
21
+ analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
22
+ customerEmail: ((_g = input.customerEmail) === null || _g === void 0 ? void 0 : _g.trim()) || undefined,
23
+ returnUrl: input.returnUrl,
24
+ userId: ((_h = input.user_id) === null || _h === void 0 ? void 0 : _h.trim()) || undefined,
25
+ environment: input.environment,
26
+ runtimeConfig: input.runtimeConfig,
27
+ };
28
+ };
29
+ export const toSubscriptionCheckoutRequest = (input) => {
30
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
31
+ const recurring = requireCheckoutRecurringConfig(input.plan);
32
+ return {
33
+ offerSetId: ((_a = input.plan.offerSetId) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
34
+ offerSetKey: ((_b = input.plan.offerSetKey) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
35
+ planId: getPaywallPlanRequestId(input.plan),
36
+ planKey: ((_c = input.plan.funnelPlanKey) === null || _c === void 0 ? void 0 : _c.trim()) || input.plan.id,
37
+ providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
38
+ provider: input.provider,
39
+ paymentProfileId: ((_e = input.paymentProfileId) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
40
+ runtimeConfigRevisionId: ((_f = input.runtimeConfigRevisionId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined,
41
+ anonymousUserId: ((_g = input.anonymousUserId) === null || _g === void 0 ? void 0 : _g.trim()) || undefined,
42
+ title: input.plan.title,
43
+ description: ((_h = input.plan.description) === null || _h === void 0 ? void 0 : _h.trim()) || undefined,
44
+ amountCents: input.plan.amountCents,
45
+ billingInterval: recurring.interval,
46
+ billingIntervalCount: recurring.intervalCount,
47
+ followUpProviderPlanId: ((_j = input.plan.followUpProviderPlanId) === null || _j === void 0 ? void 0 : _j.trim()) || undefined,
48
+ followUpPlanTitle: ((_k = input.plan.followUpPlanTitle) === null || _k === void 0 ? void 0 : _k.trim()) || undefined,
49
+ followUpBillingInterval: input.plan.followUpBillingInterval,
50
+ followUpBillingIntervalCount: input.plan.followUpBillingIntervalCount,
51
+ introIterations: input.plan.introIterations,
52
+ couponId: ((_l = input.couponId) === null || _l === void 0 ? void 0 : _l.trim()) || undefined,
53
+ analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
54
+ customerEmail: ((_m = input.customerEmail) === null || _m === void 0 ? void 0 : _m.trim()) || undefined,
55
+ returnUrl: input.returnUrl,
56
+ userId: ((_o = input.user_id) === null || _o === void 0 ? void 0 : _o.trim()) || undefined,
57
+ environment: input.environment,
58
+ runtimeConfig: input.runtimeConfig,
59
+ };
60
+ };
61
+ export const toSubscriptionCheckoutPlanRequest = (input) => {
62
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
63
+ const recurring = requireCheckoutRecurringConfig(input.plan);
64
+ return {
65
+ checkoutSessionId: input.checkoutSessionId.trim(),
66
+ offerSetId: ((_a = input.plan.offerSetId) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
67
+ offerSetKey: ((_b = input.plan.offerSetKey) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
68
+ planId: getPaywallPlanRequestId(input.plan),
69
+ planKey: ((_c = input.plan.funnelPlanKey) === null || _c === void 0 ? void 0 : _c.trim()) || input.plan.id,
70
+ providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
71
+ provider: input.provider,
72
+ paymentProfileId: ((_e = input.paymentProfileId) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
73
+ runtimeConfigRevisionId: ((_f = input.runtimeConfigRevisionId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined,
74
+ title: input.plan.title,
75
+ description: ((_g = input.plan.description) === null || _g === void 0 ? void 0 : _g.trim()) || undefined,
76
+ amountCents: input.plan.amountCents,
77
+ billingInterval: recurring.interval,
78
+ billingIntervalCount: recurring.intervalCount,
79
+ followUpProviderPlanId: ((_h = input.plan.followUpProviderPlanId) === null || _h === void 0 ? void 0 : _h.trim()) || undefined,
80
+ followUpPlanTitle: ((_j = input.plan.followUpPlanTitle) === null || _j === void 0 ? void 0 : _j.trim()) || undefined,
81
+ followUpBillingInterval: input.plan.followUpBillingInterval,
82
+ followUpBillingIntervalCount: input.plan.followUpBillingIntervalCount,
83
+ introIterations: input.plan.introIterations,
84
+ couponId: ((_k = input.couponId) === null || _k === void 0 ? void 0 : _k.trim()) || undefined,
85
+ analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
86
+ customerEmail: ((_l = input.customerEmail) === null || _l === void 0 ? void 0 : _l.trim()) || undefined,
87
+ userId: ((_m = input.user_id) === null || _m === void 0 ? void 0 : _m.trim()) || undefined,
88
+ environment: input.environment,
89
+ runtimeConfig: input.runtimeConfig,
90
+ };
91
+ };
92
+ export const toSubscriptionCheckoutStatusRequest = (input) => {
93
+ const checkoutSessionId = requireCheckoutSessionId(input.checkoutSessionId);
94
+ return {
95
+ checkoutSessionId,
96
+ environment: input.environment,
97
+ runtimeConfig: input.runtimeConfig,
98
+ };
99
+ };
@@ -0,0 +1,83 @@
1
+ import type { CheckoutSessionPlanInput } from '../../../../services/paywallPlans/types.js';
2
+ import type { RuntimeMode } from '@funnelsgrove/runtime';
3
+ import type { StripeRuntimeConfigOverrides } from '../shared/types.js';
4
+ export type CreateOneTimeCheckoutInput = {
5
+ plan: CheckoutSessionPlanInput;
6
+ runtimeConfigRevisionId?: string | null;
7
+ paymentProfileId?: string | null;
8
+ provider?: 'stripe' | null;
9
+ anonymousUserId?: string | null;
10
+ idempotencyKey?: string | null;
11
+ couponId?: string | null;
12
+ analyticsMetadata?: Record<string, unknown> | null;
13
+ customerEmail?: string | null;
14
+ returnUrl: string;
15
+ user_id?: string | null;
16
+ environment?: RuntimeMode;
17
+ runtimeConfig?: StripeRuntimeConfigOverrides;
18
+ };
19
+ export type CreateOneTimeCheckoutResponse = {
20
+ clientSecret: string;
21
+ checkoutSessionId?: string;
22
+ stripePublishableKey?: string;
23
+ environment?: 'test' | 'live';
24
+ paymentProfileId?: string;
25
+ userId?: string;
26
+ anonymousUserId?: string;
27
+ funnelEndUserId?: string;
28
+ };
29
+ export type CreateSubscriptionCheckoutInput = {
30
+ plan: CheckoutSessionPlanInput;
31
+ runtimeConfigRevisionId?: string | null;
32
+ paymentProfileId?: string | null;
33
+ provider?: 'stripe' | null;
34
+ anonymousUserId?: string | null;
35
+ couponId?: string | null;
36
+ analyticsMetadata?: Record<string, unknown> | null;
37
+ customerEmail?: string | null;
38
+ returnUrl: string;
39
+ user_id?: string | null;
40
+ environment?: RuntimeMode;
41
+ runtimeConfig?: StripeRuntimeConfigOverrides;
42
+ };
43
+ export type CreateSubscriptionCheckoutResponse = {
44
+ clientSecret: string;
45
+ checkoutSessionId?: string;
46
+ subscriptionId?: string;
47
+ stripePublishableKey?: string;
48
+ environment?: 'test' | 'live';
49
+ paymentProfileId?: string;
50
+ userId?: string;
51
+ anonymousUserId?: string;
52
+ funnelEndUserId?: string;
53
+ };
54
+ export type UpdateSubscriptionCheckoutPlanInput = {
55
+ checkoutSessionId: string;
56
+ plan: CheckoutSessionPlanInput;
57
+ runtimeConfigRevisionId?: string | null;
58
+ paymentProfileId?: string | null;
59
+ provider?: 'stripe' | null;
60
+ couponId?: string | null;
61
+ analyticsMetadata?: Record<string, unknown> | null;
62
+ customerEmail?: string | null;
63
+ user_id?: string | null;
64
+ environment?: RuntimeMode;
65
+ runtimeConfig?: StripeRuntimeConfigOverrides;
66
+ };
67
+ export type UpdateSubscriptionCheckoutPlanResponse = {
68
+ checkoutSessionId: string;
69
+ environment?: 'test' | 'live';
70
+ };
71
+ export type VerifySubscriptionCheckoutPaymentInput = {
72
+ checkoutSessionId: string;
73
+ environment?: RuntimeMode;
74
+ runtimeConfig?: StripeRuntimeConfigOverrides;
75
+ };
76
+ export type VerifySubscriptionCheckoutPaymentResponse = {
77
+ checkoutSessionId: string;
78
+ paid: boolean;
79
+ paymentStatus?: string | null;
80
+ status?: string | null;
81
+ environment?: 'test' | 'live';
82
+ analyticsMetadata?: Record<string, unknown>;
83
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { UpdateSubscriptionCheckoutPlanInput, UpdateSubscriptionCheckoutPlanResponse } from './types.js';
2
+ export declare function updateStripeSubscriptionCheckoutPlan(input: UpdateSubscriptionCheckoutPlanInput): Promise<UpdateSubscriptionCheckoutPlanResponse>;
@@ -0,0 +1,5 @@
1
+ import { funnelSdkService } from '@funnelsgrove/runtime';
2
+ import { toSubscriptionCheckoutPlanRequest } from './requests.js';
3
+ export async function updateStripeSubscriptionCheckoutPlan(input) {
4
+ return funnelSdkService.updateSubscriptionCheckoutPlan(toSubscriptionCheckoutPlanRequest(input));
5
+ }
@@ -0,0 +1,2 @@
1
+ import type { VerifySubscriptionCheckoutPaymentInput, VerifySubscriptionCheckoutPaymentResponse } from './types.js';
2
+ export declare function verifyStripeSubscriptionCheckoutPayment(input: VerifySubscriptionCheckoutPaymentInput): Promise<VerifySubscriptionCheckoutPaymentResponse>;
@@ -0,0 +1,5 @@
1
+ import { funnelSdkService } from '@funnelsgrove/runtime';
2
+ import { toSubscriptionCheckoutStatusRequest } from './requests.js';
3
+ export async function verifyStripeSubscriptionCheckoutPayment(input) {
4
+ return funnelSdkService.verifySubscriptionCheckout(toSubscriptionCheckoutStatusRequest(input));
5
+ }
@@ -0,0 +1,2 @@
1
+ import type { CreateCheckoutSessionInput, CreateCheckoutSessionResponse } from './types.js';
2
+ export declare function createStripeCheckoutSession(input: CreateCheckoutSessionInput): Promise<CreateCheckoutSessionResponse>;
@@ -0,0 +1,5 @@
1
+ import { funnelSdkService } from '@funnelsgrove/runtime';
2
+ import { toHostedCheckoutRequest } from './requests.js';
3
+ export async function createStripeCheckoutSession(input) {
4
+ return funnelSdkService.createHostedCheckoutSession(toHostedCheckoutRequest(input));
5
+ }
@@ -0,0 +1,2 @@
1
+ import type { CreateCheckoutSessionInput } from './types.js';
2
+ export declare function redirectToStripeCheckout(input: CreateCheckoutSessionInput): Promise<string>;
@@ -0,0 +1,13 @@
1
+ import { createStripeCheckoutSession } from './createCheckoutSession.js';
2
+ export async function redirectToStripeCheckout(input) {
3
+ var _a;
4
+ const response = await createStripeCheckoutSession(input);
5
+ const checkoutUrl = (_a = response.url) === null || _a === void 0 ? void 0 : _a.trim();
6
+ if (!checkoutUrl) {
7
+ throw new Error('Stripe did not return a checkout url');
8
+ }
9
+ if (typeof window !== 'undefined') {
10
+ window.location.assign(checkoutUrl);
11
+ }
12
+ return checkoutUrl;
13
+ }
@@ -0,0 +1,20 @@
1
+ import type { CreateCheckoutSessionInput } from './types.js';
2
+ export declare const toHostedCheckoutRequest: (input: CreateCheckoutSessionInput) => {
3
+ offerSetId: string | undefined;
4
+ offerSetKey: string | undefined;
5
+ planId: string;
6
+ providerPlanId: string | undefined;
7
+ title: string;
8
+ description: string | undefined;
9
+ amountCents: number;
10
+ billingInterval: import("../../../../index.js").BillingPlanInterval;
11
+ billingIntervalCount: number;
12
+ couponId: string | undefined;
13
+ analyticsMetadata: Record<string, unknown> | undefined;
14
+ successUrl: string;
15
+ cancelUrl: string;
16
+ customerEmail: string | undefined;
17
+ userId: string | undefined;
18
+ environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
19
+ runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
20
+ };
@@ -0,0 +1,26 @@
1
+ import { requireCheckoutRecurringConfig } from '../shared/checkout.validator.js';
2
+ import { getPaywallPlanRequestId } from '../../../../services/paywallPlans/selection.js';
3
+ import { normalizeCheckoutAnalyticsMetadata } from '../shared/checkoutMetadata.js';
4
+ export const toHostedCheckoutRequest = (input) => {
5
+ var _a, _b, _c, _d, _e, _f, _g;
6
+ const recurring = requireCheckoutRecurringConfig(input.plan);
7
+ return {
8
+ offerSetId: ((_a = input.plan.offerSetId) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
9
+ offerSetKey: ((_b = input.plan.offerSetKey) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
10
+ planId: getPaywallPlanRequestId(input.plan),
11
+ providerPlanId: ((_c = input.plan.providerPlanId) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
12
+ title: input.plan.title,
13
+ description: ((_d = input.plan.description) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
14
+ amountCents: input.plan.amountCents,
15
+ billingInterval: recurring.interval,
16
+ billingIntervalCount: recurring.intervalCount,
17
+ couponId: ((_e = input.couponId) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
18
+ analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
19
+ successUrl: input.successUrl,
20
+ cancelUrl: input.cancelUrl,
21
+ customerEmail: ((_f = input.customerEmail) === null || _f === void 0 ? void 0 : _f.trim()) || undefined,
22
+ userId: ((_g = input.user_id) === null || _g === void 0 ? void 0 : _g.trim()) || undefined,
23
+ environment: input.environment,
24
+ runtimeConfig: input.runtimeConfig,
25
+ };
26
+ };
@@ -0,0 +1,24 @@
1
+ import type { CheckoutSessionPlanInput } from '../../../../services/paywallPlans/types.js';
2
+ import type { RuntimeMode } from '@funnelsgrove/runtime';
3
+ import type { StripeRuntimeConfigOverrides } from '../shared/types.js';
4
+ export type CreateCheckoutSessionInput = {
5
+ plan: CheckoutSessionPlanInput;
6
+ successUrl: string;
7
+ cancelUrl: string;
8
+ couponId?: string | null;
9
+ analyticsMetadata?: Record<string, unknown> | null;
10
+ customerEmail?: string | null;
11
+ user_id?: string | null;
12
+ environment?: RuntimeMode;
13
+ runtimeConfig?: StripeRuntimeConfigOverrides;
14
+ };
15
+ export type CreateCheckoutSessionResponse = {
16
+ sessionId?: string;
17
+ url: string;
18
+ stripePublishableKey?: string;
19
+ environment?: 'test' | 'live';
20
+ paymentProfileId?: string;
21
+ userId?: string;
22
+ anonymousUserId?: string;
23
+ funnelEndUserId?: string;
24
+ };
@@ -0,0 +1,2 @@
1
+ import type { ChargeOneClickPaymentInput, ChargeOneClickPaymentResponse } from './types.js';
2
+ export declare function chargeStripeOneClickPayment(input: ChargeOneClickPaymentInput): Promise<ChargeOneClickPaymentResponse>;
@@ -0,0 +1,5 @@
1
+ import { funnelSdkService } from '@funnelsgrove/runtime';
2
+ import { toOneClickPaymentRequest } from './requests.js';
3
+ export async function chargeStripeOneClickPayment(input) {
4
+ return funnelSdkService.chargeOneClickPayment(toOneClickPaymentRequest(input));
5
+ }
@@ -0,0 +1,3 @@
1
+ import type { CompleteStripeOneClickPaymentInput, CompleteStripeOneClickPaymentResponse } from './types.js';
2
+ export declare const requiresStripeOneClickConfirmation: (status: string) => boolean;
3
+ export declare function completeStripeOneClickPayment(input: CompleteStripeOneClickPaymentInput): Promise<CompleteStripeOneClickPaymentResponse>;
@@ -0,0 +1,13 @@
1
+ import { chargeStripeOneClickPayment } from './chargePayment.js';
2
+ import { confirmOneClickPayment } from './confirmation.js';
3
+ export const requiresStripeOneClickConfirmation = (status) => {
4
+ return status === 'requires_action' || status === 'requires_confirmation';
5
+ };
6
+ export async function completeStripeOneClickPayment(input) {
7
+ const payment = await chargeStripeOneClickPayment(input);
8
+ if (!requiresStripeOneClickConfirmation(payment.status)) {
9
+ return Object.assign(Object.assign({}, payment), { confirmationAttempted: false });
10
+ }
11
+ const status = await confirmOneClickPayment(payment, input);
12
+ return Object.assign(Object.assign({}, payment), { status, confirmationAttempted: true });
13
+ }
@@ -0,0 +1,6 @@
1
+ import type { RuntimeMode } from '@funnelsgrove/runtime';
2
+ import type { ChargeOneClickPaymentResponse } from './types.js';
3
+ export declare const confirmOneClickPayment: (payment: ChargeOneClickPaymentResponse, input: {
4
+ returnUrl: string;
5
+ environment?: RuntimeMode;
6
+ }) => Promise<string>;
@@ -0,0 +1,22 @@
1
+ import { getStripePromise } from '../stripeClient.js';
2
+ export const confirmOneClickPayment = async (payment, input) => {
3
+ var _a, _b, _c, _d, _e, _f;
4
+ const clientSecret = (_a = payment.clientSecret) === null || _a === void 0 ? void 0 : _a.trim();
5
+ const stripePublishableKey = (_b = payment.stripePublishableKey) === null || _b === void 0 ? void 0 : _b.trim();
6
+ if (!clientSecret || !stripePublishableKey) {
7
+ throw new Error('One-click payment requires Stripe confirmation, but confirmation details are missing.');
8
+ }
9
+ const stripe = await getStripePromise((_d = (_c = payment.environment) !== null && _c !== void 0 ? _c : input.environment) !== null && _d !== void 0 ? _d : 'live', stripePublishableKey);
10
+ if (!stripe) {
11
+ throw new Error('Stripe could not be initialized for one-click payment confirmation.');
12
+ }
13
+ const confirmation = await stripe.confirmPayment({
14
+ clientSecret,
15
+ confirmParams: { return_url: input.returnUrl },
16
+ redirect: 'if_required',
17
+ });
18
+ if (confirmation.error) {
19
+ throw new Error(confirmation.error.message || 'Unable to confirm one-click payment.');
20
+ }
21
+ return (_f = (_e = confirmation.paymentIntent) === null || _e === void 0 ? void 0 : _e.status) !== null && _f !== void 0 ? _f : payment.status;
22
+ };
@@ -0,0 +1,20 @@
1
+ import type { ChargeOneClickPaymentInput } from './types.js';
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
+ currency: string | undefined;
12
+ description: string | undefined;
13
+ analyticsMetadata: Record<string, unknown> | undefined;
14
+ userId: string | undefined;
15
+ stripeCustomerId: string | undefined;
16
+ checkoutSessionId: string | undefined;
17
+ idempotencyKey: string | undefined;
18
+ environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
19
+ runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
20
+ };
@@ -0,0 +1,23 @@
1
+ import { normalizeAnalyticsMetadata } from '../shared/checkoutMetadata.js';
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
+ };
23
+ };
@@ -0,0 +1,40 @@
1
+ import type { RuntimeMode } from '@funnelsgrove/runtime';
2
+ import type { StripeRuntimeConfigOverrides } from '../shared/types.js';
3
+ export type ChargeOneClickPaymentInput = {
4
+ planId: string;
5
+ planKey?: string | null;
6
+ offerSetId?: string | null;
7
+ runtimeConfigRevisionId?: string | null;
8
+ paymentProfileId?: string | null;
9
+ provider?: 'stripe' | null;
10
+ providerPlanId?: string | null;
11
+ amountCents: number;
12
+ analyticsMetadata?: Record<string, unknown> | null;
13
+ checkoutSessionId?: string | null;
14
+ currency?: string | null;
15
+ description?: string | null;
16
+ idempotencyKey?: string | null;
17
+ stripeCustomerId?: string | null;
18
+ userId?: string | null;
19
+ /** @deprecated Use stripeCustomerId. */
20
+ stripe_customer_id?: string | null;
21
+ /** @deprecated Use userId. */
22
+ user_id?: string | null;
23
+ environment?: RuntimeMode;
24
+ runtimeConfig?: StripeRuntimeConfigOverrides;
25
+ };
26
+ export type ChargeOneClickPaymentResponse = {
27
+ paymentIntentId: string;
28
+ status: string;
29
+ amountCents?: number;
30
+ clientSecret?: string;
31
+ currency?: string;
32
+ environment?: 'test' | 'live';
33
+ stripePublishableKey?: string;
34
+ };
35
+ export type CompleteStripeOneClickPaymentInput = ChargeOneClickPaymentInput & {
36
+ returnUrl: string;
37
+ };
38
+ export type CompleteStripeOneClickPaymentResponse = ChargeOneClickPaymentResponse & {
39
+ confirmationAttempted: boolean;
40
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { CreatePaymentIntentInput, CreatePaymentIntentResponse } from './types.js';
2
+ /**
3
+ * @deprecated Use createStripeOneTimeCheckout for one-time paywall checkout.
4
+ */
5
+ export declare function createStripePaymentIntent(input: CreatePaymentIntentInput): Promise<CreatePaymentIntentResponse>;
@@ -0,0 +1,8 @@
1
+ import { funnelSdkService } from '@funnelsgrove/runtime';
2
+ import { toPaymentIntentRequest } from './requests.js';
3
+ /**
4
+ * @deprecated Use createStripeOneTimeCheckout for one-time paywall checkout.
5
+ */
6
+ export async function createStripePaymentIntent(input) {
7
+ return funnelSdkService.createOneTimePaymentIntent(toPaymentIntentRequest(input));
8
+ }