@tagadapay/plugin-sdk 2.7.36 → 2.7.37

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.
@@ -66,13 +66,20 @@ export function useCheckoutQuery(options = {}) {
66
66
  // Internal token state that can be updated after init
67
67
  const [internalToken, setInternalToken] = useState(providedToken);
68
68
  // Update internal token when provided token changes
69
+ // Always sync when providedToken is explicitly provided (not undefined)
69
70
  useEffect(() => {
70
- if (providedToken && providedToken !== internalToken) {
71
+ // If providedToken is explicitly set (not undefined), sync internalToken
72
+ // This handles both: null -> string and string -> string transitions
73
+ if (providedToken !== undefined && providedToken !== internalToken) {
71
74
  setInternalToken(providedToken);
72
75
  }
76
+ // If providedToken is undefined, keep internalToken (from init) - don't clear it
77
+ }, [providedToken, internalToken]);
78
+ // Use provided token directly when available, otherwise fall back to internal token
79
+ // Memoize to ensure React Query sees the change when providedToken updates
80
+ const checkoutToken = useMemo(() => {
81
+ return providedToken !== undefined ? providedToken : internalToken;
73
82
  }, [providedToken, internalToken]);
74
- // Use provided token or internal token
75
- const checkoutToken = providedToken || internalToken;
76
83
  // Main checkout query
77
84
  const { data: checkout, isLoading, error, isSuccess, refetch, } = useQuery({
78
85
  queryKey: ['checkout', checkoutToken, currency.code],
@@ -15,7 +15,6 @@ export function useOrderBumpQuery(options) {
15
15
  checkoutToken: checkoutToken || undefined,
16
16
  enabled: !!checkoutToken,
17
17
  });
18
- console.log('checkout order bump query', checkout);
19
18
  const actualCheckoutToken = checkoutToken || checkout?.checkoutSession?.checkoutToken || null;
20
19
  const checkOrderBumpSelection = useCallback(() => {
21
20
  if (!checkout?.checkoutSession?.sessionLineItems) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagadapay/plugin-sdk",
3
- "version": "2.7.36",
3
+ "version": "2.7.37",
4
4
  "description": "Modern React SDK for building Tagada Pay plugins",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",