@funnelsgrove/payments 0.8.0 → 0.9.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 +2 -2
- package/dist/providers/stripe/components/StripeCheckoutExpressCheckoutButton.js +11 -3
- package/dist/providers/stripe/hooks/useStripeSubscriptionCheckoutSession.d.ts +6 -3
- package/dist/providers/stripe/hooks/useStripeSubscriptionCheckoutSession.js +26 -8
- package/dist/providers/stripe/services/stripe.service.d.ts +5 -1
- package/dist/providers/stripe/services/stripe.service.js +13 -8
- package/dist/services/publishedBillingRuntime.service.d.ts +1 -0
- package/dist/services/publishedBillingRuntime.service.js +4 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -106,11 +106,11 @@ Funnels should call `resolvePublishedBillingRuntime` once at their runtime-provi
|
|
|
106
106
|
- Stripe owns real card fields and wallet controls. Local wallet buttons are placeholders until Stripe confirms availability.
|
|
107
107
|
- Keep `planId` as the funnel plan key and send Stripe's price id only as `providerPlanId`; the API uses both fields to resolve the active test/live offer mapping.
|
|
108
108
|
- Wallet unavailable state must fall back to card/manual checkout or disappear.
|
|
109
|
-
- Count `checkout_started` only at shared UI boundaries: when a shared card dialog opens or when Stripe reports
|
|
109
|
+
- Count `checkout_started` only at shared UI boundaries: when a shared card dialog opens or when Stripe reports Apple Pay / Google Pay intent. Checkout Sessions use confirmation as a fallback because Stripe omits their click callback.
|
|
110
110
|
- Pass `checkoutAnalytics` to every current shared dialog and wallet surface. The package then owns `checkout_started`, `add_payment_info`, and verified `checkout_completed`, all deduplicated by the actual Checkout Session.
|
|
111
111
|
- Call funnel lifecycle `completeStep` only from the shared checkout `onSuccess` callback. Payment-info submission is not step completion.
|
|
112
112
|
- Wallet slots may create render-only Checkout Sessions on mount so Apple Pay and Google Pay render before the visitor taps. Session creation is technical preparation and must never emit `checkout_started`.
|
|
113
|
-
- Shared checkout analytics deduplicates `checkout_started` by Checkout Session id.
|
|
113
|
+
- Shared checkout analytics deduplicates `checkout_started` by Checkout Session id. Wallet confirmation may retry the start signal when the click callback is unavailable, without creating a duplicate.
|
|
114
114
|
- Do not call `publicAnalyticsSdk.trackCheckoutStarted`, `trackPaymentInfoSubmitted`, or `trackCheckoutCompleted` directly from funnel checkout components.
|
|
115
115
|
- Funnel paywalls should style wallet buttons through the shared slot API: `className` for the Stripe button/placeholder, `slotClassName` for the outer slot, `appearance` for Stripe Elements appearance, and `options` for Stripe Express Checkout options.
|
|
116
116
|
- Keep discount math reusable here, but keep offer activation timing in funnel code.
|
|
@@ -95,8 +95,18 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAna
|
|
|
95
95
|
}
|
|
96
96
|
await (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess());
|
|
97
97
|
};
|
|
98
|
+
const queueCheckoutStarted = (paymentMethod) => {
|
|
99
|
+
if (!checkoutAnalytics) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
queueStripeSubscriptionCheckoutStarted(Object.assign(Object.assign({}, checkoutAnalytics), { checkoutSessionId, checkoutStartSource: 'wallet_click', paymentMethod }));
|
|
103
|
+
};
|
|
98
104
|
const handleConfirm = async (event) => {
|
|
99
105
|
var _a, _b, _c;
|
|
106
|
+
// Checkout Sessions omits the Express Checkout onClick callback. Confirmation
|
|
107
|
+
// is therefore the first reliable wallet-intent boundary for this provider.
|
|
108
|
+
// Session-based analytics deduplication keeps this idempotent if onClick fires.
|
|
109
|
+
queueCheckoutStarted(event.expressPaymentType);
|
|
100
110
|
if (checkoutState.type !== 'success') {
|
|
101
111
|
const message = checkoutState.type === 'error'
|
|
102
112
|
? checkoutState.error.message
|
|
@@ -163,9 +173,7 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAna
|
|
|
163
173
|
}
|
|
164
174
|
};
|
|
165
175
|
const handleClick = (event) => {
|
|
166
|
-
|
|
167
|
-
queueStripeSubscriptionCheckoutStarted(Object.assign(Object.assign({}, checkoutAnalytics), { checkoutSessionId, checkoutStartSource: 'wallet_click', paymentMethod: event.expressPaymentType }));
|
|
168
|
-
}
|
|
176
|
+
queueCheckoutStarted(event.expressPaymentType);
|
|
169
177
|
event.resolve();
|
|
170
178
|
};
|
|
171
179
|
return (_jsxs(_Fragment, { children: [_jsx("div", { className: [
|
|
@@ -14,6 +14,9 @@ export type StripeSubscriptionCheckoutSessionInput = {
|
|
|
14
14
|
plan?: PaywallPlan | null;
|
|
15
15
|
returnUrl: string;
|
|
16
16
|
runtimeConfig?: StripeRuntimeConfigOverrides;
|
|
17
|
+
runtimeConfigRevisionId?: string | null;
|
|
18
|
+
paymentProfileId?: string | null;
|
|
19
|
+
provider?: 'stripe' | null;
|
|
17
20
|
stripePublishableKey?: string | null;
|
|
18
21
|
userId?: string | null;
|
|
19
22
|
};
|
|
@@ -43,10 +46,10 @@ export type StripeSubscriptionCheckoutSession = {
|
|
|
43
46
|
updateCheckoutSessionPlan: () => Promise<boolean>;
|
|
44
47
|
};
|
|
45
48
|
export declare const buildStripeSubscriptionCheckoutPreparationAnalyticsMetadata: (analyticsMetadata: Record<string, unknown> | null | undefined, options?: StripeSubscriptionCheckoutPreparationOptions) => Record<string, unknown> | null | undefined;
|
|
46
|
-
export type StripeSubscriptionCheckoutIntentKeyInput = Pick<StripeSubscriptionCheckoutSessionInput, 'checkoutMode' | 'couponId' | 'customerEmail' | 'returnUrl' | 'runtimeConfig' | 'stripePublishableKey' | 'userId'> & {
|
|
49
|
+
export type StripeSubscriptionCheckoutIntentKeyInput = Pick<StripeSubscriptionCheckoutSessionInput, 'checkoutMode' | 'couponId' | 'customerEmail' | 'paymentProfileId' | 'provider' | 'returnUrl' | 'runtimeConfig' | 'runtimeConfigRevisionId' | 'stripePublishableKey' | 'userId'> & {
|
|
47
50
|
analyticsMetadata?: Record<string, unknown> | null;
|
|
48
51
|
};
|
|
49
|
-
export declare function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponId, customerEmail, returnUrl, runtimeConfig, stripePublishableKey, userId, }: StripeSubscriptionCheckoutIntentKeyInput): string;
|
|
52
|
+
export declare function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponId, customerEmail, returnUrl, runtimeConfig, runtimeConfigRevisionId, paymentProfileId, provider, stripePublishableKey, userId, }: StripeSubscriptionCheckoutIntentKeyInput): string;
|
|
50
53
|
export declare function shouldResetStripeSubscriptionCheckoutSessionForIntentKey(previousIntentKey: string | null, nextIntentKey: string): boolean;
|
|
51
54
|
export declare function isInactiveCheckoutSessionError(message?: string | null): boolean;
|
|
52
|
-
export declare function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMetadata, couponId, customerEmail, displayPlan, enabled, onError, plan, returnUrl, runtimeConfig, stripePublishableKey, userId, }: StripeSubscriptionCheckoutSessionInput): StripeSubscriptionCheckoutSession;
|
|
55
|
+
export declare function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMetadata, couponId, customerEmail, displayPlan, enabled, onError, plan, returnUrl, runtimeConfig, runtimeConfigRevisionId, paymentProfileId, provider, stripePublishableKey, userId, }: StripeSubscriptionCheckoutSessionInput): StripeSubscriptionCheckoutSession;
|
|
@@ -35,12 +35,17 @@ export const buildStripeSubscriptionCheckoutPreparationAnalyticsMetadata = (anal
|
|
|
35
35
|
const _b = analyticsMetadata !== null && analyticsMetadata !== void 0 ? analyticsMetadata : {}, { payment_method: _paymentMethod, paymentMethod: _camelCasePaymentMethod } = _b, metadata = __rest(_b, ["payment_method", "paymentMethod"]);
|
|
36
36
|
return Object.assign(Object.assign(Object.assign({}, metadata), (checkoutStartSource ? { checkoutStartSource } : {})), (paymentMethod ? { payment_method: paymentMethod } : {}));
|
|
37
37
|
};
|
|
38
|
-
export function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponId, customerEmail, returnUrl, runtimeConfig, stripePublishableKey, userId, }) {
|
|
38
|
+
export function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponId, customerEmail, returnUrl, runtimeConfig, runtimeConfigRevisionId, paymentProfileId, provider, stripePublishableKey, userId, }) {
|
|
39
|
+
var _a;
|
|
39
40
|
const runtimeConfigSignature = [
|
|
40
41
|
normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.apiBaseUrl),
|
|
41
42
|
normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelId),
|
|
42
43
|
normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelVersionId),
|
|
43
44
|
normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelSdkPublishableKey),
|
|
45
|
+
(_a = runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.paymentsApiVersion) !== null && _a !== void 0 ? _a : 'v1',
|
|
46
|
+
normalizeRuntimeConfigValue(runtimeConfigRevisionId),
|
|
47
|
+
normalizeRuntimeConfigValue(paymentProfileId),
|
|
48
|
+
provider !== null && provider !== void 0 ? provider : '',
|
|
44
49
|
normalizeRuntimeConfigValue(stripePublishableKey),
|
|
45
50
|
].join('|');
|
|
46
51
|
const customerEmailSignature = normalizeRuntimeConfigValue(customerEmail);
|
|
@@ -62,7 +67,7 @@ export function isInactiveCheckoutSessionError(message) {
|
|
|
62
67
|
var _a;
|
|
63
68
|
return /\bcheckout session\b.*\bno longer active\b/i.test((_a = message === null || message === void 0 ? void 0 : message.trim()) !== null && _a !== void 0 ? _a : '');
|
|
64
69
|
}
|
|
65
|
-
export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMetadata, couponId, customerEmail, displayPlan, enabled = true, onError, plan, returnUrl, runtimeConfig, stripePublishableKey, userId, }) {
|
|
70
|
+
export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMetadata, couponId, customerEmail, displayPlan, enabled = true, onError, plan, returnUrl, runtimeConfig, runtimeConfigRevisionId, paymentProfileId, provider, stripePublishableKey, userId, }) {
|
|
66
71
|
var _a, _b, _c, _d, _e;
|
|
67
72
|
const [clientSecret, setClientSecret] = useState(null);
|
|
68
73
|
const [clientSecretIntentKey, setClientSecretIntentKey] = useState(null);
|
|
@@ -73,6 +78,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMe
|
|
|
73
78
|
const [runtimeStripePublishableKey, setRuntimeStripePublishableKey] = useState(null);
|
|
74
79
|
const creatingIntentRef = useRef(null);
|
|
75
80
|
const requestIdRef = useRef(0);
|
|
81
|
+
const anonymousUserIdRef = useRef(null);
|
|
76
82
|
const configured = enabled &&
|
|
77
83
|
(isStripeConfigured(checkoutMode) ||
|
|
78
84
|
Boolean(normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelSdkPublishableKey)) ||
|
|
@@ -83,6 +89,9 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMe
|
|
|
83
89
|
customerEmail,
|
|
84
90
|
returnUrl,
|
|
85
91
|
runtimeConfig,
|
|
92
|
+
runtimeConfigRevisionId,
|
|
93
|
+
paymentProfileId,
|
|
94
|
+
provider,
|
|
86
95
|
stripePublishableKey,
|
|
87
96
|
userId,
|
|
88
97
|
});
|
|
@@ -158,7 +167,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMe
|
|
|
158
167
|
const requestId = requestIdRef.current + 1;
|
|
159
168
|
requestIdRef.current = requestId;
|
|
160
169
|
const subscriptionRequest = (async () => {
|
|
161
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
170
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
162
171
|
try {
|
|
163
172
|
const response = await createStripeSubscriptionCheckout({
|
|
164
173
|
plan,
|
|
@@ -169,6 +178,10 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMe
|
|
|
169
178
|
user_id: userId,
|
|
170
179
|
environment: checkoutMode,
|
|
171
180
|
runtimeConfig,
|
|
181
|
+
runtimeConfigRevisionId,
|
|
182
|
+
paymentProfileId,
|
|
183
|
+
provider,
|
|
184
|
+
anonymousUserId: anonymousUserIdRef.current,
|
|
172
185
|
});
|
|
173
186
|
if (((_a = creatingIntentRef.current) === null || _a === void 0 ? void 0 : _a.key) !== requestKey ||
|
|
174
187
|
((_b = creatingIntentRef.current) === null || _b === void 0 ? void 0 : _b.id) !== requestId) {
|
|
@@ -178,22 +191,24 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMe
|
|
|
178
191
|
if (publishableKey) {
|
|
179
192
|
setRuntimeStripePublishableKey(publishableKey);
|
|
180
193
|
}
|
|
194
|
+
anonymousUserIdRef.current = ((_d = response.anonymousUserId) === null || _d === void 0 ? void 0 : _d.trim())
|
|
195
|
+
|| anonymousUserIdRef.current;
|
|
181
196
|
setClientSecret(response.clientSecret);
|
|
182
197
|
setClientSecretIntentKey(requestKey);
|
|
183
|
-
setCheckoutSessionId(((
|
|
198
|
+
setCheckoutSessionId(((_e = response.checkoutSessionId) === null || _e === void 0 ? void 0 : _e.trim()) || null);
|
|
184
199
|
setClientSecretPlanKey(requestPlanKey);
|
|
185
200
|
return response.clientSecret;
|
|
186
201
|
}
|
|
187
202
|
catch (subscriptionError) {
|
|
188
|
-
if (((
|
|
189
|
-
((
|
|
203
|
+
if (((_f = creatingIntentRef.current) === null || _f === void 0 ? void 0 : _f.key) === requestKey &&
|
|
204
|
+
((_g = creatingIntentRef.current) === null || _g === void 0 ? void 0 : _g.id) === requestId) {
|
|
190
205
|
setError(getFriendlyStripeCheckoutError(subscriptionError));
|
|
191
206
|
}
|
|
192
207
|
return null;
|
|
193
208
|
}
|
|
194
209
|
finally {
|
|
195
|
-
if (((
|
|
196
|
-
((
|
|
210
|
+
if (((_h = creatingIntentRef.current) === null || _h === void 0 ? void 0 : _h.key) === requestKey &&
|
|
211
|
+
((_j = creatingIntentRef.current) === null || _j === void 0 ? void 0 : _j.id) === requestId) {
|
|
197
212
|
creatingIntentRef.current = null;
|
|
198
213
|
}
|
|
199
214
|
}
|
|
@@ -217,6 +232,9 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMe
|
|
|
217
232
|
planKey,
|
|
218
233
|
returnUrl,
|
|
219
234
|
runtimeConfig,
|
|
235
|
+
runtimeConfigRevisionId,
|
|
236
|
+
paymentProfileId,
|
|
237
|
+
provider,
|
|
220
238
|
setError,
|
|
221
239
|
userId,
|
|
222
240
|
]);
|
|
@@ -44,7 +44,7 @@ export declare function findPaywallPlan(plans: readonly PaywallPlan[], selection
|
|
|
44
44
|
export declare function getDefaultPlanSelectionValue(plans: readonly PaywallPlan[], pricing?: ResolvedCountryPricing<string> | null): string | null;
|
|
45
45
|
export declare function isStripeConfigured(mode: RuntimeMode): boolean;
|
|
46
46
|
export declare function getStripePromise(_mode: RuntimeMode, runtimePublishableKey?: string | null): Promise<Stripe | null> | null;
|
|
47
|
-
type CheckoutSessionPlanInput = Pick<PaywallPlan, 'amountCents' | 'analyticsPurchaseValue' | 'billingInterval' | 'billingIntervalCount' | 'description' | 'id' | 'providerPlanId' | 'title' | 'followUpProviderPlanId' | 'followUpPlanTitle' | 'followUpBillingInterval' | 'followUpBillingIntervalCount' | 'introIterations' | 'offerSetId' | 'offerSetKey'>;
|
|
47
|
+
type CheckoutSessionPlanInput = Pick<PaywallPlan, 'amountCents' | 'analyticsPurchaseValue' | 'billingInterval' | 'billingIntervalCount' | 'description' | 'funnelPlanKey' | 'id' | 'providerPlanId' | 'title' | 'followUpProviderPlanId' | 'followUpPlanTitle' | 'followUpBillingInterval' | 'followUpBillingIntervalCount' | 'introIterations' | 'offerSetId' | 'offerSetKey'>;
|
|
48
48
|
type CheckoutPlanRecurringConfig = {
|
|
49
49
|
interval: BillingPlanInterval;
|
|
50
50
|
intervalCount: number;
|
|
@@ -129,6 +129,10 @@ export declare const requiresStripeOneClickConfirmation: (status: string) => boo
|
|
|
129
129
|
export declare function completeStripeOneClickPayment(input: CompleteStripeOneClickPaymentInput): Promise<CompleteStripeOneClickPaymentResponse>;
|
|
130
130
|
type CreateSubscriptionCheckoutInput = {
|
|
131
131
|
plan: CheckoutSessionPlanInput;
|
|
132
|
+
runtimeConfigRevisionId?: string | null;
|
|
133
|
+
paymentProfileId?: string | null;
|
|
134
|
+
provider?: 'stripe' | null;
|
|
135
|
+
anonymousUserId?: string | null;
|
|
132
136
|
couponId?: string | null;
|
|
133
137
|
analyticsMetadata?: Record<string, unknown> | null;
|
|
134
138
|
customerEmail?: string | null;
|
|
@@ -382,7 +382,7 @@ export async function completeStripeOneClickPayment(input) {
|
|
|
382
382
|
return Object.assign(Object.assign({}, payment), { status: (_f = (_e = confirmation.paymentIntent) === null || _e === void 0 ? void 0 : _e.status) !== null && _f !== void 0 ? _f : payment.status, confirmationAttempted: true });
|
|
383
383
|
}
|
|
384
384
|
export async function createStripeSubscriptionCheckout(input) {
|
|
385
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
385
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
386
386
|
const recurring = resolveCheckoutPlanRecurringConfig(input.plan);
|
|
387
387
|
if (!recurring) {
|
|
388
388
|
throw new Error('Unable to resolve the recurring interval for the selected plan');
|
|
@@ -391,22 +391,27 @@ export async function createStripeSubscriptionCheckout(input) {
|
|
|
391
391
|
offerSetId: ((_a = input.plan.offerSetId) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
|
|
392
392
|
offerSetKey: ((_b = input.plan.offerSetKey) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
|
|
393
393
|
planId: getPaywallPlanRequestId(input.plan),
|
|
394
|
-
|
|
394
|
+
planKey: ((_c = input.plan.funnelPlanKey) === null || _c === void 0 ? void 0 : _c.trim()) || input.plan.id,
|
|
395
|
+
providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
|
|
396
|
+
provider: input.provider,
|
|
397
|
+
paymentProfileId: ((_e = input.paymentProfileId) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
|
|
398
|
+
runtimeConfigRevisionId: ((_f = input.runtimeConfigRevisionId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined,
|
|
399
|
+
anonymousUserId: ((_g = input.anonymousUserId) === null || _g === void 0 ? void 0 : _g.trim()) || undefined,
|
|
395
400
|
title: input.plan.title,
|
|
396
|
-
description: ((
|
|
401
|
+
description: ((_h = input.plan.description) === null || _h === void 0 ? void 0 : _h.trim()) || undefined,
|
|
397
402
|
amountCents: input.plan.amountCents,
|
|
398
403
|
billingInterval: recurring.interval,
|
|
399
404
|
billingIntervalCount: recurring.intervalCount,
|
|
400
|
-
followUpProviderPlanId: ((
|
|
401
|
-
followUpPlanTitle: ((
|
|
405
|
+
followUpProviderPlanId: ((_j = input.plan.followUpProviderPlanId) === null || _j === void 0 ? void 0 : _j.trim()) || undefined,
|
|
406
|
+
followUpPlanTitle: ((_k = input.plan.followUpPlanTitle) === null || _k === void 0 ? void 0 : _k.trim()) || undefined,
|
|
402
407
|
followUpBillingInterval: input.plan.followUpBillingInterval,
|
|
403
408
|
followUpBillingIntervalCount: input.plan.followUpBillingIntervalCount,
|
|
404
409
|
introIterations: input.plan.introIterations,
|
|
405
|
-
couponId: ((
|
|
410
|
+
couponId: ((_l = input.couponId) === null || _l === void 0 ? void 0 : _l.trim()) || undefined,
|
|
406
411
|
analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan),
|
|
407
|
-
customerEmail: ((
|
|
412
|
+
customerEmail: ((_m = input.customerEmail) === null || _m === void 0 ? void 0 : _m.trim()) || undefined,
|
|
408
413
|
returnUrl: input.returnUrl,
|
|
409
|
-
userId: ((
|
|
414
|
+
userId: ((_o = input.user_id) === null || _o === void 0 ? void 0 : _o.trim()) || undefined,
|
|
410
415
|
environment: input.environment,
|
|
411
416
|
runtimeConfig: input.runtimeConfig,
|
|
412
417
|
});
|
|
@@ -4,6 +4,7 @@ import { type PaywallPlan } from '../providers/stripe/services/stripe.service.js
|
|
|
4
4
|
export type PublishedBillingPlan = BillingFallbackPlanConfig & OfferSetRuntimePlanOverrides;
|
|
5
5
|
export type ResolvedPublishedBillingRuntime = {
|
|
6
6
|
revisionId: string | null;
|
|
7
|
+
paymentsApiVersion: 'v1' | 'v2';
|
|
7
8
|
mode: RuntimeMode;
|
|
8
9
|
offerSetId: string;
|
|
9
10
|
paymentProfileId: string | null;
|
|
@@ -2,7 +2,7 @@ import { resolveGeneratedOfferSetRuntime, resolvePublishedOfferSetSelection, res
|
|
|
2
2
|
import { buildBillingDiscountCatalog } from './paywallOffer.service.js';
|
|
3
3
|
import { buildConfigPaywallPlans, } from '../providers/stripe/services/stripe.service.js';
|
|
4
4
|
export const resolvePublishedBillingRuntime = ({ config, featureFlags, mode, search = '', defaultOfferSetId, baseCatalogsByMode, fallbackDiscounts, resolvedExperiments = resolvePublishedRuntimeExperiments(config), }) => {
|
|
5
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6
6
|
const offerSets = (_a = config === null || config === void 0 ? void 0 : config.offerSets) !== null && _a !== void 0 ? _a : [];
|
|
7
7
|
const selection = resolvePublishedOfferSetSelection({
|
|
8
8
|
offerSets,
|
|
@@ -26,12 +26,13 @@ export const resolvePublishedBillingRuntime = ({ config, featureFlags, mode, sea
|
|
|
26
26
|
const paymentProviderConfig = (_c = (_b = runtime.offerSet) === null || _b === void 0 ? void 0 : _b.paymentProviderConfigByMode) === null || _c === void 0 ? void 0 : _c[mode];
|
|
27
27
|
return {
|
|
28
28
|
revisionId: (_d = config === null || config === void 0 ? void 0 : config.revisionId) !== null && _d !== void 0 ? _d : null,
|
|
29
|
+
paymentsApiVersion: (_e = config === null || config === void 0 ? void 0 : config.paymentsApiVersion) !== null && _e !== void 0 ? _e : 'v1',
|
|
29
30
|
mode,
|
|
30
31
|
offerSetId: selection.offerSetId,
|
|
31
|
-
paymentProfileId: ((
|
|
32
|
+
paymentProfileId: ((_g = (_f = runtime.offerSet) === null || _f === void 0 ? void 0 : _f.paymentProfileId) === null || _g === void 0 ? void 0 : _g.trim()) || null,
|
|
32
33
|
provider,
|
|
33
34
|
stripePublishableKey: provider === 'stripe' && (paymentProviderConfig === null || paymentProviderConfig === void 0 ? void 0 : paymentProviderConfig.provider) === 'stripe'
|
|
34
|
-
? ((
|
|
35
|
+
? ((_h = paymentProviderConfig === null || paymentProviderConfig === void 0 ? void 0 : paymentProviderConfig.stripePublishableKey) === null || _h === void 0 ? void 0 : _h.trim()) || null
|
|
35
36
|
: null,
|
|
36
37
|
experimentId: selection.experimentId,
|
|
37
38
|
variantKey: selection.variantKey,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnelsgrove/payments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"test:run": "vitest run --passWithNoTests"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@funnelsgrove/analytics": "^0.1.
|
|
36
|
-
"@funnelsgrove/runtime": "^0.
|
|
35
|
+
"@funnelsgrove/analytics": "^0.1.82",
|
|
36
|
+
"@funnelsgrove/runtime": "^0.9.0",
|
|
37
37
|
"@solidgate/react-sdk": "1.34.0",
|
|
38
38
|
"@stripe/react-stripe-js": "^5.6.0",
|
|
39
39
|
"@stripe/stripe-js": "^8.7.0",
|