@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
@@ -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: ((_l = input.user_id) === null || _l === void 0 ? void 0 : _l.trim()) || undefined }), toCheckoutIdentityRequestFields(input.user_id)), { environment: input.environment, runtimeConfig: input.runtimeConfig });
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: ((_s = input.user_id) === null || _s === void 0 ? void 0 : _s.trim()) || undefined }), toCheckoutIdentityRequestFields(input.user_id)), { environment: input.environment, runtimeConfig: input.runtimeConfig });
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 & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/payments",
3
- "version": "0.67.0",
3
+ "version": "0.69.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",
@@ -46,11 +46,11 @@
46
46
  "jsdom": "20.0.3",
47
47
  "typescript": "^5",
48
48
  "vitest": "^3.2.4",
49
- "@funnelsgrove/runtime": "0.43.0",
50
- "@funnelsgrove/analytics": "0.26.0"
49
+ "@funnelsgrove/runtime": "0.44.0",
50
+ "@funnelsgrove/analytics": "0.27.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "@funnelsgrove/runtime": "^0.43.0",
54
- "@funnelsgrove/analytics": "^0.26.0"
53
+ "@funnelsgrove/runtime": "^0.44.0",
54
+ "@funnelsgrove/analytics": "^0.27.0"
55
55
  }
56
56
  }
@@ -1,18 +0,0 @@
1
- import type { PlatformWalletPaymentMethod } from './walletPlatform.js';
2
- type Props = {
3
- showWalletMethod: boolean;
4
- showPayPalMethod: boolean;
5
- selectedMethod: 'wallet' | 'card';
6
- disabled: boolean;
7
- /** `accordion`: only the wallet option; Stripe's accordion lists cards and other methods below it. */
8
- layout?: 'tabs' | 'accordion';
9
- paymentMethodLabel: string;
10
- cardLabel: string;
11
- walletAriaLabel: string;
12
- walletPaymentMethods: readonly PlatformWalletPaymentMethod[];
13
- cardBrandLabels: readonly string[];
14
- onWalletSelect: () => void;
15
- onCardSelect: () => void;
16
- };
17
- export declare function SharedCheckoutPaymentMethods({ showWalletMethod, showPayPalMethod, selectedMethod, disabled, layout, paymentMethodLabel, cardLabel, walletAriaLabel, walletPaymentMethods, cardBrandLabels, onWalletSelect, onCardSelect }: Props): import("react/jsx-runtime").JSX.Element;
18
- export {};
@@ -1,15 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { PaymentBrandMark } from './CheckoutBrandAssets.js';
3
- export function SharedCheckoutPaymentMethods({ showWalletMethod, showPayPalMethod, selectedMethod, disabled, layout = 'tabs', paymentMethodLabel, cardLabel, walletAriaLabel, walletPaymentMethods, cardBrandLabels, onWalletSelect, onCardSelect }) {
4
- return (_jsxs("div", { className: 'shared-checkout-v2-methods', "data-paypal": showPayPalMethod ? 'true' : undefined, "data-layout": layout, role: layout === 'accordion' ? 'radiogroup' : 'tablist', "aria-label": paymentMethodLabel, children: [showWalletMethod ? _jsxs("button", { type: 'button', disabled: disabled, className: [
5
- 'shared-checkout-v2-method',
6
- selectedMethod === 'wallet' ? 'is-selected' : '',
7
- ]
8
- .filter(Boolean)
9
- .join(' '), onClick: onWalletSelect, role: layout === 'accordion' ? 'radio' : 'tab', "aria-selected": layout === 'accordion' ? undefined : selectedMethod === 'wallet', "aria-checked": layout === 'accordion' ? selectedMethod === 'wallet' : undefined, children: [layout === 'accordion' ? _jsx("span", { className: 'shared-checkout-v2-method-radio', "aria-hidden": 'true' }) : null, _jsxs("span", { className: 'shared-checkout-v2-tab-wallets', "aria-hidden": 'true', children: [showPayPalMethod ? _jsx(PaymentBrandMark, { label: 'PayPal', className: 'shared-checkout-v2-tab-wallet' }) : null, walletPaymentMethods.includes('applePay') ? (_jsx(PaymentBrandMark, { label: 'Apple Pay', className: 'shared-checkout-v2-tab-wallet' })) : null, walletPaymentMethods.includes('googlePay') ? (_jsx(PaymentBrandMark, { label: 'Google Pay', className: 'shared-checkout-v2-tab-wallet' })) : null] }), _jsx("span", { className: 'shared-checkout-v2-sr-only', children: walletAriaLabel })] }) : null, layout === 'accordion' ? null : _jsxs("button", { type: 'button', className: [
10
- 'shared-checkout-v2-method',
11
- selectedMethod === 'card' ? 'is-selected' : '',
12
- ]
13
- .filter(Boolean)
14
- .join(' '), disabled: disabled, onClick: onCardSelect, role: 'tab', "aria-selected": selectedMethod === 'card', children: [_jsx("strong", { children: cardLabel }), _jsx("span", { className: 'shared-checkout-v2-tab-brands', "aria-hidden": 'true', children: cardBrandLabels.slice(0, 4).map((label) => (_jsx(PaymentBrandMark, { label: label, className: 'shared-checkout-v2-tab-brand' }, label))) })] })] }));
15
- }
@@ -1,7 +0,0 @@
1
- import type { SharedStripeCheckoutV2DialogProps } from './SharedStripeCheckoutV2Dialog.js';
2
- export declare const getFixedSupportedBillingCountry: (supportedCountries: readonly string[]) => string | null;
3
- type SharedStripeCheckoutV2FormProps = Omit<SharedStripeCheckoutV2DialogProps, 'stripePromise' | 'onClose'> & {
4
- onClose: () => void;
5
- };
6
- export declare function SharedStripeCheckoutV2CheckoutSessionForm({ copy, amountCents, buttonColor, cardSubmitLabel, closeAriaLabel, countdownLabel, checkoutAnalytics, checkoutSessionId, customerEmail, customerEmailEditable: allowEmailEditing, customerEmailLabel, customerEmailPlaceholder, customerEmailInvalidMessage, customerName, discountAmountLabel, discountLabel, discountPercent, initialWalletAvailable, onClose, onWalletCancel, onCustomerEmailChange, onCustomerEmailCommit, onError, onInactiveCheckoutSession, onPaymentInfoSubmitted, onSuccess, paymentMethodLabels, paypalCheckout, paypalPending, paypalLabel, promoActive, processingLabel, promoCode, promoCodeLabel, remainingSeconds, returnUrl, savedLabel, secureLabel, satisfactionLabel, satisfactionPercent, summaryLabel, supportedCountries, themeColor, title, totalLabel, totalValue, unsupportedCountryMessage, walletButtonLabel, originalPriceLabel, originalPriceValue, variant, presentation, }: SharedStripeCheckoutV2FormProps): import("react/jsx-runtime").JSX.Element;
7
- export {};
@@ -1,328 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { completePaywallCheckout } from '@funnelsgrove/runtime';
4
- import { useEffect, useMemo, useRef, useState } from 'react';
5
- import { PaymentElement, useCheckout } from '@stripe/react-stripe-js/checkout';
6
- import { isValidCheckoutEmail as isValidEmail, isCheckoutEmailError } from '../../../services/checkoutEmail.js';
7
- import { resolveCheckoutReturnUrl } from '../services/checkout/checkoutReturnUrl.js';
8
- import { PaymentBrandMark, SecurityLockIcon } from './CheckoutBrandAssets.js';
9
- import { StripeCheckoutExpressCheckoutButton } from './StripeCheckoutExpressCheckoutButton.js';
10
- import { getUnsupportedCheckoutCountryMessage, normalizeSupportedCheckoutCountries } from './checkoutCountries.js';
11
- import { isInactiveCheckoutSessionError } from '../hooks/useStripeSubscriptionCheckoutSession.js';
12
- import { getStripeWalletPaymentMethodOrder, usePlatformWalletPaymentMethods } from './walletPlatform.js';
13
- import { trackPaidStripeSubscriptionCheckoutCompleted, trackStripeSubscriptionPaymentInfoSubmitted } from '../services/checkoutCompletionAnalytics.service.js';
14
- import { trackCheckoutFailureShown } from '../../../services/checkoutObservability.service.js';
15
- import { isStripeCheckoutAlreadyPaidError, normalizeStripeCheckoutError } from '../services/stripeCheckoutError.js';
16
- import { SharedCheckoutPaymentMethods } from './SharedCheckoutPaymentMethods.internal.js';
17
- import { SharedStripeCheckoutV2Summary } from './SharedStripeCheckoutV2Summary.internal.js';
18
- import { useCheckoutEmail } from './useCheckoutEmail.internal.js';
19
- import { getCheckoutSessionPaymentMethodTypes } from '../services/checkoutSessionPaymentMethods.js';
20
- import { defaultCheckoutV2Copy } from './checkout-v2.content.js';
21
- const defaultPaymentMethodLabels = ['Visa', 'Mastercard', 'Maestro', 'Discover'];
22
- export const getFixedSupportedBillingCountry = (supportedCountries) => supportedCountries.length === 1 ? supportedCountries[0] : null;
23
- const getCheckoutCountryLabel = (countryCode, copy) => { var _a; return (_a = copy.countryNames[countryCode]) !== null && _a !== void 0 ? _a : countryCode; };
24
- function getFriendlyCardErrorMessage(error, fallback) {
25
- return error instanceof Error && error.message
26
- ? error.message
27
- : fallback;
28
- }
29
- export function SharedStripeCheckoutV2CheckoutSessionForm({ copy = defaultCheckoutV2Copy, amountCents, buttonColor, cardSubmitLabel, closeAriaLabel, countdownLabel, checkoutAnalytics, checkoutSessionId, customerEmail, customerEmailEditable: allowEmailEditing = false, customerEmailLabel = 'Email', customerEmailPlaceholder = 'Enter your email', customerEmailInvalidMessage = 'Enter a valid email address.', customerName, discountAmountLabel, discountLabel, discountPercent, initialWalletAvailable, onClose, onWalletCancel, onCustomerEmailChange, onCustomerEmailCommit, onError, onInactiveCheckoutSession, onPaymentInfoSubmitted, onSuccess, paymentMethodLabels = defaultPaymentMethodLabels, paypalCheckout, paypalPending = false, paypalLabel, promoActive, processingLabel, promoCode, promoCodeLabel, remainingSeconds, returnUrl, savedLabel, secureLabel, satisfactionLabel, satisfactionPercent, summaryLabel, supportedCountries, themeColor, title, totalLabel, totalValue, unsupportedCountryMessage, walletButtonLabel, originalPriceLabel, originalPriceValue, variant = 'standard', presentation = 'dialog', }) {
30
- const checkoutState = useCheckout();
31
- const walletPaymentMethods = usePlatformWalletPaymentMethods();
32
- const [selectedMethod, setSelectedMethod] = useState('wallet');
33
- const [walletAvailable, setWalletAvailable] = useState(initialWalletAvailable !== null && initialWalletAvailable !== void 0 ? initialWalletAvailable : null);
34
- const effectiveWalletAvailable = initialWalletAvailable === true && walletAvailable !== false
35
- ? true
36
- : walletAvailable;
37
- const [submitting, setSubmitting] = useState(false);
38
- const [walletConfirming, setWalletConfirming] = useState(false);
39
- const [completed, setCompleted] = useState(false);
40
- const [providerConfirmed, setProviderConfirmed] = useState(false);
41
- const submitInFlightRef = useRef(false);
42
- const [paymentElementReady, setPaymentElementReady] = useState(false);
43
- const [paymentElementComplete, setPaymentElementComplete] = useState(false);
44
- const paymentElementRef = useRef(null);
45
- const [stripeMethodType, setStripeMethodType] = useState('card');
46
- const [accordionExpanded, setAccordionExpanded] = useState(null);
47
- // CHECKOUT-BR-010: a session with methods beyond cards shows Stripe's accordion next to the wallet option.
48
- const accordionLayout = getCheckoutSessionPaymentMethodTypes(checkoutSessionId).some((type) => type !== 'card');
49
- const [error, setError] = useState(null);
50
- const [billingCountry, setBillingCountry] = useState(null);
51
- const { initialCustomerEmail, resolvedCustomerEmail, customerEmailEditable, emailDraft, setEmailDraft, rejectedEmail, setRejectedEmail, emailSaving, emailSessionChanged, commitEmailDraftIfValid, ensureCustomerEmail } = useCheckoutEmail({
52
- customerEmail, allowEmailEditing, customerEmailInvalidMessage,
53
- onCustomerEmailCommit, onCustomerEmailChange, onError: (message) => setSharedError(message),
54
- });
55
- const normalizedSupportedCountries = useMemo(() => normalizeSupportedCheckoutCountries(supportedCountries), [supportedCountries]);
56
- const fixedBillingCountry = getFixedSupportedBillingCountry(normalizedSupportedCountries);
57
- const fixedBillingCountryLabel = fixedBillingCountry
58
- ? getCheckoutCountryLabel(fixedBillingCountry, copy)
59
- : null;
60
- const cardBrandLabels = useMemo(() => paymentMethodLabels.length > 0 ? paymentMethodLabels : defaultPaymentMethodLabels, [paymentMethodLabels]);
61
- const normalizedPromoCode = promoCode.trim();
62
- const showPromo = promoActive !== null && promoActive !== void 0 ? promoActive : (discountPercent > 0 && normalizedPromoCode.length > 0);
63
- const emailFieldClassName = [
64
- 'shared-checkout-v2-email-field',
65
- customerEmailEditable ? '' : 'is-disabled',
66
- ]
67
- .filter(Boolean)
68
- .join(' ');
69
- const checkoutStyle = {
70
- '--shared-checkout-v2-theme-color': themeColor,
71
- '--shared-checkout-v2-button-color': buttonColor,
72
- };
73
- const expressCheckoutSummaryLabel = (summaryLabel === null || summaryLabel === void 0 ? void 0 : summaryLabel.trim()) || discountLabel || title;
74
- const showPayPalMethod = presentation === 'dialog' && Boolean(paypalCheckout);
75
- const walletAriaLabel = [
76
- ...(showPayPalMethod ? [paypalLabel] : []),
77
- ...walletPaymentMethods.map((method) => method === 'applePay' ? walletButtonLabel : 'Google Pay'),
78
- ].join(' / ');
79
- const walletEmailReady = !emailSessionChanged && isValidEmail(initialCustomerEmail)
80
- && rejectedEmail === null && resolvedCustomerEmail === initialCustomerEmail;
81
- const showPlatformWallets = presentation !== 'inline' && walletEmailReady
82
- && effectiveWalletAvailable !== false && walletPaymentMethods.length > 0;
83
- const showWalletMethod = showPlatformWallets || showPayPalMethod;
84
- const effectiveSelectedMethod = showWalletMethod && (paypalPending || selectedMethod === 'wallet') ? 'wallet' : 'card';
85
- const expressCheckoutOptions = useMemo(() => {
86
- return {
87
- buttonHeight: 55,
88
- buttonTheme: {
89
- applePay: 'black',
90
- googlePay: 'black',
91
- },
92
- buttonType: {
93
- applePay: 'subscribe',
94
- googlePay: 'subscribe',
95
- },
96
- layout: {
97
- maxColumns: 1,
98
- maxRows: 2,
99
- overflow: 'auto',
100
- },
101
- paymentMethodOrder: getStripeWalletPaymentMethodOrder(walletPaymentMethods),
102
- paymentMethods: {
103
- amazonPay: 'never',
104
- applePay: walletPaymentMethods.includes('applePay') ? 'always' : 'never',
105
- googlePay: walletPaymentMethods.includes('googlePay') ? 'always' : 'never',
106
- klarna: 'never',
107
- link: 'never',
108
- paypal: 'never',
109
- },
110
- };
111
- }, [walletPaymentMethods]);
112
- const paymentElementOptions = useMemo(() => {
113
- return Object.assign(Object.assign({ fields: {
114
- billingDetails: {
115
- name: 'never',
116
- email: 'never',
117
- address: {
118
- country: fixedBillingCountry ? 'never' : 'auto',
119
- },
120
- },
121
- }, layout: accordionLayout
122
- ? {
123
- type: 'accordion',
124
- defaultCollapsed: effectiveSelectedMethod === 'wallet',
125
- radios: true,
126
- spacedAccordionItems: true,
127
- visibleAccordionItemsCount: 0,
128
- }
129
- : 'tabs' }, (accordionLayout ? { paymentMethodOrder: ['card'] } : {})), { wallets: {
130
- applePay: 'never',
131
- googlePay: 'never',
132
- link: 'never',
133
- } });
134
- // The initial collapsed state is read once when Stripe mounts the element.
135
- // eslint-disable-next-line react-hooks/exhaustive-deps
136
- }, [accordionLayout, fixedBillingCountry]);
137
- const accordionStartsExpanded = typeof paymentElementOptions.layout === 'object'
138
- && paymentElementOptions.layout.defaultCollapsed === false;
139
- const showCardForm = accordionLayout
140
- ? (accordionExpanded !== null && accordionExpanded !== void 0 ? accordionExpanded : accordionStartsExpanded) && effectiveSelectedMethod === 'card'
141
- : true;
142
- const handleInactiveCheckoutSession = () => {
143
- setError(null);
144
- onInactiveCheckoutSession === null || onInactiveCheckoutSession === void 0 ? void 0 : onInactiveCheckoutSession();
145
- };
146
- const setSharedError = (message, alreadyTracked = false, details) => {
147
- const errorDetails = message ? details !== null && details !== void 0 ? details : normalizeStripeCheckoutError(message, undefined, 'card') : undefined;
148
- if (isCheckoutEmailError({ code: errorDetails === null || errorDetails === void 0 ? void 0 : errorDetails.providerErrorCode }) || isCheckoutEmailError(message)) {
149
- setRejectedEmail(initialCustomerEmail);
150
- setSelectedMethod('card');
151
- }
152
- if (isInactiveCheckoutSessionError(message)) {
153
- handleInactiveCheckoutSession();
154
- return;
155
- }
156
- if (message && checkoutAnalytics && !alreadyTracked) {
157
- trackCheckoutFailureShown(Object.assign({ analytics: checkoutAnalytics, checkoutSessionId, errorMessage: message, failureStage: 'card_form', provider: 'stripe' }, errorDetails));
158
- }
159
- setError(message);
160
- if (message)
161
- onError === null || onError === void 0 ? void 0 : onError(message, errorDetails);
162
- else
163
- onError === null || onError === void 0 ? void 0 : onError(message);
164
- };
165
- const selectWalletMethod = () => {
166
- var _a;
167
- if (showWalletMethod && !paypalPending && !submitting) {
168
- setSelectedMethod('wallet');
169
- if (accordionLayout)
170
- (_a = paymentElementRef.current) === null || _a === void 0 ? void 0 : _a.collapse();
171
- }
172
- };
173
- const selectCardMethod = () => { if (!paypalPending && !submitting)
174
- setSelectedMethod('card'); };
175
- const handleWalletAvailabilityChange = (available) => {
176
- setWalletAvailable(available);
177
- if (!available && !showPayPalMethod && selectedMethod === 'wallet') {
178
- setSelectedMethod('card');
179
- }
180
- };
181
- const getBillingCountryError = (country) => getUnsupportedCheckoutCountryMessage({
182
- billingCountry: country,
183
- message: unsupportedCountryMessage,
184
- supportedCountries: normalizedSupportedCountries,
185
- });
186
- const handlePaymentElementChange = (event) => {
187
- var _a, _b, _c;
188
- setPaymentElementComplete(event.complete);
189
- setStripeMethodType(event.value.type);
190
- if (accordionLayout)
191
- setAccordionExpanded(!event.collapsed);
192
- if (accordionLayout && !event.collapsed) {
193
- // While a wallet or PayPal payment is in flight the wallet option stays selected.
194
- if (paypalPending || walletConfirming)
195
- (_a = paymentElementRef.current) === null || _a === void 0 ? void 0 : _a.collapse();
196
- else
197
- setSelectedMethod('card');
198
- }
199
- setBillingCountry((_c = (_b = event.value.billingDetails) === null || _b === void 0 ? void 0 : _b.address.country) !== null && _c !== void 0 ? _c : fixedBillingCountry);
200
- };
201
- const trackCheckoutSuccess = async (embedded = false) => {
202
- if (checkoutAnalytics) {
203
- await trackPaidStripeSubscriptionCheckoutCompleted(Object.assign({ checkoutSessionId }, checkoutAnalytics));
204
- }
205
- if (!embedded)
206
- await (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess());
207
- };
208
- const trackPaymentInfoSubmitted = async () => {
209
- if (checkoutAnalytics) {
210
- await trackStripeSubscriptionPaymentInfoSubmitted(Object.assign({ checkoutSessionId }, checkoutAnalytics)).catch(() => 'analytics_rejected');
211
- }
212
- await (onPaymentInfoSubmitted === null || onPaymentInfoSubmitted === void 0 ? void 0 : onPaymentInfoSubmitted());
213
- };
214
- useEffect(() => {
215
- if (effectiveSelectedMethod !== 'card' || typeof window === 'undefined') {
216
- return;
217
- }
218
- const resizeTimer = window.setTimeout(() => {
219
- window.dispatchEvent(new Event('resize'));
220
- }, 0);
221
- return () => window.clearTimeout(resizeTimer);
222
- }, [effectiveSelectedMethod]);
223
- const handleSubmit = async (event) => {
224
- event.preventDefault();
225
- if (paypalPending)
226
- return;
227
- if (submitInFlightRef.current || (emailSessionChanged && !providerConfirmed)) {
228
- return;
229
- }
230
- if (!providerConfirmed) {
231
- const billingCountryError = getBillingCountryError(billingCountry !== null && billingCountry !== void 0 ? billingCountry : fixedBillingCountry);
232
- if (billingCountryError) {
233
- setSharedError(billingCountryError);
234
- return;
235
- }
236
- if (checkoutState.type !== 'success') {
237
- setSharedError(checkoutState.type === 'error'
238
- ? checkoutState.error.message
239
- : copy.formNotReady);
240
- return;
241
- }
242
- if (!paymentElementReady) {
243
- setSharedError(copy.formNotReady, true);
244
- return;
245
- }
246
- }
247
- submitInFlightRef.current = true;
248
- setSubmitting(true);
249
- setSharedError(null);
250
- const finishSubmitting = () => {
251
- submitInFlightRef.current = false;
252
- setSubmitting(false);
253
- };
254
- let confirmed = providerConfirmed;
255
- try {
256
- if (!providerConfirmed && checkoutState.type === 'success') {
257
- const syncedEmail = await ensureCustomerEmail();
258
- if (!syncedEmail) {
259
- finishSubmitting();
260
- return;
261
- }
262
- if (paymentElementComplete) {
263
- await trackPaymentInfoSubmitted();
264
- }
265
- const result = await checkoutState.checkout.confirm({
266
- redirect: 'if_required',
267
- });
268
- if (result.type === 'error' && !isStripeCheckoutAlreadyPaidError(result.error)) {
269
- const message = result.error.message || copy.paymentFailed;
270
- setSharedError(message, false, normalizeStripeCheckoutError(message, result.error, 'card'));
271
- finishSubmitting();
272
- return;
273
- }
274
- confirmed = true;
275
- setProviderConfirmed(true);
276
- }
277
- if (typeof window !== 'undefined') {
278
- if (await completePaywallCheckout('stripe', checkoutSessionId || '', { beforeNotify: async () => {
279
- setCompleted(true);
280
- await trackCheckoutSuccess(true);
281
- } })) {
282
- return;
283
- }
284
- await trackCheckoutSuccess();
285
- window.location.assign(resolveCheckoutReturnUrl(returnUrl, checkoutSessionId));
286
- return;
287
- }
288
- finishSubmitting();
289
- }
290
- catch (submitError) {
291
- setSharedError(getFriendlyCardErrorMessage(submitError, copy.cardError), confirmed);
292
- finishSubmitting();
293
- }
294
- };
295
- const emailField = (_jsxs("label", { className: emailFieldClassName, children: [_jsx("span", { className: 'shared-checkout-v2-email-label', children: customerEmailLabel }), _jsx("span", { className: 'shared-checkout-v2-email-control', children: _jsx("input", { type: 'email', autoComplete: 'email', className: 'shared-checkout-v2-email-input', disabled: !customerEmailEditable || emailSaving, inputMode: 'email', readOnly: !customerEmailEditable, value: customerEmailEditable ? emailDraft : initialCustomerEmail, placeholder: customerEmailPlaceholder, onBlur: (event) => commitEmailDraftIfValid(event.currentTarget.value), onChange: (event) => {
296
- if (!customerEmailEditable) {
297
- return;
298
- }
299
- setEmailDraft(event.target.value);
300
- } }) })] }));
301
- const visibleError = error;
302
- if (providerConfirmed && !completed)
303
- return _jsxs("form", { onSubmit: handleSubmit, className: 'shared-checkout-v2-verifying', style: checkoutStyle, children: [_jsx("p", { role: error ? 'alert' : 'status', children: error || copy.verifyingPayment }), _jsx("button", { type: 'submit', disabled: submitting, className: 'shared-checkout-v2-status-button', children: copy.checkPaymentStatus })] });
304
- if (completed)
305
- return _jsx("div", { role: 'status', className: 'shared-checkout-v2-confirmed', style: checkoutStyle, children: copy.paymentConfirmed });
306
- return (_jsxs("div", { className: 'shared-checkout-v2-shell', "data-variant": variant, style: checkoutStyle, children: [presentation === 'dialog' ? _jsxs(_Fragment, { children: [_jsxs("header", { className: 'shared-checkout-v2-header', children: [_jsx("button", { type: 'button', className: 'shared-checkout-v2-close', onClick: onClose, "aria-label": closeAriaLabel, children: _jsx("span", { "aria-hidden": 'true' }) }), _jsx("h2", { id: 'shared-checkout-v2-title', children: title })] }), !(showPayPalMethod && effectiveSelectedMethod === 'wallet') ? _jsx(SharedStripeCheckoutV2Summary, { countdownUnit: copy.countdownUnit, discountPercent, countdownLabel, remainingSeconds, variant, satisfactionPercent, satisfactionLabel, originalPriceLabel, originalPriceValue, discountLabel, discountAmountLabel, promoCodeLabel, promoCode, totalLabel, totalValue, savedLabel, showPromo }) : null] }) : null, _jsxs("form", { className: 'shared-checkout-v2-payment', onSubmit: (event) => void handleSubmit(event), children: [showWalletMethod || showPayPalMethod ? (_jsx(SharedCheckoutPaymentMethods, { showWalletMethod: showWalletMethod, showPayPalMethod: showPayPalMethod, selectedMethod: effectiveSelectedMethod, disabled: paypalPending || submitting || walletConfirming, layout: accordionLayout ? 'accordion' : 'tabs', paymentMethodLabel: copy.paymentMethodLabel, cardLabel: copy.cardLabel, walletAriaLabel: walletAriaLabel, walletPaymentMethods: walletPaymentMethods, cardBrandLabels: cardBrandLabels, onWalletSelect: selectWalletMethod, onCardSelect: selectCardMethod })) : null, presentation === 'dialog' ? _jsxs("div", { hidden: effectiveSelectedMethod !== 'wallet', className: [
307
- 'shared-checkout-v2-wallet-panel',
308
- effectiveSelectedMethod === 'wallet' ? 'is-visible' : '',
309
- ]
310
- .filter(Boolean)
311
- .join(' '), children: [_jsxs("p", { className: 'shared-checkout-v2-secure-pill', children: [_jsx(SecurityLockIcon, { className: 'shared-checkout-v2-secure-pill-icon' }), secureLabel] }), showPayPalMethod && effectiveSelectedMethod === 'wallet' ? _jsx("div", { className: 'shared-checkout-v2-paypal-button', "aria-label": paypalLabel, inert: walletConfirming || submitting, children: paypalCheckout }) : null, _jsxs("div", { inert: paypalPending, hidden: !showPlatformWallets, className: 'shared-checkout-v2-wallet-shell', "aria-label": walletAriaLabel, children: [_jsx(StripeCheckoutExpressCheckoutButton, { amountCents: amountCents, availabilityPaymentMethods: walletPaymentMethods, beforeConfirm: async () => {
312
- if (paypalPending)
313
- return null;
314
- setWalletConfirming(true);
315
- const email = await ensureCustomerEmail();
316
- if (!email)
317
- setWalletConfirming(false);
318
- return email;
319
- }, checkoutAnalytics: checkoutAnalytics, checkoutSessionId: checkoutSessionId, className: 'shared-checkout-v2-express-buttons', confirmEmail: false, customerEmail: resolvedCustomerEmail, customerName: customerName, initialAvailable: initialWalletAvailable, keepInitialAvailableOnReady: initialWalletAvailable === true, onAvailabilityChange: handleWalletAvailabilityChange, onCancel: () => { setWalletConfirming(false); onWalletCancel === null || onWalletCancel === void 0 ? void 0 : onWalletCancel(); }, onError: (message, details) => setSharedError(message, true, details), onPaymentInfoSubmitted: onPaymentInfoSubmitted, onPaymentRejected: () => { setWalletConfirming(false); setSelectedMethod('card'); }, onSuccess: () => trackCheckoutSuccess(), onEmbeddedComplete: () => setCompleted(true), onVerificationPending: () => setProviderConfirmed(true), options: expressCheckoutOptions, returnUrl: returnUrl, summaryLabel: expressCheckoutSummaryLabel, supportedCountries: normalizedSupportedCountries, unsupportedCountryMessage: unsupportedCountryMessage }), _jsx("span", { className: 'shared-checkout-v2-sr-only', children: walletAriaLabel })] })] }) : null, _jsxs("div", { hidden: !accordionLayout && effectiveSelectedMethod !== 'card', className: [
320
- 'shared-checkout-v2-card-panel',
321
- accordionLayout || effectiveSelectedMethod === 'card' ? 'is-visible' : '',
322
- ]
323
- .filter(Boolean)
324
- .join(' '), children: [_jsxs("div", { className: 'shared-checkout-v2-card-box', children: [accordionLayout ? null : emailField, _jsx(PaymentElement, { options: paymentElementOptions, onChange: handlePaymentElementChange, onReady: (element) => {
325
- paymentElementRef.current = element;
326
- setPaymentElementReady(true);
327
- } }), accordionLayout && showCardForm ? emailField : null, fixedBillingCountry && fixedBillingCountryLabel ? (_jsxs("label", { className: 'shared-checkout-v2-country-field', children: [_jsx("span", { className: 'shared-checkout-v2-country-label', children: copy.billingCountryLabel }), _jsx("span", { className: 'shared-checkout-v2-country-control', children: _jsx("select", { "aria-label": copy.billingCountryLabel, className: 'shared-checkout-v2-country-select', value: fixedBillingCountry, onChange: () => setBillingCountry(fixedBillingCountry), children: _jsx("option", { value: fixedBillingCountry, children: fixedBillingCountryLabel }) }) })] })) : null] }), visibleError ? _jsx("p", { className: 'shared-checkout-v2-error', children: visibleError }) : null, showCardForm ? _jsxs(_Fragment, { children: [_jsxs("button", { type: 'submit', className: 'shared-checkout-v2-card-submit', disabled: submitting || emailSaving || emailSessionChanged || !paymentElementReady, children: [_jsx(SecurityLockIcon, { className: 'shared-checkout-v2-card-submit-icon' }), submitting || emailSaving || emailSessionChanged ? processingLabel : cardSubmitLabel] }), stripeMethodType === 'card' ? _jsx("div", { className: 'shared-checkout-v2-card-brands', "aria-hidden": 'true', children: cardBrandLabels.map((label) => (_jsx(PaymentBrandMark, { label: label, className: 'shared-checkout-v2-card-brand' }, label))) }) : null, _jsxs("p", { className: 'shared-checkout-v2-secure-pill shared-checkout-v2-secure-pill--card', children: [_jsx(SecurityLockIcon, { className: 'shared-checkout-v2-secure-pill-icon' }), secureLabel] })] }) : null] })] })] }));
328
- }
@@ -1,7 +0,0 @@
1
- import type { SharedStripeCheckoutV2DialogProps } from './SharedStripeCheckoutV2Dialog.js';
2
- type SummaryProps = Pick<SharedStripeCheckoutV2DialogProps, 'discountPercent' | 'countdownLabel' | 'remainingSeconds' | 'variant' | 'satisfactionPercent' | 'satisfactionLabel' | 'originalPriceLabel' | 'originalPriceValue' | 'discountLabel' | 'discountAmountLabel' | 'promoCodeLabel' | 'promoCode' | 'totalLabel' | 'totalValue' | 'savedLabel'> & {
3
- showPromo: boolean;
4
- countdownUnit: string;
5
- };
6
- export declare function SharedStripeCheckoutV2Summary({ discountPercent, countdownLabel, remainingSeconds, variant, satisfactionPercent, satisfactionLabel, originalPriceLabel, originalPriceValue, discountLabel, discountAmountLabel, promoCodeLabel, promoCode, totalLabel, totalValue, savedLabel, showPromo, countdownUnit }: SummaryProps): import("react/jsx-runtime").JSX.Element;
7
- export {};
@@ -1,19 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- const formatCountdown = (remainingSeconds) => {
3
- const normalizedSeconds = Number.isFinite(remainingSeconds)
4
- ? Math.max(0, Math.floor(remainingSeconds))
5
- : 0;
6
- const minutes = Math.floor(normalizedSeconds / 60);
7
- const seconds = normalizedSeconds % 60;
8
- return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
9
- };
10
- export function SharedStripeCheckoutV2Summary({ discountPercent, countdownLabel, remainingSeconds, variant, satisfactionPercent, satisfactionLabel, originalPriceLabel, originalPriceValue, discountLabel, discountAmountLabel, promoCodeLabel, promoCode, totalLabel, totalValue, savedLabel, showPromo, countdownUnit }) {
11
- const countdownValue = formatCountdown(remainingSeconds);
12
- const normalizedPromoCode = promoCode.trim();
13
- return (_jsxs("section", { className: 'shared-checkout-v2-summary', children: [showPromo ? (_jsxs("p", { className: 'shared-checkout-v2-countdown', children: [discountPercent, "% ", countdownLabel, " ", countdownValue, " ", countdownUnit] })) : null, variant === 'standard' ? (_jsxs("p", { className: 'shared-checkout-v2-satisfaction', children: [_jsx("strong", { children: satisfactionPercent }), " ", satisfactionLabel] })) : null, showPromo ? (_jsxs("div", { className: 'shared-checkout-v2-price-stack', children: [_jsxs("div", { className: 'shared-checkout-v2-price-row is-muted', children: [_jsx("span", { children: originalPriceLabel }), _jsx("span", { className: 'shared-checkout-v2-strike', children: originalPriceValue })] }), _jsxs("div", { className: 'shared-checkout-v2-price-row is-discount', children: [_jsx("strong", { children: discountLabel }), _jsx("strong", { children: discountAmountLabel })] }), _jsxs("div", { className: 'shared-checkout-v2-promo', children: [_jsx("span", { children: promoCodeLabel }), _jsx("strong", { children: normalizedPromoCode })] })] })) : null, _jsxs("div", { className: [
14
- 'shared-checkout-v2-total',
15
- showPromo ? '' : 'is-plain',
16
- ]
17
- .filter(Boolean)
18
- .join(' '), children: [_jsx("span", { children: totalLabel }), _jsxs("strong", { children: [_jsx("svg", { viewBox: '0 0 24 24', "aria-hidden": 'true', children: _jsx("path", { d: 'M20.6 13.4 12.4 21.6a2.2 2.2 0 0 1-3.1 0L2.4 14.7a2.2 2.2 0 0 1-.6-1.6V5.4a2 2 0 0 1 2-2h7.7a2.2 2.2 0 0 1 1.6.6l7.5 7.5a1.4 1.4 0 0 1 0 1.9ZM7.2 8.1a1.2 1.2 0 1 0 0-2.4 1.2 1.2 0 0 0 0 2.4Z' }) }), totalValue] })] }), showPromo ? (_jsxs("p", { className: 'shared-checkout-v2-saved', children: [_jsx("span", { "aria-hidden": 'true', children: "\uD83D\uDD25" }), savedLabel] })) : null] }));
19
- }