@funnelsgrove/payments 0.22.1 → 0.22.3

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.
@@ -68,6 +68,7 @@ const isAbortError = (error) => (error instanceof DOMException && error.name ===
68
68
  export function SolidgateCheckoutDialog({ open, request, customerEmail, checkoutAnalytics, content, presentation, onClose, onCustomerEmailCommit, onSuccess, onRetry, onError, onStateChange, }) {
69
69
  const copy = useMemo(() => (Object.assign(Object.assign({}, defaultContent), content)), [content]);
70
70
  const [view, setView] = useState(initialView);
71
+ const [retryRequest, setRetryRequest] = useState(null);
71
72
  const normalizedCustomerEmail = normalizeValidEmail(customerEmail);
72
73
  const [emailInput, setEmailInput] = useState((customerEmail === null || customerEmail === void 0 ? void 0 : customerEmail.trim()) || '');
73
74
  const [committedEmail, setCommittedEmail] = useState(normalizedCustomerEmail);
@@ -99,6 +100,8 @@ export function SolidgateCheckoutDialog({ open, request, customerEmail, checkout
99
100
  setEmailError(null);
100
101
  }, [customerEmail, normalizedCustomerEmail]);
101
102
  const { discountKeyOrProviderId, failUrl, funnelPlanKey, paymentProfileId, providerPlanId, checkoutType, environment, funnelEndUserId, funnelId, idempotencyKey, offerSetId, returnUrl, runtimeConfig, successUrl, } = request;
103
+ const checkoutKey = (retryRequest === null || retryRequest === void 0 ? void 0 : retryRequest.originalKey) === idempotencyKey
104
+ ? retryRequest.key : idempotencyKey;
102
105
  const { apiBaseUrl, funnelId: runtimeFunnelId, funnelSdkPublishableKey, funnelVersionId, paymentsApiVersion, } = runtimeConfig || {};
103
106
  const hasRuntimeConfig = runtimeConfig !== undefined;
104
107
  const normalizedRequest = useMemo(() => ({
@@ -110,7 +113,7 @@ export function SolidgateCheckoutDialog({ open, request, customerEmail, checkout
110
113
  providerPlanId: (providerPlanId === null || providerPlanId === void 0 ? void 0 : providerPlanId.trim()) || null,
111
114
  checkoutType: checkoutType || null,
112
115
  environment: environment || null,
113
- idempotencyKey: idempotencyKey.trim(),
116
+ idempotencyKey: checkoutKey.trim(),
114
117
  discountKeyOrProviderId: (discountKeyOrProviderId === null || discountKeyOrProviderId === void 0 ? void 0 : discountKeyOrProviderId.trim()) || null,
115
118
  returnUrl: returnUrl.trim(),
116
119
  successUrl: successUrl.trim(),
@@ -136,7 +139,7 @@ export function SolidgateCheckoutDialog({ open, request, customerEmail, checkout
136
139
  funnelSdkPublishableKey,
137
140
  funnelVersionId,
138
141
  paymentsApiVersion,
139
- idempotencyKey,
142
+ checkoutKey,
140
143
  offerSetId,
141
144
  returnUrl,
142
145
  hasRuntimeConfig,
@@ -392,5 +395,8 @@ export function SolidgateCheckoutDialog({ open, request, customerEmail, checkout
392
395
  setState(Object.assign(Object.assign({}, view), { state: 'recoverable_error', canResumeVerification: false }));
393
396
  trackFailure(copyRef.current.error, 'payment_form', (_a = view.checkout) === null || _a === void 0 ? void 0 : _a.attemptId);
394
397
  (_b = onErrorRef.current) === null || _b === void 0 ? void 0 : _b.call(onErrorRef, copyRef.current.error);
395
- } }, view.checkout.attemptId)) : null, presentation && view.checkout && showForm ? (_jsx("p", { className: 'solidgate-checkout-secure', children: presentation.secureLabel })) : null, statusMessage && view.state !== 'ready' ? (_jsx("div", { className: 'solidgate-checkout-status', children: _jsx("p", { role: 'status', "aria-live": 'polite', children: statusMessage }) })) : null, view.canResumeVerification ? (_jsx("button", { type: 'button', onClick: () => void verifyCanonicalStatus(), className: 'solidgate-checkout-action solidgate-checkout-action--spaced', children: copy.resumeVerification })) : null, (view.state === 'recoverable_error' || view.state === 'expired') && !view.canResumeVerification && onRetry ? (_jsx("button", { type: 'button', onClick: onRetry, className: 'solidgate-checkout-action solidgate-checkout-action--spaced', children: copy.retry })) : null] })) : null] }), _jsx("style", { children: solidgateCheckoutDialogStyles })] }));
398
+ } }, view.checkout.attemptId)) : null, presentation && view.checkout && showForm ? (_jsx("p", { className: 'solidgate-checkout-secure', children: presentation.secureLabel })) : null, statusMessage && view.state !== 'ready' ? (_jsx("div", { className: 'solidgate-checkout-status', children: _jsx("p", { role: 'status', "aria-live": 'polite', children: statusMessage }) })) : null, view.canResumeVerification ? (_jsx("button", { type: 'button', onClick: () => void verifyCanonicalStatus(), className: 'solidgate-checkout-action solidgate-checkout-action--spaced', children: copy.resumeVerification })) : null, (view.state === 'recoverable_error' || view.state === 'expired') && !view.canResumeVerification ? (_jsx("button", { type: 'button', onClick: onRetry || (() => setRetryRequest({
399
+ originalKey: idempotencyKey,
400
+ key: crypto.randomUUID(),
401
+ })), className: 'solidgate-checkout-action solidgate-checkout-action--spaced', children: copy.retry })) : null] })) : null] }), _jsx("style", { children: solidgateCheckoutDialogStyles })] }));
396
402
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/payments",
3
- "version": "0.22.1",
3
+ "version": "0.22.3",
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.19.1",
50
- "@funnelsgrove/analytics": "0.2.0"
49
+ "@funnelsgrove/runtime": "0.20.0",
50
+ "@funnelsgrove/analytics": "0.3.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "@funnelsgrove/runtime": "^0.19.1",
54
- "@funnelsgrove/analytics": "^0.1.111 || ^0.2.0"
53
+ "@funnelsgrove/runtime": "^0.19.1 || ^0.20.0",
54
+ "@funnelsgrove/analytics": "^0.1.111 || ^0.2.0 || ^0.3.0"
55
55
  }
56
56
  }