@funnelsgrove/payments 0.11.13 → 0.11.15

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.
@@ -34,9 +34,12 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAna
34
34
  const appliedServerUpdateKeyRef = useRef('');
35
35
  const [appliedServerUpdateKey, setAppliedServerUpdateKey] = useState('');
36
36
  const serverUpdatePromiseRef = useRef(null);
37
+ const [serverUpdateInFlight, setServerUpdateInFlight] = useState(false);
37
38
  const [walletAvailable, setWalletAvailable] = useState(initialAvailable !== null && initialAvailable !== void 0 ? initialAvailable : null);
38
39
  const normalizedServerUpdateKey = (serverUpdateKey === null || serverUpdateKey === void 0 ? void 0 : serverUpdateKey.trim()) || '';
39
- const serverUpdatePending = Boolean(normalizedServerUpdateKey && appliedServerUpdateKey !== normalizedServerUpdateKey);
40
+ const serverUpdatePending = serverUpdateInFlight ||
41
+ Boolean(serverUpdatePromiseRef.current) ||
42
+ Boolean(normalizedServerUpdateKey && appliedServerUpdateKey !== normalizedServerUpdateKey);
40
43
  const effectiveWalletAvailable = initialAvailable === true && walletAvailable !== false
41
44
  ? true
42
45
  : walletAvailable;
@@ -67,6 +70,7 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAna
67
70
  return true;
68
71
  }
69
72
  }
73
+ setServerUpdateInFlight(true);
70
74
  const updatePromise = (async () => {
71
75
  let updateCallbackFailed = false;
72
76
  const updateResult = await checkoutState.checkout.runServerUpdate(async () => {
@@ -109,6 +113,7 @@ export function StripeCheckoutExpressCheckoutButton({ beforeConfirm, checkoutAna
109
113
  finally {
110
114
  if (((_a = serverUpdatePromiseRef.current) === null || _a === void 0 ? void 0 : _a.promise) === updatePromise) {
111
115
  serverUpdatePromiseRef.current = null;
116
+ setServerUpdateInFlight(false);
112
117
  }
113
118
  }
114
119
  }, [checkoutAnalytics, checkoutSessionId, checkoutState, normalizedServerUpdateKey, onError, onServerUpdate]);
@@ -50,8 +50,9 @@ export type StripeSubscriptionCheckoutSession = {
50
50
  export declare const buildStripeSubscriptionCheckoutPreparationAnalyticsMetadata: (analyticsMetadata: Record<string, unknown> | null | undefined, options?: StripeSubscriptionCheckoutPreparationOptions) => Record<string, unknown> | null | undefined;
51
51
  export type StripeSubscriptionCheckoutIntentKeyInput = Pick<StripeSubscriptionCheckoutSessionInput, 'checkoutMode' | 'couponId' | 'customerEmail' | 'paymentProfileId' | 'provider' | 'returnUrl' | 'runtimeConfig' | 'runtimeConfigRevisionId' | 'stripePublishableKey' | 'userId'> & {
52
52
  analyticsMetadata?: Record<string, unknown> | null;
53
+ planKey?: string | null;
53
54
  };
54
- export declare function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponId, customerEmail, returnUrl, runtimeConfig, runtimeConfigRevisionId, paymentProfileId, provider, stripePublishableKey, userId, }: StripeSubscriptionCheckoutIntentKeyInput): string;
55
+ export declare function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponId, customerEmail, returnUrl, runtimeConfig, runtimeConfigRevisionId, paymentProfileId, planKey, provider, stripePublishableKey, userId, }: StripeSubscriptionCheckoutIntentKeyInput): string;
55
56
  export declare function shouldResetStripeSubscriptionCheckoutSessionForIntentKey(previousIntentKey: string | null, nextIntentKey: string): boolean;
56
57
  export declare function isInactiveCheckoutSessionError(message?: string | null): boolean;
57
58
  export declare const shouldReportStripeCheckoutFailureShown: (message: string) => boolean;
@@ -37,7 +37,7 @@ export const buildStripeSubscriptionCheckoutPreparationAnalyticsMetadata = (anal
37
37
  const _b = analyticsMetadata !== null && analyticsMetadata !== void 0 ? analyticsMetadata : {}, { payment_method: _paymentMethod, paymentMethod: _camelCasePaymentMethod } = _b, metadata = __rest(_b, ["payment_method", "paymentMethod"]);
38
38
  return Object.assign(Object.assign(Object.assign({}, metadata), (checkoutStartSource ? { checkoutStartSource } : {})), (paymentMethod ? { payment_method: paymentMethod } : {}));
39
39
  };
40
- export function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponId, customerEmail, returnUrl, runtimeConfig, runtimeConfigRevisionId, paymentProfileId, provider, stripePublishableKey, userId, }) {
40
+ export function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponId, customerEmail, returnUrl, runtimeConfig, runtimeConfigRevisionId, paymentProfileId, planKey, provider, stripePublishableKey, userId, }) {
41
41
  var _a;
42
42
  const runtimeConfigSignature = [
43
43
  normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.apiBaseUrl),
@@ -59,6 +59,7 @@ export function buildStripeSubscriptionCheckoutIntentKey({ checkoutMode, couponI
59
59
  customerEmailSignature,
60
60
  userIdSignature,
61
61
  (couponId === null || couponId === void 0 ? void 0 : couponId.trim()) || '',
62
+ (planKey === null || planKey === void 0 ? void 0 : planKey.trim()) || '',
62
63
  returnUrl.trim(),
63
64
  ].join('|');
64
65
  }
@@ -87,10 +88,18 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMe
87
88
  (isStripeConfigured(checkoutMode) ||
88
89
  Boolean(normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelSdkPublishableKey)) ||
89
90
  Boolean(normalizeRuntimeConfigValue(stripePublishableKey)));
91
+ const planKey = [
92
+ (_a = plan === null || plan === void 0 ? void 0 : plan.id) !== null && _a !== void 0 ? _a : '',
93
+ (_b = plan === null || plan === void 0 ? void 0 : plan.providerPlanId) !== null && _b !== void 0 ? _b : '',
94
+ (_c = plan === null || plan === void 0 ? void 0 : plan.amountCents) !== null && _c !== void 0 ? _c : '',
95
+ (_d = displayPlan === null || displayPlan === void 0 ? void 0 : displayPlan.id) !== null && _d !== void 0 ? _d : '',
96
+ (_e = displayPlan === null || displayPlan === void 0 ? void 0 : displayPlan.amountCents) !== null && _e !== void 0 ? _e : '',
97
+ ].join('|');
90
98
  const intentKey = buildStripeSubscriptionCheckoutIntentKey({
91
99
  checkoutMode,
92
100
  couponId,
93
101
  customerEmail,
102
+ planKey,
94
103
  returnUrl,
95
104
  runtimeConfig,
96
105
  runtimeConfigRevisionId,
@@ -99,13 +108,6 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMe
99
108
  stripePublishableKey,
100
109
  userId,
101
110
  });
102
- const planKey = [
103
- (_a = plan === null || plan === void 0 ? void 0 : plan.id) !== null && _a !== void 0 ? _a : '',
104
- (_b = plan === null || plan === void 0 ? void 0 : plan.providerPlanId) !== null && _b !== void 0 ? _b : '',
105
- (_c = plan === null || plan === void 0 ? void 0 : plan.amountCents) !== null && _c !== void 0 ? _c : '',
106
- (_d = displayPlan === null || displayPlan === void 0 ? void 0 : displayPlan.id) !== null && _d !== void 0 ? _d : '',
107
- (_e = displayPlan === null || displayPlan === void 0 ? void 0 : displayPlan.amountCents) !== null && _e !== void 0 ? _e : '',
108
- ].join('|');
109
111
  const activeClientSecret = clientSecretIntentKey === intentKey ? clientSecret : null;
110
112
  const activeCheckoutSessionId = clientSecretIntentKey === intentKey ? checkoutSessionId : null;
111
113
  const activePlanKey = clientSecretIntentKey === intentKey ? clientSecretPlanKey : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/payments",
3
- "version": "0.11.13",
3
+ "version": "0.11.15",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",