@funnelsgrove/payments 0.66.0 → 0.68.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/README.md +27 -5
- package/dist/generated/package-version.d.ts +1 -1
- package/dist/generated/package-version.js +1 -1
- package/dist/providers/solidgate/components/SolidgateCheckoutDialog.js +5 -1
- package/dist/providers/solidgate/services/solidgateDeclineMessage.js +1 -1
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.d.ts +27 -2
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.js +205 -100
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.options.d.ts +16 -0
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.options.js +19 -0
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.styles.d.ts +3 -1
- package/dist/providers/stripe/components/StripeWalletFirstCheckout.styles.js +13 -8
- package/dist/providers/stripe/components/WalletButton.d.ts +20 -0
- package/dist/providers/stripe/components/WalletButton.js +52 -0
- package/dist/providers/stripe/components/index.d.ts +1 -0
- package/dist/providers/stripe/components/index.js +1 -0
- package/dist/providers/stripe/hooks/useStripeOneTimeCheckoutSession.d.ts +10 -3
- package/dist/providers/stripe/hooks/useStripeOneTimeCheckoutSession.js +18 -8
- package/dist/providers/stripe/hooks/useStripeSubscriptionCheckoutSession.d.ts +10 -3
- package/dist/providers/stripe/hooks/useStripeSubscriptionCheckoutSession.js +19 -8
- package/dist/providers/stripe/services/checkout/requests.d.ts +8 -4
- package/dist/providers/stripe/services/checkout/requests.js +6 -6
- package/dist/providers/stripe/services/checkout/types.d.ts +9 -0
- package/dist/providers/stripe/services/checkoutCompletionAnalytics.service.d.ts +1 -1
- package/dist/providers/stripe/services/oneClick/completePayment.js +4 -1
- package/dist/providers/stripe/services/oneClick/confirmation.js +8 -5
- package/dist/providers/stripe/services/oneClick/types.d.ts +2 -0
- package/package.json +5 -5
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/** Wallet slot of WalletButton: progress bar, Stripe's wallet button and the unavailable note share one height. */
|
|
2
|
+
export const walletButtonStyles = `
|
|
3
|
+
.wfc-wallet-slot { position:relative; height:55px; }
|
|
4
|
+
.wfc-wallet-button { height:55px; overflow:hidden; border-radius:12px; }
|
|
5
|
+
.wfc-progress { position:relative; display:block; height:100%; overflow:hidden; border-radius:12px; background:#eef0f6; }
|
|
6
|
+
.wfc-progress::after { content:''; position:absolute; inset:0; background:linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent); transform:translateX(-100%); animation:wfc-sheen 1.3s ease-in-out infinite; }
|
|
7
|
+
.wfc-progress--overlay { position:absolute; inset:0; z-index:1; }
|
|
8
|
+
@keyframes wfc-sheen { to { transform:translateX(100%); } }
|
|
9
|
+
@media (prefers-reduced-motion: reduce) { .wfc-progress::after { animation:none; } }
|
|
10
|
+
.wfc-wallet-unavailable { position:absolute; inset:0; z-index:1; display:flex; align-items:center; justify-content:center; margin:0; padding:0 16px; border-radius:12px; background:#f4f5f8; color:#6b6773; font-size:14px; line-height:1.35; text-align:center; }
|
|
11
|
+
`;
|
|
1
12
|
/** Styles for StripeWalletFirstCheckout; colors come from its `themeColor` and `buttonColor` props. */
|
|
2
13
|
export const stripeWalletFirstCheckoutStyles = `
|
|
3
14
|
.wfc { display:grid; gap:12px; }
|
|
@@ -19,15 +30,9 @@ export const stripeWalletFirstCheckoutStyles = `
|
|
|
19
30
|
.wfc-benefits { margin:0 0 16px; padding:0; list-style:none; display:grid; gap:10px; font-size:15px; line-height:1.4; color:#303136; }
|
|
20
31
|
.wfc-benefits li { display:flex; gap:10px; align-items:flex-start; }
|
|
21
32
|
.wfc-check { flex:none; width:16px; height:16px; margin-top:2px; color:var(--wfc-theme); }
|
|
22
|
-
|
|
23
|
-
.wfc-wallet-button { height:55px; overflow:hidden; border-radius:12px; }
|
|
24
|
-
.wfc-progress { position:relative; display:block; height:100%; overflow:hidden; border-radius:12px; background:#eef0f6; }
|
|
25
|
-
.wfc-progress::after { content:''; position:absolute; inset:0; background:linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent); transform:translateX(-100%); animation:wfc-sheen 1.3s ease-in-out infinite; }
|
|
26
|
-
.wfc-progress--overlay { position:absolute; inset:0; z-index:1; }
|
|
33
|
+
${walletButtonStyles}
|
|
27
34
|
.wfc-progress--form { height:320px; }
|
|
28
|
-
|
|
29
|
-
@media (prefers-reduced-motion: reduce) { .wfc-progress::after { animation:none; } }
|
|
30
|
-
.wfc-wallet-unavailable { position:absolute; inset:0; z-index:1; display:flex; align-items:center; justify-content:center; margin:0; padding:0 16px; border-radius:12px; background:#f4f5f8; color:#6b6773; font-size:14px; line-height:1.35; text-align:center; }
|
|
35
|
+
.wfc-method-label { font-size:17px; font-weight:600; line-height:1.2; color:#303136; }
|
|
31
36
|
.wfc-secure { margin:16px 0 0; text-align:center; font-size:14px; line-height:1.45; color:#8c909a; }
|
|
32
37
|
.wfc-card-form { display:grid; gap:14px; }
|
|
33
38
|
.wfc-card-form .wfc-secure { margin-top:0; }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Stripe } from '@stripe/stripe-js';
|
|
2
|
+
import { type StripeCheckoutExpressCheckoutButtonProps } from './StripeCheckoutExpressCheckoutButton.js';
|
|
3
|
+
import type { PlatformWalletPaymentMethod } from './walletPlatform.js';
|
|
4
|
+
export type WalletButtonSession = {
|
|
5
|
+
/** Null while the Checkout Session is being created. */
|
|
6
|
+
clientSecret: string | null;
|
|
7
|
+
stripePromise: Promise<Stripe | null> | null;
|
|
8
|
+
/** Stripe's `colorPrimary`, e.g. the funnel's theme color. */
|
|
9
|
+
themeColor?: string;
|
|
10
|
+
};
|
|
11
|
+
export type WalletButtonProps = Pick<StripeCheckoutExpressCheckoutButtonProps, 'amountCents' | 'beforeConfirm' | 'checkoutAnalytics' | 'checkoutSessionId' | 'customerEmail' | 'customerName' | 'onAvailabilityChange' | 'onCancel' | 'onEmbeddedComplete' | 'onError' | 'onPaymentRejected' | 'onSuccess' | 'onVerificationPending' | 'returnUrl' | 'summaryLabel'> & {
|
|
12
|
+
wallet: PlatformWalletPaymentMethod;
|
|
13
|
+
/** Accessible name of the progress bar. */
|
|
14
|
+
processingLabel: string;
|
|
15
|
+
/** Shown in the slot when this browser cannot pay with the wallet. */
|
|
16
|
+
unavailableNote: string;
|
|
17
|
+
/** Own Checkout Session scope for a standalone placement; omit inside an existing `CheckoutProvider`. */
|
|
18
|
+
session?: WalletButtonSession;
|
|
19
|
+
};
|
|
20
|
+
export declare function WalletButton({ session, ...slot }: WalletButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
/**
|
|
15
|
+
* One platform wallet (Apple Pay or Google Pay) in a slot of fixed height: a
|
|
16
|
+
* progress bar until Stripe's button arrives, Stripe's own wallet button, or a
|
|
17
|
+
* note that this browser cannot pay with that wallet. Nothing moves between
|
|
18
|
+
* these states.
|
|
19
|
+
*
|
|
20
|
+
* Inside an existing `CheckoutProvider` (e.g. the wallet block of
|
|
21
|
+
* `StripeWalletFirstCheckout`) omit `session`. For a standalone placement pass
|
|
22
|
+
* `session`: the button then owns its Checkout Session scope and shows the
|
|
23
|
+
* progress bar while `clientSecret` is null.
|
|
24
|
+
*/
|
|
25
|
+
import { useState } from 'react';
|
|
26
|
+
import { CheckoutProvider } from '@stripe/react-stripe-js/checkout';
|
|
27
|
+
import { StripeCheckoutExpressCheckoutButton } from './StripeCheckoutExpressCheckoutButton.js';
|
|
28
|
+
import { walletButtonStyles } from './StripeWalletFirstCheckout.styles.js';
|
|
29
|
+
import { buildWalletFirstCheckoutOptions } from './StripeWalletFirstCheckout.options.js';
|
|
30
|
+
export function WalletButton(_a) {
|
|
31
|
+
var { session } = _a, slot = __rest(_a, ["session"]);
|
|
32
|
+
if (!session)
|
|
33
|
+
return _jsx(WalletSlot, Object.assign({}, slot));
|
|
34
|
+
return (_jsxs(_Fragment, { children: [session.clientSecret && session.stripePromise ? (_jsx(CheckoutProvider, { stripe: session.stripePromise, options: buildWalletFirstCheckoutOptions(session.clientSecret, session.themeColor), children: _jsx(WalletSlot, Object.assign({}, slot)) }, session.clientSecret)) : (_jsx("div", { className: 'wfc-wallet-slot', children: _jsx("span", { className: 'wfc-progress', role: 'status', "aria-label": slot.processingLabel }) })), _jsx("style", { children: walletButtonStyles })] }));
|
|
35
|
+
}
|
|
36
|
+
function WalletSlot(_a) {
|
|
37
|
+
var { onAvailabilityChange, processingLabel, unavailableNote, wallet } = _a, button = __rest(_a, ["onAvailabilityChange", "processingLabel", "unavailableNote", "wallet"]);
|
|
38
|
+
// null until Stripe answers; the slot shows progress at the button's height meanwhile.
|
|
39
|
+
const [available, setAvailable] = useState(null);
|
|
40
|
+
const options = {
|
|
41
|
+
buttonHeight: 55,
|
|
42
|
+
buttonTheme: { applePay: 'black', googlePay: 'black' },
|
|
43
|
+
buttonType: { applePay: 'plain', googlePay: 'plain' },
|
|
44
|
+
layout: { maxColumns: 1, maxRows: 1, overflow: 'auto' },
|
|
45
|
+
paymentMethods: {
|
|
46
|
+
amazonPay: 'never', klarna: 'never', link: 'never', paypal: 'never',
|
|
47
|
+
applePay: wallet === 'applePay' ? 'always' : 'never',
|
|
48
|
+
googlePay: wallet === 'googlePay' ? 'always' : 'never',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
return (_jsxs("div", { className: 'wfc-wallet-slot', children: [_jsx("div", { className: 'wfc-wallet-button', "data-ready": available === true, children: _jsx(StripeCheckoutExpressCheckoutButton, Object.assign({}, button, { availabilityPaymentMethods: [wallet], confirmEmail: false, onAvailabilityChange: (value) => { setAvailable(value); onAvailabilityChange === null || onAvailabilityChange === void 0 ? void 0 : onAvailabilityChange(value); }, options: options })) }), available === null ? _jsx("span", { className: 'wfc-progress wfc-progress--overlay', role: 'status', "aria-label": processingLabel }) : null, available === false ? _jsx("p", { className: 'wfc-wallet-unavailable', role: 'status', children: unavailableNote }) : null] }));
|
|
52
|
+
}
|
|
@@ -12,5 +12,6 @@ export * from './StripePlanSelector.js';
|
|
|
12
12
|
export * from './StripeSubscriptionWalletSurface.js';
|
|
13
13
|
export * from './StripeWalletFirstCheckout.js';
|
|
14
14
|
export * from './StripeCheckoutSheet.js';
|
|
15
|
+
export * from './WalletButton.js';
|
|
15
16
|
export * from './WalletSubscriptionCheckoutSlot.js';
|
|
16
17
|
export * from './walletPlatform.js';
|
|
@@ -12,5 +12,6 @@ export * from './StripePlanSelector.js';
|
|
|
12
12
|
export * from './StripeSubscriptionWalletSurface.js';
|
|
13
13
|
export * from './StripeWalletFirstCheckout.js';
|
|
14
14
|
export * from './StripeCheckoutSheet.js';
|
|
15
|
+
export * from './WalletButton.js';
|
|
15
16
|
export * from './WalletSubscriptionCheckoutSlot.js';
|
|
16
17
|
export * from './walletPlatform.js';
|
|
@@ -19,6 +19,11 @@ export type StripeOneTimeCheckoutSessionInput = {
|
|
|
19
19
|
onReset?: () => void;
|
|
20
20
|
onError?: (message: string | null) => void;
|
|
21
21
|
plan?: StripeOneTimeCheckoutPlanInput | null;
|
|
22
|
+
/**
|
|
23
|
+
* CHECKOUT-BR-010: restrict the session to these Stripe method types, e.g. `['card']` or `['pix']`.
|
|
24
|
+
* Each list is its own checkout identity. Omitted, the session offers the profile's methods.
|
|
25
|
+
*/
|
|
26
|
+
paymentMethodTypes?: readonly string[] | null;
|
|
22
27
|
returnUrl: string;
|
|
23
28
|
runtimeConfig?: StripeRuntimeConfigOverrides;
|
|
24
29
|
stripePublishableKey?: string | null;
|
|
@@ -33,6 +38,8 @@ export type StripeOneTimeCheckoutPreparationOptions = {
|
|
|
33
38
|
export declare function resolveStripeOneTimeCheckoutPreparationOptions(source: CheckoutPreparationSource, options?: StripeOneTimeCheckoutPreparationOptions): StripeOneTimeCheckoutPreparationOptions;
|
|
34
39
|
export type StripeOneTimeCheckoutSession = {
|
|
35
40
|
activeClientSecret: string | null;
|
|
41
|
+
/** Every method the offer supports (CHECKOUT-BR-010); null until the session exists. */
|
|
42
|
+
availablePaymentMethodTypes: readonly string[] | null;
|
|
36
43
|
checkoutSessionId: string | null;
|
|
37
44
|
configured: boolean;
|
|
38
45
|
error: string | null;
|
|
@@ -49,9 +56,9 @@ export type StripeOneTimeCheckoutSession = {
|
|
|
49
56
|
stripePromise: Promise<Stripe | null> | null;
|
|
50
57
|
};
|
|
51
58
|
export declare const buildStripeOneTimeCheckoutPreparationAnalyticsMetadata: (analyticsMetadata: Record<string, unknown> | null | undefined, options?: StripeOneTimeCheckoutPreparationOptions) => Record<string, unknown> | null | undefined;
|
|
52
|
-
export type StripeOneTimeCheckoutIntentKeyInput = Pick<StripeOneTimeCheckoutSessionInput, 'checkoutMode' | 'couponId' | 'customerEmail' | 'plan' | 'returnUrl' | 'runtimeConfig' | 'stripePublishableKey' | 'userId' | 'runtimeConfigRevisionId' | 'paymentProfileId' | 'provider'> & {
|
|
59
|
+
export type StripeOneTimeCheckoutIntentKeyInput = Pick<StripeOneTimeCheckoutSessionInput, 'checkoutMode' | 'couponId' | 'customerEmail' | 'paymentMethodTypes' | 'plan' | 'returnUrl' | 'runtimeConfig' | 'stripePublishableKey' | 'userId' | 'runtimeConfigRevisionId' | 'paymentProfileId' | 'provider'> & {
|
|
53
60
|
analyticsMetadata?: Record<string, unknown> | null;
|
|
54
61
|
};
|
|
55
|
-
export declare function buildStripeOneTimeCheckoutIntentKey({ runtimeConfigRevisionId, paymentProfileId, provider, checkoutMode, couponId, customerEmail, plan, returnUrl, runtimeConfig, stripePublishableKey, userId, }: StripeOneTimeCheckoutIntentKeyInput): string;
|
|
62
|
+
export declare function buildStripeOneTimeCheckoutIntentKey({ runtimeConfigRevisionId, paymentProfileId, provider, checkoutMode, couponId, customerEmail, paymentMethodTypes, plan, returnUrl, runtimeConfig, stripePublishableKey, userId, }: StripeOneTimeCheckoutIntentKeyInput): string;
|
|
56
63
|
export declare function shouldResetStripeOneTimeCheckoutSessionForIntentKey(previousIntentKey: string | null, nextIntentKey: string): boolean;
|
|
57
|
-
export declare function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextRuntimeConfigRevisionId, paymentProfileId: nextPaymentProfileId, provider: nextProvider, analyticsMetadata, checkoutAnalytics, checkoutMode: nextCheckoutMode, couponId, customerEmail, enabled, onError, onPreparationStart, onReset, plan, returnUrl, runtimeConfig: nextRuntimeConfig, stripePublishableKey: nextStripePublishableKey, stripeLocale, userId, }: StripeOneTimeCheckoutSessionInput): StripeOneTimeCheckoutSession;
|
|
64
|
+
export declare function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextRuntimeConfigRevisionId, paymentProfileId: nextPaymentProfileId, provider: nextProvider, analyticsMetadata, checkoutAnalytics, checkoutMode: nextCheckoutMode, couponId, customerEmail, enabled, onError, onPreparationStart, onReset, plan, paymentMethodTypes, returnUrl, runtimeConfig: nextRuntimeConfig, stripePublishableKey: nextStripePublishableKey, stripeLocale, userId, }: StripeOneTimeCheckoutSessionInput): StripeOneTimeCheckoutSession;
|
|
@@ -36,8 +36,8 @@ export const buildStripeOneTimeCheckoutPreparationAnalyticsMetadata = (analytics
|
|
|
36
36
|
const _b = analyticsMetadata !== null && analyticsMetadata !== void 0 ? analyticsMetadata : {}, { payment_method: _paymentMethod, paymentMethod: _camelCasePaymentMethod } = _b, metadata = __rest(_b, ["payment_method", "paymentMethod"]);
|
|
37
37
|
return Object.assign(Object.assign(Object.assign({}, metadata), (checkoutStartSource ? { checkoutStartSource } : {})), (paymentMethod ? { payment_method: paymentMethod } : {}));
|
|
38
38
|
};
|
|
39
|
-
export function buildStripeOneTimeCheckoutIntentKey({ runtimeConfigRevisionId, paymentProfileId, provider, checkoutMode, couponId, customerEmail, plan, returnUrl, runtimeConfig, stripePublishableKey, userId, }) {
|
|
40
|
-
var _a, _b, _c, _d;
|
|
39
|
+
export function buildStripeOneTimeCheckoutIntentKey({ runtimeConfigRevisionId, paymentProfileId, provider, checkoutMode, couponId, customerEmail, paymentMethodTypes, plan, returnUrl, runtimeConfig, stripePublishableKey, userId, }) {
|
|
40
|
+
var _a, _b, _c, _d, _e;
|
|
41
41
|
const runtimeConfigSignature = [
|
|
42
42
|
(_a = runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.paymentsApiVersion) !== null && _a !== void 0 ? _a : 'v2',
|
|
43
43
|
runtimeConfigRevisionId !== null && runtimeConfigRevisionId !== void 0 ? runtimeConfigRevisionId : '',
|
|
@@ -67,12 +67,13 @@ export function buildStripeOneTimeCheckoutIntentKey({ runtimeConfigRevisionId, p
|
|
|
67
67
|
userIdSignature,
|
|
68
68
|
(couponId === null || couponId === void 0 ? void 0 : couponId.trim()) || '',
|
|
69
69
|
returnUrl.trim(),
|
|
70
|
+
(_e = paymentMethodTypes === null || paymentMethodTypes === void 0 ? void 0 : paymentMethodTypes.join(',')) !== null && _e !== void 0 ? _e : '',
|
|
70
71
|
].join('|');
|
|
71
72
|
}
|
|
72
73
|
export function shouldResetStripeOneTimeCheckoutSessionForIntentKey(previousIntentKey, nextIntentKey) {
|
|
73
74
|
return previousIntentKey !== null && previousIntentKey !== nextIntentKey;
|
|
74
75
|
}
|
|
75
|
-
export function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextRuntimeConfigRevisionId, paymentProfileId: nextPaymentProfileId, provider: nextProvider, analyticsMetadata, checkoutAnalytics, checkoutMode: nextCheckoutMode, couponId, customerEmail, enabled = true, onError, onPreparationStart, onReset, plan, returnUrl, runtimeConfig: nextRuntimeConfig, stripePublishableKey: nextStripePublishableKey, stripeLocale, userId, }) {
|
|
76
|
+
export function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextRuntimeConfigRevisionId, paymentProfileId: nextPaymentProfileId, provider: nextProvider, analyticsMetadata, checkoutAnalytics, checkoutMode: nextCheckoutMode, couponId, customerEmail, enabled = true, onError, onPreparationStart, onReset, plan, paymentMethodTypes, returnUrl, runtimeConfig: nextRuntimeConfig, stripePublishableKey: nextStripePublishableKey, stripeLocale, userId, }) {
|
|
76
77
|
var _a, _b, _c, _d, _e;
|
|
77
78
|
const preparedSelectionRef = useRef(null);
|
|
78
79
|
const nextSelection = {
|
|
@@ -89,6 +90,7 @@ export function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextR
|
|
|
89
90
|
const [clientSecret, setClientSecret] = useState(null);
|
|
90
91
|
const [clientSecretIntentKey, setClientSecretIntentKey] = useState(null);
|
|
91
92
|
const [checkoutSessionId, setCheckoutSessionId] = useState(null);
|
|
93
|
+
const [availablePaymentMethodTypes, setAvailablePaymentMethodTypes] = useState(null);
|
|
92
94
|
const [error, setErrorState] = useState(null);
|
|
93
95
|
const [loading, setLoading] = useState(createEmptyCheckoutPreparationLoading);
|
|
94
96
|
const [runtimeStripePublishableKey, setRuntimeStripePublishableKey] = useState(null);
|
|
@@ -114,6 +116,7 @@ export function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextR
|
|
|
114
116
|
checkoutMode,
|
|
115
117
|
couponId,
|
|
116
118
|
customerEmail,
|
|
119
|
+
paymentMethodTypes,
|
|
117
120
|
plan,
|
|
118
121
|
returnUrl,
|
|
119
122
|
runtimeConfig,
|
|
@@ -128,6 +131,7 @@ export function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextR
|
|
|
128
131
|
].join('|');
|
|
129
132
|
const activeClientSecret = clientSecretIntentKey === intentKey ? clientSecret : null;
|
|
130
133
|
const activeCheckoutSessionId = clientSecretIntentKey === intentKey ? checkoutSessionId : null;
|
|
134
|
+
const activeAvailablePaymentMethodTypes = clientSecretIntentKey === intentKey ? availablePaymentMethodTypes : null;
|
|
131
135
|
const stripePromise = useMemo(() => {
|
|
132
136
|
var _a;
|
|
133
137
|
return getStripePromise(checkoutMode, (_a = runtimeStripePublishableKey !== null && runtimeStripePublishableKey !== void 0 ? runtimeStripePublishableKey : stripePublishableKey) !== null && _a !== void 0 ? _a : runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelSdkPublishableKey, stripeLocale);
|
|
@@ -143,6 +147,7 @@ export function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextR
|
|
|
143
147
|
setClientSecret(null);
|
|
144
148
|
setClientSecretIntentKey(null);
|
|
145
149
|
setCheckoutSessionId(null);
|
|
150
|
+
setAvailablePaymentMethodTypes(null);
|
|
146
151
|
}, []);
|
|
147
152
|
const setError = useCallback((message) => {
|
|
148
153
|
if (isInactiveCheckoutSessionError(message) && recoveredIntentKeyRef.current !== intentKey) {
|
|
@@ -212,7 +217,7 @@ export function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextR
|
|
|
212
217
|
const requestId = requestIdRef.current + 1;
|
|
213
218
|
requestIdRef.current = requestId;
|
|
214
219
|
const checkoutRequest = (async () => {
|
|
215
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
220
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
216
221
|
try {
|
|
217
222
|
const response = await createStripeOneTimeCheckout({
|
|
218
223
|
idempotencyKey,
|
|
@@ -224,6 +229,7 @@ export function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextR
|
|
|
224
229
|
analyticsMetadata: buildStripeOneTimeCheckoutPreparationAnalyticsMetadata(analyticsMetadataRef.current, options),
|
|
225
230
|
couponId,
|
|
226
231
|
customerEmail,
|
|
232
|
+
paymentMethodTypes,
|
|
227
233
|
returnUrl,
|
|
228
234
|
user_id: userId,
|
|
229
235
|
environment: checkoutMode,
|
|
@@ -242,11 +248,12 @@ export function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextR
|
|
|
242
248
|
setClientSecret(response.clientSecret);
|
|
243
249
|
setClientSecretIntentKey(requestKey);
|
|
244
250
|
setCheckoutSessionId(((_d = response.checkoutSessionId) === null || _d === void 0 ? void 0 : _d.trim()) || null);
|
|
251
|
+
setAvailablePaymentMethodTypes((_e = response.availablePaymentMethodTypes) !== null && _e !== void 0 ? _e : null);
|
|
245
252
|
return response.clientSecret;
|
|
246
253
|
}
|
|
247
254
|
catch (checkoutError) {
|
|
248
|
-
if (((
|
|
249
|
-
((
|
|
255
|
+
if (((_f = creatingIntentRef.current) === null || _f === void 0 ? void 0 : _f.key) === requestKey &&
|
|
256
|
+
((_g = creatingIntentRef.current) === null || _g === void 0 ? void 0 : _g.id) === requestId) {
|
|
250
257
|
const failure = describeStripeCheckoutFailure(checkoutError);
|
|
251
258
|
const message = failure.message;
|
|
252
259
|
const observabilityAnalytics = resolveCheckoutObservabilityAnalyticsContext({
|
|
@@ -277,8 +284,8 @@ export function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextR
|
|
|
277
284
|
return null;
|
|
278
285
|
}
|
|
279
286
|
finally {
|
|
280
|
-
if (((
|
|
281
|
-
((
|
|
287
|
+
if (((_h = creatingIntentRef.current) === null || _h === void 0 ? void 0 : _h.key) === requestKey &&
|
|
288
|
+
((_j = creatingIntentRef.current) === null || _j === void 0 ? void 0 : _j.id) === requestId) {
|
|
282
289
|
creatingIntentRef.current = null;
|
|
283
290
|
}
|
|
284
291
|
}
|
|
@@ -301,6 +308,7 @@ export function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextR
|
|
|
301
308
|
couponId,
|
|
302
309
|
customerEmail,
|
|
303
310
|
intentKey,
|
|
311
|
+
paymentMethodTypes,
|
|
304
312
|
plan,
|
|
305
313
|
returnUrl,
|
|
306
314
|
runtimeConfig,
|
|
@@ -350,6 +358,7 @@ export function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextR
|
|
|
350
358
|
const restartWalletCheckout = useCallback((options = {}) => prepareCheckout('wallet', Object.assign(Object.assign({}, options), { forceNew: true })), [prepareCheckout]);
|
|
351
359
|
return useMemo(() => ({
|
|
352
360
|
activeClientSecret,
|
|
361
|
+
availablePaymentMethodTypes: activeAvailablePaymentMethodTypes,
|
|
353
362
|
checkoutSessionId: activeCheckoutSessionId,
|
|
354
363
|
configured,
|
|
355
364
|
error,
|
|
@@ -365,6 +374,7 @@ export function useStripeOneTimeCheckoutSession({ runtimeConfigRevisionId: nextR
|
|
|
365
374
|
setError,
|
|
366
375
|
stripePromise,
|
|
367
376
|
}), [
|
|
377
|
+
activeAvailablePaymentMethodTypes,
|
|
368
378
|
activeCheckoutSessionId,
|
|
369
379
|
activeClientSecret,
|
|
370
380
|
configured,
|
|
@@ -21,6 +21,11 @@ export type StripeSubscriptionCheckoutSessionInput = {
|
|
|
21
21
|
runtimeConfig?: StripeRuntimeConfigOverrides;
|
|
22
22
|
runtimeConfigRevisionId?: string | null;
|
|
23
23
|
paymentProfileId?: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* CHECKOUT-BR-010: restrict the session to these Stripe method types, e.g. `['card']` or `['pix']`.
|
|
26
|
+
* Each list is its own checkout identity. Omitted, the session offers the profile's methods.
|
|
27
|
+
*/
|
|
28
|
+
paymentMethodTypes?: readonly string[] | null;
|
|
24
29
|
provider?: 'stripe' | null;
|
|
25
30
|
stripePublishableKey?: string | null;
|
|
26
31
|
stripeLocale?: StripeConstructorOptions['locale'];
|
|
@@ -36,6 +41,8 @@ export declare function resolveStripeSubscriptionCheckoutPreparationOptions(sour
|
|
|
36
41
|
export type StripeSubscriptionCheckoutSession = {
|
|
37
42
|
activeClientSecret: string | null;
|
|
38
43
|
activePlanKey: string | null;
|
|
44
|
+
/** Every method the offer supports (CHECKOUT-BR-010); null until the session exists. */
|
|
45
|
+
availablePaymentMethodTypes: readonly string[] | null;
|
|
39
46
|
checkoutSessionId: string | null;
|
|
40
47
|
configured: boolean;
|
|
41
48
|
error: string | null;
|
|
@@ -53,13 +60,13 @@ export type StripeSubscriptionCheckoutSession = {
|
|
|
53
60
|
updateCheckoutSessionPlan: () => Promise<boolean>;
|
|
54
61
|
};
|
|
55
62
|
export declare const buildStripeSubscriptionCheckoutPreparationAnalyticsMetadata: (analyticsMetadata: Record<string, unknown> | null | undefined, options?: StripeSubscriptionCheckoutPreparationOptions) => Record<string, unknown> | null | undefined;
|
|
56
|
-
export type StripeSubscriptionCheckoutIntentKeyInput = Pick<StripeSubscriptionCheckoutSessionInput, 'checkoutMode' | 'couponId' | 'customerEmail' | 'paymentProfileId' | 'provider' | 'returnUrl' | 'runtimeConfig' | 'runtimeConfigRevisionId' | 'stripePublishableKey' | 'userId'> & {
|
|
63
|
+
export type StripeSubscriptionCheckoutIntentKeyInput = Pick<StripeSubscriptionCheckoutSessionInput, 'checkoutMode' | 'couponId' | 'customerEmail' | 'paymentMethodTypes' | 'paymentProfileId' | 'provider' | 'returnUrl' | 'runtimeConfig' | 'runtimeConfigRevisionId' | 'stripePublishableKey' | 'userId'> & {
|
|
57
64
|
analyticsMetadata?: Record<string, unknown> | null;
|
|
58
65
|
planKey?: string | null;
|
|
59
66
|
};
|
|
60
|
-
export declare function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponId, customerEmail, returnUrl, runtimeConfig, runtimeConfigRevisionId, paymentProfileId, planKey, provider, stripePublishableKey, userId, }: StripeSubscriptionCheckoutIntentKeyInput): string;
|
|
67
|
+
export declare function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponId, customerEmail, returnUrl, runtimeConfig, runtimeConfigRevisionId, paymentMethodTypes, paymentProfileId, planKey, provider, stripePublishableKey, userId, }: StripeSubscriptionCheckoutIntentKeyInput): string;
|
|
61
68
|
export declare function shouldResetStripeSubscriptionCheckoutSessionForIntentKey(previousIntentKey: string | null, nextIntentKey: string): boolean;
|
|
62
69
|
export declare function isInactiveCheckoutSessionError(message?: string | null): boolean;
|
|
63
70
|
export declare function shouldAutoRecoverStripeSubscriptionCheckoutSession(message: string | null | undefined, alreadyRecovered: boolean): boolean;
|
|
64
71
|
export declare const shouldReportStripeCheckoutFailureShown: (message: string) => boolean;
|
|
65
|
-
export declare function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckoutMode, analyticsMetadata, checkoutAnalytics, couponId, customerEmail, displayPlan, enabled, onError, onPreparationStart, onReset, plan, returnUrl, runtimeConfig: nextRuntimeConfig, runtimeConfigRevisionId: nextRuntimeConfigRevisionId, paymentProfileId: nextPaymentProfileId, provider: nextProvider, stripePublishableKey: nextStripePublishableKey, stripeLocale, userId, }: StripeSubscriptionCheckoutSessionInput): StripeSubscriptionCheckoutSession;
|
|
72
|
+
export declare function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckoutMode, analyticsMetadata, checkoutAnalytics, couponId, customerEmail, displayPlan, enabled, onError, onPreparationStart, onReset, plan, paymentMethodTypes, returnUrl, runtimeConfig: nextRuntimeConfig, runtimeConfigRevisionId: nextRuntimeConfigRevisionId, paymentProfileId: nextPaymentProfileId, provider: nextProvider, stripePublishableKey: nextStripePublishableKey, stripeLocale, userId, }: StripeSubscriptionCheckoutSessionInput): StripeSubscriptionCheckoutSession;
|
|
@@ -36,8 +36,8 @@ export const buildStripeSubscriptionCheckoutPreparationAnalyticsMetadata = (anal
|
|
|
36
36
|
const _b = analyticsMetadata !== null && analyticsMetadata !== void 0 ? analyticsMetadata : {}, { payment_method: _paymentMethod, paymentMethod: _camelCasePaymentMethod } = _b, metadata = __rest(_b, ["payment_method", "paymentMethod"]);
|
|
37
37
|
return Object.assign(Object.assign(Object.assign({}, metadata), (checkoutStartSource ? { checkoutStartSource } : {})), (paymentMethod ? { payment_method: paymentMethod } : {}));
|
|
38
38
|
};
|
|
39
|
-
export function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponId, customerEmail, returnUrl, runtimeConfig, runtimeConfigRevisionId, paymentProfileId, planKey, provider, stripePublishableKey, userId, }) {
|
|
40
|
-
var _a;
|
|
39
|
+
export function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponId, customerEmail, returnUrl, runtimeConfig, runtimeConfigRevisionId, paymentMethodTypes, paymentProfileId, planKey, provider, stripePublishableKey, userId, }) {
|
|
40
|
+
var _a, _b;
|
|
41
41
|
const runtimeConfigSignature = [
|
|
42
42
|
normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.apiBaseUrl),
|
|
43
43
|
normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelId),
|
|
@@ -60,6 +60,7 @@ export function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponI
|
|
|
60
60
|
(couponId === null || couponId === void 0 ? void 0 : couponId.trim()) || '',
|
|
61
61
|
(planKey === null || planKey === void 0 ? void 0 : planKey.trim()) || '',
|
|
62
62
|
returnUrl.trim(),
|
|
63
|
+
(_b = paymentMethodTypes === null || paymentMethodTypes === void 0 ? void 0 : paymentMethodTypes.join(',')) !== null && _b !== void 0 ? _b : '',
|
|
63
64
|
].join('|');
|
|
64
65
|
}
|
|
65
66
|
export function shouldResetStripeSubscriptionCheckoutSessionForIntentKey(previousIntentKey, nextIntentKey) {
|
|
@@ -73,7 +74,7 @@ export function shouldAutoRecoverStripeSubscriptionCheckoutSession(message, alre
|
|
|
73
74
|
return !alreadyRecovered && isInactiveCheckoutSessionError(message);
|
|
74
75
|
}
|
|
75
76
|
export const shouldReportStripeCheckoutFailureShown = (message) => !isInactiveCheckoutSessionError(message);
|
|
76
|
-
export function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckoutMode, analyticsMetadata, checkoutAnalytics, couponId, customerEmail, displayPlan, enabled = true, onError, onPreparationStart, onReset, plan, returnUrl, runtimeConfig: nextRuntimeConfig, runtimeConfigRevisionId: nextRuntimeConfigRevisionId, paymentProfileId: nextPaymentProfileId, provider: nextProvider, stripePublishableKey: nextStripePublishableKey, stripeLocale, userId, }) {
|
|
77
|
+
export function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckoutMode, analyticsMetadata, checkoutAnalytics, couponId, customerEmail, displayPlan, enabled = true, onError, onPreparationStart, onReset, plan, paymentMethodTypes, returnUrl, runtimeConfig: nextRuntimeConfig, runtimeConfigRevisionId: nextRuntimeConfigRevisionId, paymentProfileId: nextPaymentProfileId, provider: nextProvider, stripePublishableKey: nextStripePublishableKey, stripeLocale, userId, }) {
|
|
77
78
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
78
79
|
const preparedSelectionRef = useRef(null);
|
|
79
80
|
const nextSelection = {
|
|
@@ -91,6 +92,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckou
|
|
|
91
92
|
const [clientSecretIntentKey, setClientSecretIntentKey] = useState(null);
|
|
92
93
|
const [checkoutSessionId, setCheckoutSessionId] = useState(null);
|
|
93
94
|
const [clientSecretPlanKey, setClientSecretPlanKey] = useState(null);
|
|
95
|
+
const [availablePaymentMethodTypes, setAvailablePaymentMethodTypes] = useState(null);
|
|
94
96
|
const [error, setErrorState] = useState(null);
|
|
95
97
|
const [recoveryRequest, setRecoveryRequest] = useState(0);
|
|
96
98
|
const [loading, setLoading] = useState(createEmptyCheckoutPreparationLoading);
|
|
@@ -123,6 +125,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckou
|
|
|
123
125
|
checkoutMode,
|
|
124
126
|
couponId,
|
|
125
127
|
customerEmail,
|
|
128
|
+
paymentMethodTypes,
|
|
126
129
|
planKey,
|
|
127
130
|
returnUrl,
|
|
128
131
|
runtimeConfig,
|
|
@@ -148,6 +151,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckou
|
|
|
148
151
|
setClientSecretIntentKey(null);
|
|
149
152
|
setCheckoutSessionId(null);
|
|
150
153
|
setClientSecretPlanKey(null);
|
|
154
|
+
setAvailablePaymentMethodTypes(null);
|
|
151
155
|
}, []);
|
|
152
156
|
const setError = useCallback((message) => {
|
|
153
157
|
if (isInactiveCheckoutSessionError(message)) {
|
|
@@ -218,6 +222,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckou
|
|
|
218
222
|
checkoutMode,
|
|
219
223
|
couponId,
|
|
220
224
|
customerEmail: preparedCustomerEmail,
|
|
225
|
+
paymentMethodTypes,
|
|
221
226
|
paymentProfileId,
|
|
222
227
|
planKey,
|
|
223
228
|
provider,
|
|
@@ -242,13 +247,14 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckou
|
|
|
242
247
|
const requestId = requestIdRef.current + 1;
|
|
243
248
|
requestIdRef.current = requestId;
|
|
244
249
|
const subscriptionRequest = (async () => {
|
|
245
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
250
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
246
251
|
try {
|
|
247
252
|
const response = await createStripeSubscriptionCheckout({
|
|
248
253
|
plan,
|
|
249
254
|
analyticsMetadata: buildStripeSubscriptionCheckoutPreparationAnalyticsMetadata(analyticsMetadataRef.current, options),
|
|
250
255
|
couponId,
|
|
251
256
|
customerEmail: preparedCustomerEmail,
|
|
257
|
+
paymentMethodTypes,
|
|
252
258
|
returnUrl,
|
|
253
259
|
user_id: userId,
|
|
254
260
|
environment: checkoutMode,
|
|
@@ -274,12 +280,13 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckou
|
|
|
274
280
|
setClientSecretIntentKey(requestKey);
|
|
275
281
|
rememberCheckoutSessionPaymentMethodTypes((_e = response.checkoutSessionId) === null || _e === void 0 ? void 0 : _e.trim(), response.paymentMethodTypes);
|
|
276
282
|
setCheckoutSessionId(((_f = response.checkoutSessionId) === null || _f === void 0 ? void 0 : _f.trim()) || null);
|
|
283
|
+
setAvailablePaymentMethodTypes((_g = response.availablePaymentMethodTypes) !== null && _g !== void 0 ? _g : null);
|
|
277
284
|
setClientSecretPlanKey(requestPlanKey);
|
|
278
285
|
return response.clientSecret;
|
|
279
286
|
}
|
|
280
287
|
catch (subscriptionError) {
|
|
281
|
-
if (((
|
|
282
|
-
((
|
|
288
|
+
if (((_h = creatingIntentRef.current) === null || _h === void 0 ? void 0 : _h.key) === requestKey &&
|
|
289
|
+
((_j = creatingIntentRef.current) === null || _j === void 0 ? void 0 : _j.id) === requestId) {
|
|
283
290
|
const failure = describeStripeCheckoutFailure(subscriptionError);
|
|
284
291
|
const message = failure.message;
|
|
285
292
|
const observabilityAnalytics = resolveCheckoutObservabilityAnalyticsContext({
|
|
@@ -307,8 +314,8 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckou
|
|
|
307
314
|
return null;
|
|
308
315
|
}
|
|
309
316
|
finally {
|
|
310
|
-
if (((
|
|
311
|
-
((
|
|
317
|
+
if (((_k = creatingIntentRef.current) === null || _k === void 0 ? void 0 : _k.key) === requestKey &&
|
|
318
|
+
((_l = creatingIntentRef.current) === null || _l === void 0 ? void 0 : _l.id) === requestId) {
|
|
312
319
|
creatingIntentRef.current = null;
|
|
313
320
|
}
|
|
314
321
|
}
|
|
@@ -329,6 +336,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckou
|
|
|
329
336
|
customerEmail,
|
|
330
337
|
displayPlan,
|
|
331
338
|
intentKey,
|
|
339
|
+
paymentMethodTypes,
|
|
332
340
|
plan,
|
|
333
341
|
planKey,
|
|
334
342
|
returnUrl,
|
|
@@ -460,9 +468,11 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckou
|
|
|
460
468
|
setError,
|
|
461
469
|
userId,
|
|
462
470
|
]);
|
|
471
|
+
const activeAvailablePaymentMethodTypes = clientSecretIntentKey === intentKey ? availablePaymentMethodTypes : null;
|
|
463
472
|
return useMemo(() => ({
|
|
464
473
|
activeClientSecret,
|
|
465
474
|
activePlanKey,
|
|
475
|
+
availablePaymentMethodTypes: activeAvailablePaymentMethodTypes,
|
|
466
476
|
checkoutSessionId: activeCheckoutSessionId,
|
|
467
477
|
configured,
|
|
468
478
|
error,
|
|
@@ -479,6 +489,7 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode: nextCheckou
|
|
|
479
489
|
stripePromise,
|
|
480
490
|
updateCheckoutSessionPlan,
|
|
481
491
|
}), [
|
|
492
|
+
activeAvailablePaymentMethodTypes,
|
|
482
493
|
activeCheckoutSessionId,
|
|
483
494
|
activeClientSecret,
|
|
484
495
|
activePlanKey,
|
|
@@ -3,11 +3,12 @@ export declare const toOneTimeCheckoutRequest: (input: CreateOneTimeCheckoutInpu
|
|
|
3
3
|
environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
|
|
4
4
|
runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
|
|
5
5
|
checkoutIdentityToken: string;
|
|
6
|
+
userId: string | undefined;
|
|
7
|
+
paymentMethodTypes?: readonly string[] | undefined;
|
|
6
8
|
couponId: string | undefined;
|
|
7
9
|
analyticsMetadata: Record<string, unknown> | undefined;
|
|
8
10
|
customerEmail: string | undefined;
|
|
9
11
|
returnUrl: string;
|
|
10
|
-
userId: string | undefined;
|
|
11
12
|
currency?: string | undefined;
|
|
12
13
|
money?: import("@funnelsgrove/runtime").ProviderMoney | undefined;
|
|
13
14
|
planKey: string;
|
|
@@ -27,11 +28,12 @@ export declare const toOneTimeCheckoutRequest: (input: CreateOneTimeCheckoutInpu
|
|
|
27
28
|
environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
|
|
28
29
|
runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
|
|
29
30
|
checkoutIdentityToken?: undefined;
|
|
31
|
+
userId: string | undefined;
|
|
32
|
+
paymentMethodTypes?: readonly string[] | undefined;
|
|
30
33
|
couponId: string | undefined;
|
|
31
34
|
analyticsMetadata: Record<string, unknown> | undefined;
|
|
32
35
|
customerEmail: string | undefined;
|
|
33
36
|
returnUrl: string;
|
|
34
|
-
userId: string | undefined;
|
|
35
37
|
currency?: string | undefined;
|
|
36
38
|
money?: import("@funnelsgrove/runtime").ProviderMoney | undefined;
|
|
37
39
|
planKey: string;
|
|
@@ -52,6 +54,8 @@ export declare const toSubscriptionCheckoutRequest: (input: CreateSubscriptionCh
|
|
|
52
54
|
environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
|
|
53
55
|
runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
|
|
54
56
|
checkoutIdentityToken: string;
|
|
57
|
+
userId: string | undefined;
|
|
58
|
+
paymentMethodTypes?: readonly string[] | undefined;
|
|
55
59
|
billingInterval: import("../../../../index.js").BillingPlanInterval;
|
|
56
60
|
billingIntervalCount: number;
|
|
57
61
|
followUpProviderPlanId: string | undefined;
|
|
@@ -63,7 +67,6 @@ export declare const toSubscriptionCheckoutRequest: (input: CreateSubscriptionCh
|
|
|
63
67
|
analyticsMetadata: Record<string, unknown> | undefined;
|
|
64
68
|
customerEmail: string | undefined;
|
|
65
69
|
returnUrl: string;
|
|
66
|
-
userId: string | undefined;
|
|
67
70
|
currency?: string | undefined;
|
|
68
71
|
money?: import("@funnelsgrove/runtime").ProviderMoney | undefined;
|
|
69
72
|
offerSetId: string | undefined;
|
|
@@ -83,6 +86,8 @@ export declare const toSubscriptionCheckoutRequest: (input: CreateSubscriptionCh
|
|
|
83
86
|
environment: import("@funnelsgrove/runtime").RuntimeMode | undefined;
|
|
84
87
|
runtimeConfig: import("@funnelsgrove/runtime").FunnelSdkRuntimeConfigOverrides | undefined;
|
|
85
88
|
checkoutIdentityToken?: undefined;
|
|
89
|
+
userId: string | undefined;
|
|
90
|
+
paymentMethodTypes?: readonly string[] | undefined;
|
|
86
91
|
billingInterval: import("../../../../index.js").BillingPlanInterval;
|
|
87
92
|
billingIntervalCount: number;
|
|
88
93
|
followUpProviderPlanId: string | undefined;
|
|
@@ -94,7 +99,6 @@ export declare const toSubscriptionCheckoutRequest: (input: CreateSubscriptionCh
|
|
|
94
99
|
analyticsMetadata: Record<string, unknown> | undefined;
|
|
95
100
|
customerEmail: string | undefined;
|
|
96
101
|
returnUrl: string;
|
|
97
|
-
userId: string | undefined;
|
|
98
102
|
currency?: string | undefined;
|
|
99
103
|
money?: import("@funnelsgrove/runtime").ProviderMoney | undefined;
|
|
100
104
|
offerSetId: string | undefined;
|
|
@@ -8,17 +8,17 @@ const toCheckoutIdentityRequestFields = (userId) => {
|
|
|
8
8
|
return checkoutIdentityToken ? { checkoutIdentityToken } : {};
|
|
9
9
|
};
|
|
10
10
|
export const toOneTimeCheckoutRequest = (input) => {
|
|
11
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
12
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ planKey: ((_a = input.plan.funnelPlanKey) === null || _a === void 0 ? void 0 : _a.trim()) || input.plan.id, runtimeConfigRevisionId: input.runtimeConfigRevisionId, paymentProfileId: input.paymentProfileId, provider: input.provider, anonymousUserId: input.anonymousUserId, idempotencyKey: input.idempotencyKey, offerSetId: ((_b = input.plan.offerSetId) === null || _b === void 0 ? void 0 : _b.trim()) || undefined, offerSetKey: ((_c = input.plan.offerSetKey) === null || _c === void 0 ? void 0 : _c.trim()) || undefined, planId: getPaywallPlanRequestId(input.plan), providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined, title: input.plan.title, description: ((_e = input.plan.description) === null || _e === void 0 ? void 0 : _e.trim()) || undefined, amountCents: input.plan.amountCents }, (input.plan.money ? { money: input.plan.money } : {})), (((_f = input.plan.money) === null || _f === void 0 ? void 0 : _f.currency) || input.plan.currency
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
12
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ planKey: ((_a = input.plan.funnelPlanKey) === null || _a === void 0 ? void 0 : _a.trim()) || input.plan.id, runtimeConfigRevisionId: input.runtimeConfigRevisionId, paymentProfileId: input.paymentProfileId, provider: input.provider, anonymousUserId: input.anonymousUserId, idempotencyKey: input.idempotencyKey, offerSetId: ((_b = input.plan.offerSetId) === null || _b === void 0 ? void 0 : _b.trim()) || undefined, offerSetKey: ((_c = input.plan.offerSetKey) === null || _c === void 0 ? void 0 : _c.trim()) || undefined, planId: getPaywallPlanRequestId(input.plan), providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined, title: input.plan.title, description: ((_e = input.plan.description) === null || _e === void 0 ? void 0 : _e.trim()) || undefined, amountCents: input.plan.amountCents }, (input.plan.money ? { money: input.plan.money } : {})), (((_f = input.plan.money) === null || _f === void 0 ? void 0 : _f.currency) || input.plan.currency
|
|
13
13
|
? { currency: (_h = (_g = input.plan.money) === null || _g === void 0 ? void 0 : _g.currency) !== null && _h !== void 0 ? _h : input.plan.currency }
|
|
14
|
-
: {})), { couponId: ((_j = input.couponId) === null || _j === void 0 ? void 0 : _j.trim()) || undefined, analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan), customerEmail: ((_k = input.customerEmail) === null || _k === void 0 ? void 0 : _k.trim()) || undefined, returnUrl: input.returnUrl, userId: ((
|
|
14
|
+
: {})), { couponId: ((_j = input.couponId) === null || _j === void 0 ? void 0 : _j.trim()) || undefined, analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan), customerEmail: ((_k = input.customerEmail) === null || _k === void 0 ? void 0 : _k.trim()) || undefined, returnUrl: input.returnUrl }), (((_l = input.paymentMethodTypes) === null || _l === void 0 ? void 0 : _l.length) ? { paymentMethodTypes: input.paymentMethodTypes } : {})), { userId: ((_m = input.user_id) === null || _m === void 0 ? void 0 : _m.trim()) || undefined }), toCheckoutIdentityRequestFields(input.user_id)), { environment: input.environment, runtimeConfig: input.runtimeConfig });
|
|
15
15
|
};
|
|
16
16
|
export const toSubscriptionCheckoutRequest = (input) => {
|
|
17
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
18
18
|
const recurring = requireCheckoutRecurringConfig(input.plan);
|
|
19
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ offerSetId: ((_a = input.plan.offerSetId) === null || _a === void 0 ? void 0 : _a.trim()) || undefined, offerSetKey: ((_b = input.plan.offerSetKey) === null || _b === void 0 ? void 0 : _b.trim()) || undefined, planId: getPaywallPlanRequestId(input.plan), planKey: ((_c = input.plan.funnelPlanKey) === null || _c === void 0 ? void 0 : _c.trim()) || input.plan.id, providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined, provider: input.provider, paymentProfileId: ((_e = input.paymentProfileId) === null || _e === void 0 ? void 0 : _e.trim()) || undefined, runtimeConfigRevisionId: ((_f = input.runtimeConfigRevisionId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined, anonymousUserId: ((_g = input.anonymousUserId) === null || _g === void 0 ? void 0 : _g.trim()) || undefined, idempotencyKey: ((_h = input.idempotencyKey) === null || _h === void 0 ? void 0 : _h.trim()) || undefined, title: input.plan.title, description: ((_j = input.plan.description) === null || _j === void 0 ? void 0 : _j.trim()) || undefined, amountCents: input.plan.amountCents }, (input.plan.money ? { money: input.plan.money } : {})), (((_k = input.plan.money) === null || _k === void 0 ? void 0 : _k.currency) || input.plan.currency
|
|
19
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ offerSetId: ((_a = input.plan.offerSetId) === null || _a === void 0 ? void 0 : _a.trim()) || undefined, offerSetKey: ((_b = input.plan.offerSetKey) === null || _b === void 0 ? void 0 : _b.trim()) || undefined, planId: getPaywallPlanRequestId(input.plan), planKey: ((_c = input.plan.funnelPlanKey) === null || _c === void 0 ? void 0 : _c.trim()) || input.plan.id, providerPlanId: ((_d = input.plan.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined, provider: input.provider, paymentProfileId: ((_e = input.paymentProfileId) === null || _e === void 0 ? void 0 : _e.trim()) || undefined, runtimeConfigRevisionId: ((_f = input.runtimeConfigRevisionId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined, anonymousUserId: ((_g = input.anonymousUserId) === null || _g === void 0 ? void 0 : _g.trim()) || undefined, idempotencyKey: ((_h = input.idempotencyKey) === null || _h === void 0 ? void 0 : _h.trim()) || undefined, title: input.plan.title, description: ((_j = input.plan.description) === null || _j === void 0 ? void 0 : _j.trim()) || undefined, amountCents: input.plan.amountCents }, (input.plan.money ? { money: input.plan.money } : {})), (((_k = input.plan.money) === null || _k === void 0 ? void 0 : _k.currency) || input.plan.currency
|
|
20
20
|
? { currency: (_m = (_l = input.plan.money) === null || _l === void 0 ? void 0 : _l.currency) !== null && _m !== void 0 ? _m : input.plan.currency }
|
|
21
|
-
: {})), { billingInterval: recurring.interval, billingIntervalCount: recurring.intervalCount, followUpProviderPlanId: ((_o = input.plan.followUpProviderPlanId) === null || _o === void 0 ? void 0 : _o.trim()) || undefined, followUpPlanTitle: ((_p = input.plan.followUpPlanTitle) === null || _p === void 0 ? void 0 : _p.trim()) || undefined, followUpBillingInterval: input.plan.followUpBillingInterval, followUpBillingIntervalCount: input.plan.followUpBillingIntervalCount, introIterations: input.plan.introIterations, couponId: ((_q = input.couponId) === null || _q === void 0 ? void 0 : _q.trim()) || undefined, analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan), customerEmail: ((_r = input.customerEmail) === null || _r === void 0 ? void 0 : _r.trim()) || undefined, returnUrl: input.returnUrl, userId: ((
|
|
21
|
+
: {})), { billingInterval: recurring.interval, billingIntervalCount: recurring.intervalCount, followUpProviderPlanId: ((_o = input.plan.followUpProviderPlanId) === null || _o === void 0 ? void 0 : _o.trim()) || undefined, followUpPlanTitle: ((_p = input.plan.followUpPlanTitle) === null || _p === void 0 ? void 0 : _p.trim()) || undefined, followUpBillingInterval: input.plan.followUpBillingInterval, followUpBillingIntervalCount: input.plan.followUpBillingIntervalCount, introIterations: input.plan.introIterations, couponId: ((_q = input.couponId) === null || _q === void 0 ? void 0 : _q.trim()) || undefined, analyticsMetadata: normalizeCheckoutAnalyticsMetadata(input.analyticsMetadata, input.plan), customerEmail: ((_r = input.customerEmail) === null || _r === void 0 ? void 0 : _r.trim()) || undefined, returnUrl: input.returnUrl }), (((_s = input.paymentMethodTypes) === null || _s === void 0 ? void 0 : _s.length) ? { paymentMethodTypes: input.paymentMethodTypes } : {})), { userId: ((_t = input.user_id) === null || _t === void 0 ? void 0 : _t.trim()) || undefined }), toCheckoutIdentityRequestFields(input.user_id)), { environment: input.environment, runtimeConfig: input.runtimeConfig });
|
|
22
22
|
};
|
|
23
23
|
export const toSubscriptionCheckoutPlanRequest = (input) => {
|
|
24
24
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
@@ -12,12 +12,17 @@ export type CreateOneTimeCheckoutInput = {
|
|
|
12
12
|
analyticsMetadata?: Record<string, unknown> | null;
|
|
13
13
|
customerEmail?: string | null;
|
|
14
14
|
returnUrl: string;
|
|
15
|
+
/** Embedded sessions only: restrict the session to these Stripe method types (CHECKOUT-BR-010). */
|
|
16
|
+
paymentMethodTypes?: readonly string[] | null;
|
|
15
17
|
user_id?: string | null;
|
|
16
18
|
environment?: RuntimeMode;
|
|
17
19
|
runtimeConfig?: StripeRuntimeConfigOverrides;
|
|
18
20
|
};
|
|
19
21
|
export type CreateOneTimeCheckoutResponse = {
|
|
20
22
|
clientSecret: string;
|
|
23
|
+
paymentMethodTypes?: string[];
|
|
24
|
+
/** Every method the offer supports, one session each (CHECKOUT-BR-010). */
|
|
25
|
+
availablePaymentMethodTypes?: string[];
|
|
21
26
|
checkoutSessionId?: string;
|
|
22
27
|
stripePublishableKey?: string;
|
|
23
28
|
environment?: 'test' | 'live';
|
|
@@ -37,6 +42,8 @@ export type CreateSubscriptionCheckoutInput = {
|
|
|
37
42
|
analyticsMetadata?: Record<string, unknown> | null;
|
|
38
43
|
customerEmail?: string | null;
|
|
39
44
|
returnUrl: string;
|
|
45
|
+
/** Embedded sessions only: restrict the session to these Stripe method types (CHECKOUT-BR-010). */
|
|
46
|
+
paymentMethodTypes?: readonly string[] | null;
|
|
40
47
|
user_id?: string | null;
|
|
41
48
|
environment?: RuntimeMode;
|
|
42
49
|
runtimeConfig?: StripeRuntimeConfigOverrides;
|
|
@@ -44,6 +51,8 @@ export type CreateSubscriptionCheckoutInput = {
|
|
|
44
51
|
export type CreateSubscriptionCheckoutResponse = {
|
|
45
52
|
clientSecret: string;
|
|
46
53
|
paymentMethodTypes?: string[];
|
|
54
|
+
/** Every method the offer supports, one session each (CHECKOUT-BR-010). */
|
|
55
|
+
availablePaymentMethodTypes?: string[];
|
|
47
56
|
checkoutSessionId?: string;
|
|
48
57
|
subscriptionId?: string;
|
|
49
58
|
stripePublishableKey?: string;
|
|
@@ -14,7 +14,7 @@ export type StripeSubscriptionCheckoutAnalyticsContext = {
|
|
|
14
14
|
};
|
|
15
15
|
export type TrackStripeSubscriptionCheckoutStartedInput = StripeSubscriptionCheckoutAnalyticsContext & {
|
|
16
16
|
checkoutSessionId?: string | null;
|
|
17
|
-
checkoutStartSource?: 'card_form_open' | 'wallet_click' | 'wallet_cancel';
|
|
17
|
+
checkoutStartSource?: 'card_form_open' | 'method_form_open' | 'wallet_click' | 'wallet_cancel';
|
|
18
18
|
paymentMethod?: unknown;
|
|
19
19
|
};
|
|
20
20
|
export type TrackPaidStripeSubscriptionCheckoutCompletedInput = StripeSubscriptionCheckoutAnalyticsContext & {
|
|
@@ -6,7 +6,10 @@ export const requiresStripeOneClickConfirmation = (status) => {
|
|
|
6
6
|
};
|
|
7
7
|
export async function completeStripeOneClickPayment(input) {
|
|
8
8
|
const payment = await chargeStripeOneClickPayment(input);
|
|
9
|
-
|
|
9
|
+
// CHECKOUT-BR-011: a Pix upsell shows its QR code only while it still awaits payment.
|
|
10
|
+
const confirmationAttempted = payment.paymentMethodType === 'pix'
|
|
11
|
+
? payment.status === 'requires_payment_method'
|
|
12
|
+
: requiresStripeOneClickConfirmation(payment.status);
|
|
10
13
|
const result = Object.assign(Object.assign({}, payment), { status: confirmationAttempted ? await confirmOneClickPayment(payment, input) : payment.status, confirmationAttempted });
|
|
11
14
|
try {
|
|
12
15
|
await trackPaidStripeOneClickPaymentCompleted(input, result);
|