@funnelsgrove/payments 0.67.0 → 0.69.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.
Files changed (40) hide show
  1. package/README.md +58 -19
  2. package/dist/components/CheckoutErrorOverlay.d.ts +37 -0
  3. package/dist/components/CheckoutErrorOverlay.js +67 -0
  4. package/dist/generated/package-version.d.ts +1 -1
  5. package/dist/generated/package-version.js +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/providers/solidgate/components/SolidgateCheckoutDialog.js +5 -1
  8. package/dist/providers/solidgate/services/solidgateDeclineMessage.js +1 -1
  9. package/dist/providers/stripe/components/SharedStripeCheckoutV2Dialog.d.ts +13 -4
  10. package/dist/providers/stripe/components/SharedStripeCheckoutV2Dialog.js +93 -88
  11. package/dist/providers/stripe/components/StripeCheckoutDialog.d.ts +31 -0
  12. package/dist/providers/stripe/components/StripeCheckoutDialog.js +179 -0
  13. package/dist/providers/stripe/components/StripeWalletFirstCheckout.d.ts +91 -2
  14. package/dist/providers/stripe/components/StripeWalletFirstCheckout.js +361 -111
  15. package/dist/providers/stripe/components/StripeWalletFirstCheckout.options.d.ts +24 -0
  16. package/dist/providers/stripe/components/StripeWalletFirstCheckout.options.js +17 -0
  17. package/dist/providers/stripe/components/StripeWalletFirstCheckout.styles.d.ts +3 -1
  18. package/dist/providers/stripe/components/StripeWalletFirstCheckout.styles.js +24 -9
  19. package/dist/providers/stripe/components/WalletButton.d.ts +22 -0
  20. package/dist/providers/stripe/components/WalletButton.js +52 -0
  21. package/dist/providers/stripe/components/checkout-v2.content.d.ts +3 -0
  22. package/dist/providers/stripe/components/index.d.ts +2 -0
  23. package/dist/providers/stripe/components/index.js +2 -0
  24. package/dist/providers/stripe/components/useCheckoutEmail.internal.d.ts +3 -1
  25. package/dist/providers/stripe/components/useCheckoutEmail.internal.js +8 -3
  26. package/dist/providers/stripe/hooks/useStripeOneTimeCheckoutSession.d.ts +10 -3
  27. package/dist/providers/stripe/hooks/useStripeOneTimeCheckoutSession.js +18 -8
  28. package/dist/providers/stripe/hooks/useStripeSubscriptionCheckoutSession.d.ts +10 -3
  29. package/dist/providers/stripe/hooks/useStripeSubscriptionCheckoutSession.js +19 -8
  30. package/dist/providers/stripe/services/checkout/requests.d.ts +8 -4
  31. package/dist/providers/stripe/services/checkout/requests.js +6 -6
  32. package/dist/providers/stripe/services/checkout/types.d.ts +9 -0
  33. package/dist/providers/stripe/services/checkoutCompletionAnalytics.service.d.ts +1 -1
  34. package/package.json +5 -5
  35. package/dist/providers/stripe/components/SharedCheckoutPaymentMethods.internal.d.ts +0 -18
  36. package/dist/providers/stripe/components/SharedCheckoutPaymentMethods.internal.js +0 -15
  37. package/dist/providers/stripe/components/SharedStripeCheckoutV2Form.internal.d.ts +0 -7
  38. package/dist/providers/stripe/components/SharedStripeCheckoutV2Form.internal.js +0 -328
  39. package/dist/providers/stripe/components/SharedStripeCheckoutV2Summary.internal.d.ts +0 -7
  40. package/dist/providers/stripe/components/SharedStripeCheckoutV2Summary.internal.js +0 -19
@@ -0,0 +1,17 @@
1
+ /** `CheckoutProvider` options shared by every Checkout Session scope of the wallet-first checkout. Internal to the package. */
2
+ const appearance = {
3
+ labels: 'above',
4
+ variables: {
5
+ borderRadius: '12px',
6
+ colorBackground: '#fff',
7
+ colorText: '#303136',
8
+ colorTextPlaceholder: '#8c909a',
9
+ spacingUnit: '4px',
10
+ },
11
+ };
12
+ /** `fixedBillingCountry` fills in the only billing country the offer accepts. */
13
+ export function buildWalletFirstCheckoutOptions(clientSecret, themeColor, fixedBillingCountry) {
14
+ return Object.assign(Object.assign({ clientSecret }, (fixedBillingCountry ? { defaultValues: { billingAddress: { address: { country: fixedBillingCountry } } } } : {})), { elementsOptions: {
15
+ appearance: Object.assign(Object.assign({}, appearance), { variables: Object.assign(Object.assign({}, appearance.variables), (themeColor ? { colorPrimary: themeColor } : {})) }),
16
+ } });
17
+ }
@@ -1,2 +1,4 @@
1
+ /** Wallet slot of WalletButton: progress bar, Stripe's wallet button and the unavailable note share one height. */
2
+ export declare const walletButtonStyles = "\n.wfc-wallet-slot { position:relative; height:55px; }\n.wfc-wallet-button { height:55px; overflow:hidden; border-radius:12px; }\n.wfc-progress { position:relative; display:block; height:100%; overflow:hidden; border-radius:12px; background:#eef0f6; }\n.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; }\n.wfc-progress--overlay { position:absolute; inset:0; z-index:1; }\n@keyframes wfc-sheen { to { transform:translateX(100%); } }\n@media (prefers-reduced-motion: reduce) { .wfc-progress::after { animation:none; } }\n.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; }\n";
1
3
  /** Styles for StripeWalletFirstCheckout; colors come from its `themeColor` and `buttonColor` props. */
2
- export declare const stripeWalletFirstCheckoutStyles = "\n.wfc { display:grid; gap:12px; }\n/* The radio marks the choice; every card keeps the same quiet border. */\n.wfc-method { border-radius:16px; background:#fff; box-shadow:0 0 0 1.5px #e6e6ec; }\n.wfc-method-head { display:flex; align-items:center; gap:14px; width:100%; min-height:60px; padding:14px 16px; border:0; background:transparent; color:inherit; text-align:left; cursor:pointer; border-radius:16px; }\n.wfc-method-head:disabled { cursor:default; }\n.wfc-method-head:focus-visible { outline:3px solid var(--wfc-theme); outline-offset:2px; }\n.wfc-radio { flex:none; width:24px; height:24px; border-radius:50%; border:2px solid #b8bac4; background:#fff; transition:border-color .2s ease, box-shadow .2s ease; }\n.wfc-method[data-checked='true'] .wfc-radio { border-color:var(--wfc-theme); box-shadow:inset 0 0 0 4px #fff, inset 0 0 0 12px var(--wfc-theme); }\n.wfc-method-body { display:grid; grid-template-rows:0fr; opacity:0; transition:grid-template-rows .34s cubic-bezier(.25,.8,.25,1), opacity .22s ease; }\n.wfc-method-body[data-open='true'] { grid-template-rows:1fr; opacity:1; transition:grid-template-rows .34s cubic-bezier(.25,.8,.25,1), opacity .28s ease .08s; }\n.wfc-method-clip { min-height:0; overflow:hidden; }\n.wfc-method-content { padding:0 16px 16px; }\n@media (prefers-reduced-motion: reduce) { .wfc-method-body, .wfc-method-body[data-open='true'] { transition:none; } }\n.wfc-mark { height:30px; width:auto; color:#000; }\n.wfc-card-marks { display:flex; gap:6px; align-items:center; }\n.wfc-brand { width:40px; height:26px; border-radius:4px; }\n.wfc-benefits { margin:0 0 16px; padding:0; list-style:none; display:grid; gap:10px; font-size:15px; line-height:1.4; color:#303136; }\n.wfc-benefits li { display:flex; gap:10px; align-items:flex-start; }\n.wfc-check { flex:none; width:16px; height:16px; margin-top:2px; color:var(--wfc-theme); }\n.wfc-wallet-slot { position:relative; height:55px; }\n.wfc-wallet-button { height:55px; overflow:hidden; border-radius:12px; }\n.wfc-progress { position:relative; display:block; height:100%; overflow:hidden; border-radius:12px; background:#eef0f6; }\n.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; }\n.wfc-progress--overlay { position:absolute; inset:0; z-index:1; }\n.wfc-progress--form { height:320px; }\n@keyframes wfc-sheen { to { transform:translateX(100%); } }\n@media (prefers-reduced-motion: reduce) { .wfc-progress::after { animation:none; } }\n.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; }\n.wfc-secure { margin:16px 0 0; text-align:center; font-size:14px; line-height:1.45; color:#8c909a; }\n.wfc-card-form { display:grid; gap:14px; }\n.wfc-card-form .wfc-secure { margin-top:0; }\n.wfc-submit { min-height:52px; border:0; border-radius:12px; background:var(--wfc-button); color:#fff; font:600 17px/1.2 inherit; cursor:pointer; }\n.wfc-submit:disabled { opacity:.6; cursor:default; }\n.wfc-error { margin:0; color:#c62828; font-size:14px; text-align:center; }\n.wfc-secure.is-status { color:var(--wfc-theme); font-weight:600; }\n";
4
+ export declare const stripeWalletFirstCheckoutStyles = "\n.wfc { position:relative; display:grid; gap:12px; }\n/* The radio marks the choice; every card keeps the same quiet border. */\n.wfc-method { border-radius:16px; background:#fff; box-shadow:0 0 0 1.5px #e6e6ec; }\n.wfc-method-head { display:flex; align-items:center; gap:14px; width:100%; min-height:60px; padding:14px 16px; border:0; background:transparent; color:inherit; text-align:left; cursor:pointer; border-radius:16px; }\n.wfc-method-head:disabled { cursor:default; }\n.wfc-method-head:focus-visible { outline:3px solid var(--wfc-theme); outline-offset:2px; }\n.wfc-radio { flex:none; width:24px; height:24px; border-radius:50%; border:2px solid #b8bac4; background:#fff; transition:border-color .2s ease, box-shadow .2s ease; }\n.wfc-method[data-checked='true'] .wfc-radio { border-color:var(--wfc-theme); box-shadow:inset 0 0 0 4px #fff, inset 0 0 0 12px var(--wfc-theme); }\n.wfc-method-body { display:grid; grid-template-rows:0fr; opacity:0; transition:grid-template-rows .34s cubic-bezier(.25,.8,.25,1), opacity .22s ease; }\n.wfc-method-body[data-open='true'] { grid-template-rows:1fr; opacity:1; transition:grid-template-rows .34s cubic-bezier(.25,.8,.25,1), opacity .28s ease .08s; }\n.wfc-method-clip { min-height:0; overflow:hidden; }\n.wfc-method-content { padding:0 16px 16px; }\n@media (prefers-reduced-motion: reduce) { .wfc-method-body, .wfc-method-body[data-open='true'] { transition:none; } }\n.wfc-mark { height:30px; width:auto; color:#000; }\n.wfc-card-marks { display:flex; gap:6px; align-items:center; }\n.wfc-brand { width:40px; height:26px; border-radius:4px; }\n.wfc-benefits { margin:0 0 16px; padding:0; list-style:none; display:grid; gap:10px; font-size:15px; line-height:1.4; color:#303136; }\n.wfc-benefits li { display:flex; gap:10px; align-items:flex-start; }\n.wfc-check { flex:none; width:16px; height:16px; margin-top:2px; color:var(--wfc-theme); }\n\n.wfc-wallet-slot { position:relative; height:55px; }\n.wfc-wallet-button { height:55px; overflow:hidden; border-radius:12px; }\n.wfc-progress { position:relative; display:block; height:100%; overflow:hidden; border-radius:12px; background:#eef0f6; }\n.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; }\n.wfc-progress--overlay { position:absolute; inset:0; z-index:1; }\n@keyframes wfc-sheen { to { transform:translateX(100%); } }\n@media (prefers-reduced-motion: reduce) { .wfc-progress::after { animation:none; } }\n.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; }\n\n.wfc-progress--form { height:320px; }\n.wfc-method-label { font-size:17px; font-weight:600; line-height:1.2; color:#303136; }\n.wfc-secure { margin:16px 0 0; text-align:center; font-size:14px; line-height:1.45; color:#8c909a; }\n.wfc-card-form { display:grid; gap:14px; }\n.wfc-card-form .wfc-secure { margin-top:0; }\n.wfc-submit { min-height:52px; border:0; border-radius:12px; background:var(--wfc-button); color:#fff; font:600 17px/1.2 inherit; cursor:pointer; }\n.wfc-submit:disabled { opacity:.6; cursor:default; }\n.wfc-error { margin:0; color:#c62828; font-size:14px; text-align:center; }\n.wfc-secure:empty { display:none; }\n.wfc-email { display:grid; gap:6px; }\n.wfc-email-label { font-size:14px; line-height:1.3; color:#303136; }\n.wfc-email-input { box-sizing:border-box; width:100%; min-height:44px; padding:10px 12px; border:1px solid #e0e0e6; border-radius:12px; background:#fff; color:#303136; font:inherit; font-size:16px; }\n.wfc-email-input:focus { outline:none; border-color:var(--wfc-theme); box-shadow:0 0 0 3px color-mix(in srgb, var(--wfc-theme) 22%, transparent); }\n.wfc-email-input:disabled { opacity:.6; }\n.wfc-card-marks .wfc-brand { display:inline-flex; }\n.wfc-card-marks .wfc-brand svg, .wfc-brand--paypal svg { width:100%; height:100%; }\n.wfc-brand--paypal { display:inline-flex; width:64px; height:26px; }\n.wfc-paypal { min-height:55px; }\n.wfc-secure.is-status { color:var(--wfc-theme); font-weight:600; }\n";
@@ -1,6 +1,17 @@
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
- .wfc { display:grid; gap:12px; }
14
+ .wfc { position:relative; display:grid; gap:12px; }
4
15
  /* The radio marks the choice; every card keeps the same quiet border. */
5
16
  .wfc-method { border-radius:16px; background:#fff; box-shadow:0 0 0 1.5px #e6e6ec; }
6
17
  .wfc-method-head { display:flex; align-items:center; gap:14px; width:100%; min-height:60px; padding:14px 16px; border:0; background:transparent; color:inherit; text-align:left; cursor:pointer; border-radius:16px; }
@@ -19,20 +30,24 @@ 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
- .wfc-wallet-slot { position:relative; height:55px; }
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
- @keyframes wfc-sheen { to { transform:translateX(100%); } }
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; }
34
39
  .wfc-submit { min-height:52px; border:0; border-radius:12px; background:var(--wfc-button); color:#fff; font:600 17px/1.2 inherit; cursor:pointer; }
35
40
  .wfc-submit:disabled { opacity:.6; cursor:default; }
36
41
  .wfc-error { margin:0; color:#c62828; font-size:14px; text-align:center; }
42
+ .wfc-secure:empty { display:none; }
43
+ .wfc-email { display:grid; gap:6px; }
44
+ .wfc-email-label { font-size:14px; line-height:1.3; color:#303136; }
45
+ .wfc-email-input { box-sizing:border-box; width:100%; min-height:44px; padding:10px 12px; border:1px solid #e0e0e6; border-radius:12px; background:#fff; color:#303136; font:inherit; font-size:16px; }
46
+ .wfc-email-input:focus { outline:none; border-color:var(--wfc-theme); box-shadow:0 0 0 3px color-mix(in srgb, var(--wfc-theme) 22%, transparent); }
47
+ .wfc-email-input:disabled { opacity:.6; }
48
+ .wfc-card-marks .wfc-brand { display:inline-flex; }
49
+ .wfc-card-marks .wfc-brand svg, .wfc-brand--paypal svg { width:100%; height:100%; }
50
+ .wfc-brand--paypal { display:inline-flex; width:64px; height:26px; }
51
+ .wfc-paypal { min-height:55px; }
37
52
  .wfc-secure.is-status { color:var(--wfc-theme); font-weight:600; }
38
53
  `;
@@ -0,0 +1,22 @@
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' | 'onPaymentInfoSubmitted' | 'onPaymentRejected' | 'onSuccess' | 'onVerificationPending' | 'returnUrl' | 'summaryLabel' | 'supportedCountries' | 'unsupportedCountryMessage'> & {
12
+ /** Availability known from an earlier render: the button shows without the progress bar. */
13
+ initialAvailable?: boolean | null;
14
+ wallet: PlatformWalletPaymentMethod;
15
+ /** Accessible name of the progress bar. */
16
+ processingLabel: string;
17
+ /** Shown in the slot when this browser cannot pay with the wallet. */
18
+ unavailableNote: string;
19
+ /** Own Checkout Session scope for a standalone placement; omit inside an existing `CheckoutProvider`. */
20
+ session?: WalletButtonSession;
21
+ };
22
+ 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 { initialAvailable = null, onAvailabilityChange, processingLabel, unavailableNote, wallet } = _a, button = __rest(_a, ["initialAvailable", "onAvailabilityChange", "processingLabel", "unavailableNote", "wallet"]);
38
+ // null until Stripe answers; the slot shows progress at the button's height meanwhile.
39
+ const [available, setAvailable] = useState(initialAvailable);
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, initialAvailable: initialAvailable, keepInitialAvailableOnReady: initialAvailable === true, 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
+ }
@@ -1,3 +1,4 @@
1
+ import type { CheckoutErrorOverlayCopy } from '../../../components/CheckoutErrorOverlay.js';
1
2
  export type SharedStripeCheckoutV2Copy = {
2
3
  paymentMethodLabel: string;
3
4
  countdownUnit: string;
@@ -10,5 +11,7 @@ export type SharedStripeCheckoutV2Copy = {
10
11
  paymentConfirmed: string;
11
12
  billingCountryLabel: string;
12
13
  countryNames: Readonly<Record<string, string>>;
14
+ /** Titles and buttons of the payment error panel; English defaults. `checkPaymentStatus` labels its status check. */
15
+ errors?: CheckoutErrorOverlayCopy;
13
16
  };
14
17
  export declare const defaultCheckoutV2Copy: SharedStripeCheckoutV2Copy;
@@ -12,5 +12,7 @@ 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 './StripeCheckoutDialog.js';
16
+ export * from './WalletButton.js';
15
17
  export * from './WalletSubscriptionCheckoutSlot.js';
16
18
  export * from './walletPlatform.js';
@@ -12,5 +12,7 @@ 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 './StripeCheckoutDialog.js';
16
+ export * from './WalletButton.js';
15
17
  export * from './WalletSubscriptionCheckoutSlot.js';
16
18
  export * from './walletPlatform.js';
@@ -3,8 +3,10 @@ type EmailInput = Pick<SharedStripeCheckoutV2DialogProps, 'customerEmail' | 'onC
3
3
  allowEmailEditing: boolean;
4
4
  customerEmailInvalidMessage: string;
5
5
  onError: (message: string) => void;
6
+ /** The Checkout Session the email belongs to; a replaced session starts from its own email. */
7
+ sessionKey?: string | null;
6
8
  };
7
- export declare function useCheckoutEmail({ customerEmail, allowEmailEditing, customerEmailInvalidMessage, onCustomerEmailCommit, onCustomerEmailChange, onError }: EmailInput): {
9
+ export declare function useCheckoutEmail({ customerEmail, allowEmailEditing, customerEmailInvalidMessage, onCustomerEmailCommit, onCustomerEmailChange, onError, sessionKey }: EmailInput): {
8
10
  initialCustomerEmail: string;
9
11
  resolvedCustomerEmail: string;
10
12
  customerEmailEditable: boolean;
@@ -1,12 +1,17 @@
1
1
  'use client';
2
2
  import { useRef, useState } from 'react';
3
3
  import { isValidCheckoutEmail as isValidEmail, normalizeCheckoutEmailResult } from '../../../services/checkoutEmail.js';
4
- export function useCheckoutEmail({ customerEmail, allowEmailEditing, customerEmailInvalidMessage, onCustomerEmailCommit, onCustomerEmailChange, onError }) {
4
+ export function useCheckoutEmail({ customerEmail, allowEmailEditing, customerEmailInvalidMessage, onCustomerEmailCommit, onCustomerEmailChange, onError, sessionKey = null }) {
5
5
  const initialCustomerEmail = (customerEmail === null || customerEmail === void 0 ? void 0 : customerEmail.trim()) || '';
6
- const sessionCustomerEmail = useRef(initialCustomerEmail).current;
7
- const emailSessionChanged = sessionCustomerEmail !== initialCustomerEmail;
6
+ const [session, setSession] = useState({ key: sessionKey, email: initialCustomerEmail });
8
7
  const [emailDraft, setEmailDraft] = useState(initialCustomerEmail);
9
8
  const [rejectedEmail, setRejectedEmail] = useState(null);
9
+ if (session.key !== sessionKey) {
10
+ setSession({ key: sessionKey, email: initialCustomerEmail });
11
+ setEmailDraft(initialCustomerEmail);
12
+ setRejectedEmail(null);
13
+ }
14
+ const emailSessionChanged = session.key === sessionKey && session.email !== initialCustomerEmail;
10
15
  const customerEmailEditable = allowEmailEditing || !isValidEmail(initialCustomerEmail) || rejectedEmail !== null;
11
16
  const resolvedCustomerEmail = customerEmailEditable
12
17
  ? emailDraft.trim()
@@ -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 (((_e = creatingIntentRef.current) === null || _e === void 0 ? void 0 : _e.key) === requestKey &&
249
- ((_f = creatingIntentRef.current) === null || _f === void 0 ? void 0 : _f.id) === requestId) {
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 (((_g = creatingIntentRef.current) === null || _g === void 0 ? void 0 : _g.key) === requestKey &&
281
- ((_h = creatingIntentRef.current) === null || _h === void 0 ? void 0 : _h.id) === requestId) {
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 (((_g = creatingIntentRef.current) === null || _g === void 0 ? void 0 : _g.key) === requestKey &&
282
- ((_h = creatingIntentRef.current) === null || _h === void 0 ? void 0 : _h.id) === requestId) {
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 (((_j = creatingIntentRef.current) === null || _j === void 0 ? void 0 : _j.key) === requestKey &&
311
- ((_k = creatingIntentRef.current) === null || _k === void 0 ? void 0 : _k.id) === requestId) {
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,