@appfunnel-dev/sdk 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { useNavigation, useResponses } from './chunk-7JLCKTX6.js';
2
- export { useNavigation, useResponse, useResponses } from './chunk-7JLCKTX6.js';
3
- import { useFunnelContext } from './chunk-H5C2QJIY.js';
4
- export { FunnelProvider, registerIntegration } from './chunk-H5C2QJIY.js';
1
+ import { useNavigation, useResponses } from './chunk-YRHJBBAC.js';
2
+ export { useNavigation, useResponse, useResponses } from './chunk-YRHJBBAC.js';
3
+ import { useFunnelContext } from './chunk-7KOSK32P.js';
4
+ export { FunnelProvider, registerIntegration } from './chunk-7KOSK32P.js';
5
5
  import { forwardRef, useMemo, useRef, useEffect, useCallback, useImperativeHandle, useState, useSyncExternalStore } from 'react';
6
6
  import { loadStripe } from '@stripe/stripe-js';
7
7
  import { toast } from 'sonner';
@@ -1442,6 +1442,7 @@ var RealStripePaymentForm = forwardRef(
1442
1442
  const [clientSecret, setClientSecret] = useState(null);
1443
1443
  const [error, setError] = useState(null);
1444
1444
  const [isLoading, setIsLoading] = useState(false);
1445
+ const [alreadyCompleted, setAlreadyCompleted] = useState(false);
1445
1446
  const hasInitialized = useRef(false);
1446
1447
  useEffect(() => {
1447
1448
  if (!email || !campaignId || hasInitialized.current) return;
@@ -1486,6 +1487,25 @@ var RealStripePaymentForm = forwardRef(
1486
1487
  );
1487
1488
  const result = await response.json();
1488
1489
  if (!result.success) throw new Error(result.error || "Failed to create checkout session");
1490
+ if (result.alreadyCompleted) {
1491
+ variableStore.set("payment.error", "");
1492
+ if (result.subscriptionId) {
1493
+ variableStore.set("stripe.subscriptionId", result.subscriptionId);
1494
+ variableStore.set("subscription.status", result.status);
1495
+ }
1496
+ if (result.paymentIntentId) {
1497
+ variableStore.set("stripe.paymentIntentId", result.paymentIntentId);
1498
+ variableStore.set("payment.status", "succeeded");
1499
+ }
1500
+ tracker.track("checkout.already_completed");
1501
+ setAlreadyCompleted(true);
1502
+ if (variant === "embedded" && successPageKey) {
1503
+ router.goToPage(successPageKey);
1504
+ } else {
1505
+ onSuccess?.();
1506
+ }
1507
+ return;
1508
+ }
1489
1509
  setStripePromise(loadStripe(result.publishableKey));
1490
1510
  setClientSecret(result.clientSecret);
1491
1511
  } else {
@@ -1525,6 +1545,9 @@ var RealStripePaymentForm = forwardRef(
1525
1545
  };
1526
1546
  createIntent();
1527
1547
  }, [email, campaignId, product, paymentMode, validateOnly, variant, successPageKey, automaticTax, managedPayments, allowPromotionCodes, router, tracker, variableStore]);
1548
+ if (alreadyCompleted) {
1549
+ return null;
1550
+ }
1528
1551
  if (isLoading) {
1529
1552
  return /* @__PURE__ */ jsx("div", { className, style: { padding: "20px", textAlign: "center", color: "#6b7280" }, children: "Loading payment form..." });
1530
1553
  }