@tagadapay/plugin-sdk 2.4.39 → 2.5.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 (106) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +2 -0
  3. package/dist/react/hooks/useCheckout.js +19 -2
  4. package/dist/react/hooks/useCheckoutSession.d.ts +19 -0
  5. package/dist/react/hooks/useCheckoutSession.js +108 -0
  6. package/dist/react/hooks/useCheckoutToken.d.ts +17 -0
  7. package/dist/react/hooks/useCheckoutToken.js +80 -0
  8. package/dist/react/hooks/useOrderBump.js +92 -13
  9. package/dist/react/hooks/useOrderBumpV2.d.ts +17 -0
  10. package/dist/react/hooks/useOrderBumpV2.js +95 -0
  11. package/dist/react/hooks/useOrderBumpV3.d.ts +23 -0
  12. package/dist/react/hooks/useOrderBumpV3.js +109 -0
  13. package/dist/react/hooks/usePostPurchases.js +11 -5
  14. package/dist/react/index.d.ts +8 -0
  15. package/dist/react/index.js +4 -0
  16. package/dist/react/services/apiService.d.ts +1 -0
  17. package/dist/react/services/apiService.js +3 -0
  18. package/dist/v2/core/googleAutocomplete.d.ts +65 -0
  19. package/dist/v2/core/googleAutocomplete.js +94 -0
  20. package/dist/v2/core/index.d.ts +8 -0
  21. package/dist/v2/core/index.js +11 -0
  22. package/dist/v2/core/isoData.d.ts +50 -0
  23. package/dist/v2/core/isoData.js +103 -0
  24. package/dist/v2/core/resources/apiClient.d.ts +25 -0
  25. package/dist/v2/core/resources/apiClient.js +95 -0
  26. package/dist/v2/core/resources/checkout.d.ts +189 -0
  27. package/dist/v2/core/resources/checkout.js +119 -0
  28. package/dist/v2/core/resources/index.d.ts +13 -0
  29. package/dist/v2/core/resources/index.js +13 -0
  30. package/dist/v2/core/resources/offers.d.ts +98 -0
  31. package/dist/v2/core/resources/offers.js +115 -0
  32. package/dist/v2/core/resources/orders.d.ts +40 -0
  33. package/dist/v2/core/resources/orders.js +59 -0
  34. package/dist/v2/core/resources/payments.d.ts +140 -0
  35. package/dist/v2/core/resources/payments.js +126 -0
  36. package/dist/v2/core/resources/postPurchases.d.ts +182 -0
  37. package/dist/v2/core/resources/postPurchases.js +116 -0
  38. package/dist/v2/core/resources/products.d.ts +29 -0
  39. package/dist/v2/core/resources/products.js +49 -0
  40. package/dist/v2/core/resources/promotions.d.ts +45 -0
  41. package/dist/v2/core/resources/promotions.js +87 -0
  42. package/dist/v2/core/resources/threeds.d.ts +23 -0
  43. package/dist/v2/core/resources/threeds.js +15 -0
  44. package/dist/v2/core/utils/checkout.d.ts +24 -0
  45. package/dist/v2/core/utils/checkout.js +30 -0
  46. package/dist/v2/core/utils/currency.d.ts +28 -0
  47. package/dist/v2/core/utils/currency.js +272 -0
  48. package/dist/v2/core/utils/index.d.ts +12 -0
  49. package/dist/v2/core/utils/index.js +12 -0
  50. package/dist/v2/core/utils/order.d.ts +159 -0
  51. package/dist/v2/core/utils/order.js +42 -0
  52. package/dist/v2/core/utils/orderBump.d.ts +40 -0
  53. package/dist/v2/core/utils/orderBump.js +47 -0
  54. package/dist/v2/core/utils/pluginConfig.d.ts +43 -0
  55. package/dist/v2/core/utils/pluginConfig.js +155 -0
  56. package/dist/v2/core/utils/postPurchases.d.ts +32 -0
  57. package/dist/v2/core/utils/postPurchases.js +42 -0
  58. package/dist/v2/core/utils/products.d.ts +58 -0
  59. package/dist/v2/core/utils/products.js +64 -0
  60. package/dist/v2/core/utils/promotions.d.ts +24 -0
  61. package/dist/v2/core/utils/promotions.js +30 -0
  62. package/dist/v2/index.d.ts +19 -0
  63. package/dist/v2/index.js +15 -0
  64. package/dist/v2/react/components/DebugDrawer.d.ts +7 -0
  65. package/dist/v2/react/components/DebugDrawer.js +383 -0
  66. package/dist/v2/react/hooks/useApiQuery.d.ts +28 -0
  67. package/dist/v2/react/hooks/useApiQuery.js +84 -0
  68. package/dist/v2/react/hooks/useCheckoutQuery.d.ts +39 -0
  69. package/dist/v2/react/hooks/useCheckoutQuery.js +208 -0
  70. package/dist/v2/react/hooks/useCheckoutToken.d.ts +17 -0
  71. package/dist/v2/react/hooks/useCheckoutToken.js +80 -0
  72. package/dist/v2/react/hooks/useCurrency.d.ts +9 -0
  73. package/dist/v2/react/hooks/useCurrency.js +21 -0
  74. package/dist/v2/react/hooks/useGeoLocation.d.ts +138 -0
  75. package/dist/v2/react/hooks/useGeoLocation.js +126 -0
  76. package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +74 -0
  77. package/dist/v2/react/hooks/useGoogleAutocomplete.js +207 -0
  78. package/dist/v2/react/hooks/useISOData.d.ts +61 -0
  79. package/dist/v2/react/hooks/useISOData.js +176 -0
  80. package/dist/v2/react/hooks/useOffersQuery.d.ts +65 -0
  81. package/dist/v2/react/hooks/useOffersQuery.js +353 -0
  82. package/dist/v2/react/hooks/useOrderBumpQuery.d.ts +20 -0
  83. package/dist/v2/react/hooks/useOrderBumpQuery.js +88 -0
  84. package/dist/v2/react/hooks/useOrderQuery.d.ts +29 -0
  85. package/dist/v2/react/hooks/useOrderQuery.js +98 -0
  86. package/dist/v2/react/hooks/usePaymentPolling.d.ts +45 -0
  87. package/dist/v2/react/hooks/usePaymentPolling.js +153 -0
  88. package/dist/v2/react/hooks/usePaymentQuery.d.ts +19 -0
  89. package/dist/v2/react/hooks/usePaymentQuery.js +283 -0
  90. package/dist/v2/react/hooks/usePluginConfig.d.ts +16 -0
  91. package/dist/v2/react/hooks/usePluginConfig.js +36 -0
  92. package/dist/v2/react/hooks/usePostPurchasesQuery.d.ts +63 -0
  93. package/dist/v2/react/hooks/usePostPurchasesQuery.js +365 -0
  94. package/dist/v2/react/hooks/useProductsQuery.d.ts +31 -0
  95. package/dist/v2/react/hooks/useProductsQuery.js +102 -0
  96. package/dist/v2/react/hooks/usePromotionsQuery.d.ts +28 -0
  97. package/dist/v2/react/hooks/usePromotionsQuery.js +97 -0
  98. package/dist/v2/react/hooks/useThreeds.d.ts +36 -0
  99. package/dist/v2/react/hooks/useThreeds.js +166 -0
  100. package/dist/v2/react/hooks/useThreedsModal.d.ts +13 -0
  101. package/dist/v2/react/hooks/useThreedsModal.js +343 -0
  102. package/dist/v2/react/index.d.ts +38 -0
  103. package/dist/v2/react/index.js +27 -0
  104. package/dist/v2/react/providers/TagadaProvider.d.ts +63 -0
  105. package/dist/v2/react/providers/TagadaProvider.js +680 -0
  106. package/package.json +10 -3
@@ -0,0 +1,383 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useState, useEffect } from 'react';
4
+ import { useTagadaContext } from '../providers/TagadaProvider';
5
+ import { usePluginConfig } from '../hooks/usePluginConfig';
6
+ const safeStringify = (value) => {
7
+ if (value === null)
8
+ return 'null';
9
+ if (value === undefined)
10
+ return 'undefined';
11
+ if (typeof value === 'string')
12
+ return value;
13
+ if (typeof value === 'number' || typeof value === 'boolean')
14
+ return String(value);
15
+ try {
16
+ return JSON.stringify(value);
17
+ }
18
+ catch {
19
+ return '[object]';
20
+ }
21
+ };
22
+ const TreeView = ({ data, name, level = 0, maxLevel = 3 }) => {
23
+ const [isExpanded, setIsExpanded] = useState(level < 2);
24
+ if (level > maxLevel) {
25
+ return _jsx("span", { style: { color: '#666' }, children: "..." });
26
+ }
27
+ if (data === null) {
28
+ return _jsx("span", { style: { color: '#f59e0b' }, children: "null" });
29
+ }
30
+ if (data === undefined) {
31
+ return _jsx("span", { style: { color: '#6b7280' }, children: "undefined" });
32
+ }
33
+ if (typeof data === 'string') {
34
+ return _jsxs("span", { style: { color: '#10b981' }, children: ["\"", data, "\""] });
35
+ }
36
+ if (typeof data === 'number') {
37
+ return _jsx("span", { style: { color: '#3b82f6' }, children: data });
38
+ }
39
+ if (typeof data === 'boolean') {
40
+ return _jsx("span", { style: { color: '#8b5cf6' }, children: data.toString() });
41
+ }
42
+ if (Array.isArray(data)) {
43
+ if (data.length === 0) {
44
+ return _jsx("span", { style: { color: '#6b7280' }, children: "[]" });
45
+ }
46
+ return (_jsxs("div", { style: { marginLeft: level > 0 ? '16px' : '0' }, children: [_jsxs("button", { onClick: () => setIsExpanded(!isExpanded), style: {
47
+ background: 'none',
48
+ border: 'none',
49
+ color: '#6b7280',
50
+ cursor: 'pointer',
51
+ padding: '0',
52
+ fontSize: '14px',
53
+ }, children: [isExpanded ? '▼' : '▶', " ", name, " (", data.length, " items)"] }), isExpanded && (_jsxs("div", { style: { marginLeft: '16px' }, children: [data.slice(0, 10).map((item, index) => (_jsx(TreeView, { data: item, name: `[${index}]`, level: level + 1, maxLevel: maxLevel }, index))), data.length > 10 && (_jsxs("div", { style: { color: '#6b7280', fontSize: '12px' }, children: ["... and ", data.length - 10, " more items"] }))] }))] }));
54
+ }
55
+ if (typeof data === 'object' && data !== null) {
56
+ const keys = Object.keys(data);
57
+ if (keys.length === 0) {
58
+ return _jsx("span", { style: { color: '#6b7280' }, children: '{}' });
59
+ }
60
+ return (_jsxs("div", { style: { marginLeft: level > 0 ? '16px' : '0' }, children: [_jsxs("button", { onClick: () => setIsExpanded(!isExpanded), style: {
61
+ background: 'none',
62
+ border: 'none',
63
+ color: '#6b7280',
64
+ cursor: 'pointer',
65
+ padding: '0',
66
+ fontSize: '14px',
67
+ }, children: [isExpanded ? '▼' : '▶', " ", name, " (", keys.length, " properties)"] }), isExpanded && (_jsxs("div", { style: { marginLeft: '16px' }, children: [keys.slice(0, 20).map((key) => (_jsxs("div", { style: { marginBottom: '4px' }, children: [_jsxs("span", { style: { color: '#ef4444', fontWeight: 'bold' }, children: [key, ": "] }), _jsx(TreeView, { data: data[key], name: key, level: level + 1, maxLevel: maxLevel })] }, key))), keys.length > 20 && (_jsxs("div", { style: { color: '#6b7280', fontSize: '12px' }, children: ["... and ", keys.length - 20, " more properties"] }))] }))] }));
68
+ }
69
+ try {
70
+ return _jsx("span", { children: safeStringify(data) });
71
+ }
72
+ catch {
73
+ return _jsx("span", { children: "[object]" });
74
+ }
75
+ };
76
+ export const DebugDrawer = ({ isOpen, onClose }) => {
77
+ const context = useTagadaContext();
78
+ const pluginConfig = usePluginConfig();
79
+ const [activeTab, setActiveTab] = useState('overview');
80
+ useEffect(() => {
81
+ const handleEscape = (e) => {
82
+ if (e.key === 'Escape' && isOpen) {
83
+ onClose();
84
+ }
85
+ };
86
+ document.addEventListener('keydown', handleEscape);
87
+ return () => document.removeEventListener('keydown', handleEscape);
88
+ }, [isOpen, onClose]);
89
+ if (!isOpen)
90
+ return null;
91
+ const baseTabs = [
92
+ { id: 'overview', label: 'Overview' },
93
+ { id: 'config', label: 'Config' },
94
+ { id: 'store', label: 'Store' },
95
+ { id: 'session', label: 'Session' },
96
+ { id: 'auth', label: 'Auth' },
97
+ ];
98
+ // Add checkout tab if checkout is active
99
+ const checkoutTab = context.debugCheckout.isActive ? [{ id: 'checkout', label: 'Checkout' }] : [];
100
+ // Add items tab if checkout has summary data
101
+ const itemsTab = context.debugCheckout.isActive && context.debugCheckout.data?.checkout?.summary
102
+ ? [{ id: 'items', label: 'Items' }]
103
+ : [];
104
+ const tabs = [...baseTabs, ...checkoutTab, ...itemsTab, { id: 'raw', label: 'Raw Data' }];
105
+ return (_jsxs(_Fragment, { children: [_jsx("div", { style: {
106
+ position: 'fixed',
107
+ top: 0,
108
+ left: 0,
109
+ right: 0,
110
+ bottom: 0,
111
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
112
+ zIndex: 999998,
113
+ }, onClick: onClose }), _jsxs("div", { style: {
114
+ position: 'fixed',
115
+ top: 0,
116
+ right: 0,
117
+ bottom: 0,
118
+ width: '50vw',
119
+ minWidth: '500px',
120
+ maxWidth: '800px',
121
+ backgroundColor: '#1f2937',
122
+ color: '#f9fafb',
123
+ boxShadow: '-4px 0 24px rgba(0, 0, 0, 0.3)',
124
+ zIndex: 999999,
125
+ display: 'flex',
126
+ flexDirection: 'column',
127
+ fontSize: '14px',
128
+ fontFamily: 'ui-monospace, SFMono-Regular, Consolas, monospace',
129
+ }, children: [_jsxs("div", { style: {
130
+ padding: '16px',
131
+ borderBottom: '1px solid #374151',
132
+ display: 'flex',
133
+ justifyContent: 'space-between',
134
+ alignItems: 'center',
135
+ backgroundColor: '#111827',
136
+ }, children: [_jsxs("div", { children: [_jsx("h2", { style: { margin: 0, fontSize: '18px', fontWeight: 'bold' }, children: "\uD83D\uDC1B TagadaPay SDK Debug" }), _jsx("p", { style: { margin: '4px 0 0 0', fontSize: '12px', color: '#9ca3af' }, children: "Real-time SDK state and data inspection" })] }), _jsx("button", { onClick: onClose, style: {
137
+ background: 'none',
138
+ border: 'none',
139
+ color: '#9ca3af',
140
+ cursor: 'pointer',
141
+ fontSize: '24px',
142
+ padding: '4px',
143
+ }, children: "\u00D7" })] }), _jsx("div", { style: {
144
+ padding: '0 16px',
145
+ borderBottom: '1px solid #374151',
146
+ backgroundColor: '#111827',
147
+ }, children: _jsx("div", { style: { display: 'flex', gap: '0' }, children: tabs.map((tab) => (_jsx("button", { onClick: () => setActiveTab(tab.id), style: {
148
+ background: 'none',
149
+ border: 'none',
150
+ color: activeTab === tab.id ? '#60a5fa' : '#9ca3af',
151
+ cursor: 'pointer',
152
+ padding: '12px 16px',
153
+ fontSize: '14px',
154
+ borderBottom: activeTab === tab.id ? '2px solid #60a5fa' : '2px solid transparent',
155
+ }, children: tab.label }, tab.id))) }) }), _jsxs("div", { style: {
156
+ flex: 1,
157
+ padding: '16px',
158
+ overflow: 'auto',
159
+ backgroundColor: '#1f2937',
160
+ }, children: [activeTab === 'overview' && (_jsxs("div", { children: [_jsx("h3", { style: { margin: '0 0 16px 0', color: '#60a5fa' }, children: "SDK Overview" }), _jsxs("div", { style: { display: 'grid', gap: '12px' }, children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Initialized:" }), _jsx("span", { style: { color: context.isInitialized ? '#10b981' : '#ef4444' }, children: context.isInitialized ? '✅ Yes' : '❌ No' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Loading:" }), _jsx("span", { style: { color: context.isLoading ? '#f59e0b' : '#10b981' }, children: context.isLoading ? '⏳ Yes' : '✅ No' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Environment:" }), _jsx("span", { style: { color: '#60a5fa' }, children: context.environment.apiConfig.baseUrl.includes('dev') ? 'Development' : 'Production' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "API Base URL:" }), _jsx("span", { style: { color: '#10b981' }, children: context.environment.apiConfig.baseUrl })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Store ID:" }), _jsx("span", { style: { color: '#60a5fa' }, children: context.store?.id || 'Not set' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Customer ID:" }), _jsx("span", { style: { color: '#60a5fa' }, children: context.customer?.id || 'Not set' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Authenticated:" }), _jsx("span", { style: { color: context.auth.isAuthenticated ? '#10b981' : '#ef4444' }, children: context.auth.isAuthenticated ? '✅ Yes' : '❌ No' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Currency:" }), _jsxs("span", { style: { color: '#f59e0b' }, children: [context.currency.code, " (", context.currency.symbol, ")"] })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Locale:" }), _jsx("span", { style: { color: '#8b5cf6' }, children: context.locale.locale })] })] })] })), activeTab === 'config' && (_jsxs("div", { children: [_jsx("h3", { style: { margin: '0 0 16px 0', color: '#60a5fa' }, children: "Plugin Configuration" }), _jsxs("div", { style: { marginBottom: '24px' }, children: [_jsx("h4", { style: { margin: '0 0 12px 0', color: '#9ca3af', fontSize: '14px' }, children: "Configuration Summary" }), _jsxs("div", { style: { display: 'grid', gap: '8px', fontSize: '13px' }, children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Store ID:" }), _jsx("span", { style: { color: '#60a5fa' }, children: pluginConfig.storeId || 'Not set' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Account ID:" }), _jsx("span", { style: { color: '#60a5fa' }, children: pluginConfig.accountId || 'Not set' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Base Path:" }), _jsx("span", { style: { color: '#10b981' }, children: pluginConfig.basePath || '/' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Config Name:" }), _jsx("span", { style: { color: '#f59e0b' }, children: pluginConfig.config?.configName || 'default' })] }), pluginConfig.config?.branding?.primaryColor && (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Primary Color:" }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '8px' }, children: [_jsx("div", { style: {
161
+ width: '16px',
162
+ height: '16px',
163
+ backgroundColor: pluginConfig.config.branding.primaryColor,
164
+ border: '1px solid #374151',
165
+ borderRadius: '3px',
166
+ } }), _jsx("span", { style: { color: '#10b981' }, children: pluginConfig.config.branding.primaryColor })] })] }))] })] }), _jsxs("div", { style: { marginBottom: '16px' }, children: [_jsx("h4", { style: { margin: '0 0 12px 0', color: '#9ca3af', fontSize: '14px' }, children: "Full Configuration" }), _jsx(TreeView, { data: pluginConfig, name: "pluginConfig" })] }), process.env.NODE_ENV === 'development' && (_jsxs("div", { style: {
167
+ padding: '12px',
168
+ backgroundColor: '#1f2937',
169
+ border: '1px solid #374151',
170
+ borderRadius: '6px',
171
+ marginTop: '16px',
172
+ }, children: [_jsx("h4", { style: { margin: '0 0 8px 0', color: '#f59e0b', fontSize: '14px' }, children: "Development Mode" }), _jsxs("p", { style: { margin: '0', fontSize: '12px', color: '#9ca3af', lineHeight: '1.4' }, children: ["Configuration is loaded from ", _jsx("code", { style: { color: '#60a5fa' }, children: "/.local.json" }), " and", ' ', _jsxs("code", { style: { color: '#60a5fa' }, children: ["/config/", pluginConfig.config?.configName || 'default', ".tgd.json"] })] }), _jsxs("p", { style: { margin: '8px 0 0 0', fontSize: '12px', color: '#9ca3af', lineHeight: '1.4' }, children: ["Local config variant:", ' ', _jsx("code", { style: { color: '#f59e0b' }, children: pluginConfig.config?.configName || 'default' })] })] }))] })), activeTab === 'store' && (_jsxs("div", { children: [_jsx("h3", { style: { margin: '0 0 16px 0', color: '#60a5fa' }, children: "Store Configuration" }), context.store ? (_jsx(TreeView, { data: context.store, name: "store" })) : (_jsx("p", { style: { color: '#6b7280' }, children: "No store data available" }))] })), activeTab === 'session' && (_jsxs("div", { children: [_jsx("h3", { style: { margin: '0 0 16px 0', color: '#60a5fa' }, children: "Session Data" }), context.session ? (_jsx(TreeView, { data: context.session, name: "session" })) : (_jsx("p", { style: { color: '#6b7280' }, children: "No session data available" }))] })), activeTab === 'auth' && (_jsxs("div", { children: [_jsx("h3", { style: { margin: '0 0 16px 0', color: '#60a5fa' }, children: "Authentication State" }), _jsx(TreeView, { data: context.auth, name: "auth" }), context.customer && (_jsxs(_Fragment, { children: [_jsx("h4", { style: { margin: '24px 0 12px 0', color: '#60a5fa' }, children: "Customer Data" }), _jsx(TreeView, { data: context.customer, name: "customer" })] }))] })), activeTab === 'items' && (_jsxs("div", { children: [_jsx("h3", { style: { margin: '0 0 16px 0', color: '#60a5fa' }, children: "Items & Discounts" }), context.debugCheckout.data?.checkout?.summary ? (_jsxs("div", { children: [_jsxs("div", { style: { marginBottom: '24px' }, children: [_jsx("h4", { style: { margin: '0 0 12px 0', color: '#60a5fa' }, children: "Summary" }), _jsxs("div", { style: { display: 'grid', gap: '8px' }, children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Currency:" }), _jsx("span", { style: { color: '#f59e0b' }, children: context.debugCheckout.data.checkout.summary.currency })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Subtotal:" }), _jsx("span", { style: { color: '#9ca3af' }, children: (() => {
173
+ try {
174
+ return context.money.formatMoney(Number(context.debugCheckout.data.checkout.summary.subtotalAmount) || 0, String(context.debugCheckout.data.checkout.summary.currency) || 'USD', context.locale.locale);
175
+ }
176
+ catch {
177
+ return String(context.debugCheckout.data.checkout.summary.subtotalAmount);
178
+ }
179
+ })() })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Total Promotions:" }), _jsx("span", { style: { color: '#ef4444' }, children: (() => {
180
+ try {
181
+ return `-${context.money.formatMoney(Number(context.debugCheckout.data.checkout.summary.totalPromotionAmount) || 0, String(context.debugCheckout.data.checkout.summary.currency) || 'USD', context.locale.locale)}`;
182
+ }
183
+ catch {
184
+ return `-${String(context.debugCheckout.data.checkout.summary.totalPromotionAmount)}`;
185
+ }
186
+ })() })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Total Adjusted:" }), _jsx("span", { style: { color: '#10b981', fontWeight: 'bold' }, children: (() => {
187
+ try {
188
+ return context.money.formatMoney(Number(context.debugCheckout.data.checkout.summary.totalAdjustedAmount) || 0, String(context.debugCheckout.data.checkout.summary.currency) || 'USD', context.locale.locale);
189
+ }
190
+ catch {
191
+ return String(context.debugCheckout.data.checkout.summary.totalAdjustedAmount);
192
+ }
193
+ })() })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Shipping:" }), _jsx("span", { style: { color: '#9ca3af' }, children: (() => {
194
+ try {
195
+ const shipping = Number(context.debugCheckout.data.checkout.summary.shippingCost) || 0;
196
+ return shipping === 0
197
+ ? 'FREE'
198
+ : context.money.formatMoney(shipping, String(context.debugCheckout.data.checkout.summary.currency) || 'USD', context.locale.locale);
199
+ }
200
+ catch {
201
+ return String(context.debugCheckout.data.checkout.summary.shippingCost);
202
+ }
203
+ })() })] })] })] }), _jsxs("div", { style: { marginBottom: '24px' }, children: [_jsxs("h4", { style: { margin: '0 0 12px 0', color: '#60a5fa' }, children: ["Line Items (", context.debugCheckout.data.checkout.summary.items.length, ")"] }), _jsx("div", { style: { display: 'grid', gap: '16px' }, children: context.debugCheckout.data.checkout.summary.items.map((item, index) => (_jsx("div", { style: {
204
+ border: '1px solid #374151',
205
+ borderRadius: '8px',
206
+ padding: '12px',
207
+ backgroundColor: '#111827',
208
+ }, children: _jsxs("div", { style: { display: 'flex', gap: '12px', alignItems: 'flex-start' }, children: [(() => {
209
+ const imageUrl = item.variant?.imageUrl ||
210
+ item.orderLineItemVariant?.imageUrl ||
211
+ item.imageUrl ||
212
+ item.product?.image?.src ||
213
+ item.product?.images?.[0]?.src;
214
+ return imageUrl ? (_jsx("img", { src: imageUrl, alt: item.product?.name ||
215
+ item.orderLineItemProduct?.name ||
216
+ item.name ||
217
+ 'Product', style: {
218
+ width: '60px',
219
+ height: '60px',
220
+ objectFit: 'cover',
221
+ borderRadius: '4px',
222
+ backgroundColor: '#374151',
223
+ }, onError: (e) => {
224
+ e.target.style.display = 'none';
225
+ } })) : (_jsx("div", { style: {
226
+ width: '60px',
227
+ height: '60px',
228
+ backgroundColor: '#374151',
229
+ borderRadius: '4px',
230
+ display: 'flex',
231
+ alignItems: 'center',
232
+ justifyContent: 'center',
233
+ fontSize: '24px',
234
+ color: '#9ca3af',
235
+ }, children: "\uD83D\uDCE6" }));
236
+ })(), _jsxs("div", { style: { flex: 1 }, children: [_jsxs("div", { style: { marginBottom: '8px' }, children: [_jsxs("h5", { style: {
237
+ margin: '0 0 4px 0',
238
+ color: '#f9fafb',
239
+ fontSize: '14px',
240
+ fontWeight: 'bold',
241
+ }, children: [item.product?.name ||
242
+ item.orderLineItemProduct?.name ||
243
+ item.name ||
244
+ 'Unknown Product', item.isOrderBump && (_jsx("span", { style: {
245
+ marginLeft: '8px',
246
+ fontSize: '11px',
247
+ backgroundColor: '#f59e0b',
248
+ color: '#000',
249
+ padding: '2px 6px',
250
+ borderRadius: '4px',
251
+ }, children: "ORDER BUMP" }))] }), (item.variant?.name || item.orderLineItemVariant?.name) && (_jsxs("p", { style: { margin: '0 0 4px 0', fontSize: '12px', color: '#9ca3af' }, children: ["Variant: ", item.variant?.name || item.orderLineItemVariant?.name] })), (item.product?.description || item.description) && (_jsx("p", { style: { margin: '0', fontSize: '11px', color: '#6b7280' }, children: (() => {
252
+ const desc = item.product?.description || item.description;
253
+ // Strip HTML tags for display
254
+ const cleaned = desc.replace(/<[^>]*>/g, '');
255
+ return cleaned.length > 100
256
+ ? cleaned.substring(0, 100) + '...'
257
+ : cleaned;
258
+ })() }))] }), _jsxs("div", { style: {
259
+ display: 'grid',
260
+ gridTemplateColumns: '1fr 1fr',
261
+ gap: '8px',
262
+ fontSize: '12px',
263
+ marginBottom: '8px',
264
+ }, children: [_jsxs("div", { children: [_jsx("span", { style: { color: '#9ca3af' }, children: "Quantity: " }), _jsx("span", { style: { color: '#60a5fa', fontWeight: 'bold' }, children: item.quantity })] }), _jsxs("div", { children: [_jsx("span", { style: { color: '#9ca3af' }, children: "Unit Price: " }), _jsx("span", { style: { color: '#f9fafb' }, children: (() => {
265
+ try {
266
+ return context.money.formatMoney(Number(item.unitAmount) || 0, String(context.debugCheckout.data.checkout.summary.currency) ||
267
+ 'USD', context.locale.locale);
268
+ }
269
+ catch {
270
+ return String(item.unitAmount);
271
+ }
272
+ })() })] }), _jsxs("div", { children: [_jsx("span", { style: { color: '#9ca3af' }, children: "Original: " }), _jsx("span", { style: {
273
+ color: item.amount !== item.adjustedAmount ? '#9ca3af' : '#f9fafb',
274
+ textDecoration: item.amount !== item.adjustedAmount ? 'line-through' : 'none',
275
+ }, children: (() => {
276
+ try {
277
+ return context.money.formatMoney(Number(item.amount) || 0, String(context.debugCheckout.data.checkout.summary.currency) ||
278
+ 'USD', context.locale.locale);
279
+ }
280
+ catch {
281
+ return String(item.amount);
282
+ }
283
+ })() })] }), _jsxs("div", { children: [_jsx("span", { style: { color: '#9ca3af' }, children: "Final: " }), _jsx("span", { style: { color: '#10b981', fontWeight: 'bold' }, children: (() => {
284
+ try {
285
+ return context.money.formatMoney(Number(item.adjustedAmount) || 0, String(context.debugCheckout.data.checkout.summary.currency) ||
286
+ 'USD', context.locale.locale);
287
+ }
288
+ catch {
289
+ return String(item.adjustedAmount);
290
+ }
291
+ })() }), item.amount !== item.adjustedAmount && (_jsxs("span", { style: { color: '#ef4444', marginLeft: '4px' }, children: ["(", (() => {
292
+ try {
293
+ const discount = Number(item.amount) - Number(item.adjustedAmount);
294
+ return `-${context.money.formatMoney(discount, String(context.debugCheckout.data.checkout.summary.currency) ||
295
+ 'USD', context.locale.locale)}`;
296
+ }
297
+ catch {
298
+ return `-${item.amount - item.adjustedAmount}`;
299
+ }
300
+ })(), ")"] }))] })] }), item.adjustments && item.adjustments.length > 0 && (_jsxs("div", { style: {
301
+ backgroundColor: '#065f46',
302
+ padding: '8px',
303
+ borderRadius: '4px',
304
+ marginTop: '8px',
305
+ }, children: [_jsx("div", { style: {
306
+ fontSize: '11px',
307
+ fontWeight: 'bold',
308
+ marginBottom: '4px',
309
+ color: '#6ee7b7',
310
+ }, children: "\uD83D\uDCB0 Item Promotions Applied:" }), item.adjustments.map((adjustment, adjIndex) => (_jsxs("div", { style: { fontSize: '10px', marginBottom: '2px' }, children: [_jsx("div", { style: { color: '#6ee7b7', fontWeight: 'bold' }, children: adjustment.description }), _jsxs("div", { style: { color: '#a7f3d0' }, children: ["Amount:", ' ', (() => {
311
+ try {
312
+ return context.money.formatMoney(Math.abs(Number(adjustment.amount) || 0), String(adjustment.currency) ||
313
+ String(context.debugCheckout.data.checkout.summary.currency) ||
314
+ 'USD', context.locale.locale);
315
+ }
316
+ catch {
317
+ return String(Math.abs(Number(adjustment.amount) || 0));
318
+ }
319
+ })(), ' ', "\u2022 Type: ", adjustment.type, " \u2022 Level: ", adjustment.level, adjustment.sourceId && ` • ID: ${adjustment.sourceId}`] })] }, adjIndex)))] })), _jsxs("div", { style: { fontSize: '9px', color: '#6b7280', marginTop: '8px' }, children: ["Product ID: ", item.productId, " \u2022 Variant ID: ", item.variantId, " \u2022 Price ID:", ' ', item.priceId] })] })] }) }, item.id || index))) })] }), context.debugCheckout.data?.availablePromotions &&
320
+ context.debugCheckout.data.availablePromotions.length > 0 && (_jsxs("div", { style: { marginBottom: '24px' }, children: [_jsxs("h4", { style: { margin: '0 0 12px 0', color: '#60a5fa' }, children: ["Available Promotions (", context.debugCheckout.data.availablePromotions.length, ")"] }), _jsx("div", { style: { display: 'grid', gap: '12px' }, children: context.debugCheckout.data.availablePromotions.map((promotion, index) => (_jsxs("div", { style: {
321
+ border: '1px solid #374151',
322
+ borderRadius: '6px',
323
+ padding: '12px',
324
+ backgroundColor: '#111827',
325
+ }, children: [_jsxs("div", { style: { marginBottom: '8px' }, children: [_jsxs("div", { style: { color: '#f9fafb', fontWeight: 'bold', marginBottom: '4px' }, children: [promotion.name, promotion.automatic && (_jsx("span", { style: {
326
+ marginLeft: '8px',
327
+ fontSize: '10px',
328
+ backgroundColor: '#10b981',
329
+ color: '#000',
330
+ padding: '2px 6px',
331
+ borderRadius: '4px',
332
+ }, children: "AUTO" })), promotion.enabled && (_jsx("span", { style: {
333
+ marginLeft: '8px',
334
+ fontSize: '10px',
335
+ backgroundColor: '#3b82f6',
336
+ color: '#fff',
337
+ padding: '2px 6px',
338
+ borderRadius: '4px',
339
+ }, children: "ACTIVE" }))] }), _jsxs("div", { style: { fontSize: '11px', color: '#9ca3af' }, children: ["ID: ", promotion.id, " \u2022 Usage: ", promotion.usageCount || 0, promotion.usageLimit && ` / ${promotion.usageLimit}`] })] }), promotion.rules && promotion.rules.length > 0 && (_jsxs("div", { style: { marginBottom: '8px' }, children: [_jsx("div", { style: {
340
+ fontSize: '10px',
341
+ color: '#60a5fa',
342
+ fontWeight: 'bold',
343
+ marginBottom: '4px',
344
+ }, children: "Rules:" }), promotion.rules.map((rule, ruleIndex) => (_jsxs("div", { style: { fontSize: '9px', color: '#d1d5db', marginBottom: '2px' }, children: ["\u2022 ", rule.type, " ", rule.productId && `(Product: ${rule.productId})`, rule.minimumQuantity && ` - Min Qty: ${rule.minimumQuantity}`, rule.minimumAmount && ` - Min Amount: ${rule.minimumAmount}`, rule.variantIds &&
345
+ rule.variantIds.length > 0 &&
346
+ ` - Variants: ${rule.variantIds.length}`] }, ruleIndex)))] })), promotion.actions && promotion.actions.length > 0 && (_jsxs("div", { children: [_jsx("div", { style: {
347
+ fontSize: '10px',
348
+ color: '#10b981',
349
+ fontWeight: 'bold',
350
+ marginBottom: '4px',
351
+ }, children: "Actions:" }), promotion.actions.map((action, actionIndex) => (_jsxs("div", { style: { fontSize: '9px', color: '#d1d5db', marginBottom: '2px' }, children: ["\u2022 ", action.type, action.adjustmentPercentage &&
352
+ ` - ${action.adjustmentPercentage}% off`, action.adjustmentAmount && ` - ${action.adjustmentAmount} off`, action.freeShipping && ` - Free Shipping`, action.targetProductId && ` - Target: ${action.targetProductId}`, action.maxQuantityDiscounted &&
353
+ ` - Max Qty: ${action.maxQuantityDiscounted}`] }, actionIndex)))] }))] }, promotion.id || index))) })] })), context.debugCheckout.data.checkout.summary.adjustments &&
354
+ context.debugCheckout.data.checkout.summary.adjustments.length > 0 && (_jsxs("div", { style: { marginBottom: '24px' }, children: [_jsxs("h4", { style: { margin: '0 0 12px 0', color: '#60a5fa' }, children: ["Order Level Discounts (", context.debugCheckout.data.checkout.summary.adjustments.length, ")"] }), _jsx("div", { style: { display: 'grid', gap: '8px' }, children: context.debugCheckout.data.checkout.summary.adjustments.map((adjustment, index) => (_jsxs("div", { style: {
355
+ border: '1px solid #374151',
356
+ borderRadius: '6px',
357
+ padding: '10px',
358
+ backgroundColor: '#111827',
359
+ display: 'flex',
360
+ justifyContent: 'space-between',
361
+ alignItems: 'center',
362
+ }, children: [_jsxs("div", { children: [_jsx("div", { style: { color: '#f9fafb', fontWeight: 'bold', marginBottom: '2px' }, children: adjustment.description }), _jsxs("div", { style: { fontSize: '11px', color: '#9ca3af' }, children: [adjustment.type, " \u2022 Level: ", adjustment.level, adjustment.sourceId && ` • ID: ${adjustment.sourceId}`] })] }), _jsx("div", { style: { color: '#ef4444', fontWeight: 'bold' }, children: (() => {
363
+ try {
364
+ return context.money.formatMoney(Math.abs(Number(adjustment.amount)) || 0, String(adjustment.currency) ||
365
+ String(context.debugCheckout.data.checkout.summary.currency) ||
366
+ 'USD', context.locale.locale);
367
+ }
368
+ catch {
369
+ return String(Math.abs(Number(adjustment.amount)));
370
+ }
371
+ })() })] }, index))) })] }))] })) : (_jsx("p", { style: { color: '#6b7280' }, children: "No checkout summary data available" }))] })), activeTab === 'checkout' && (_jsxs("div", { children: [_jsx("h3", { style: { margin: '0 0 16px 0', color: '#60a5fa' }, children: "Checkout Debug" }), context.debugCheckout.isActive ? (_jsxs("div", { children: [_jsxs("div", { style: { marginBottom: '20px' }, children: [_jsx("h4", { style: { margin: '0 0 12px 0', color: '#60a5fa' }, children: "Status" }), _jsxs("div", { style: { display: 'grid', gap: '8px' }, children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Hook Active:" }), _jsx("span", { style: { color: '#10b981' }, children: "\u2705 Yes" })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Loading:" }), _jsx("span", { style: { color: context.debugCheckout.isLoading ? '#f59e0b' : '#10b981' }, children: context.debugCheckout.isLoading ? '⏳ Yes' : '✅ No' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Has Error:" }), _jsx("span", { style: { color: context.debugCheckout.error ? '#ef4444' : '#10b981' }, children: context.debugCheckout.error ? '❌ Yes' : '✅ No' })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx("span", { children: "Last Updated:" }), _jsx("span", { style: { color: '#9ca3af', fontSize: '12px' }, children: context.debugCheckout.lastUpdated?.toLocaleTimeString() || 'Never' })] })] })] }), context.debugCheckout.error && (_jsxs("div", { style: { marginBottom: '20px' }, children: [_jsx("h4", { style: { margin: '0 0 12px 0', color: '#ef4444' }, children: "Error Details" }), _jsxs("div", { style: {
372
+ backgroundColor: '#372c2c',
373
+ padding: '12px',
374
+ borderRadius: '4px',
375
+ border: '1px solid #ef4444',
376
+ }, children: [_jsxs("div", { style: { color: '#ef4444', fontWeight: 'bold', marginBottom: '8px' }, children: [context.debugCheckout.error.name, ": ", context.debugCheckout.error.message] }), context.debugCheckout.error.stack && (_jsx("pre", { style: {
377
+ color: '#9ca3af',
378
+ fontSize: '11px',
379
+ margin: 0,
380
+ whiteSpace: 'pre-wrap',
381
+ }, children: context.debugCheckout.error.stack }))] })] })), _jsxs("div", { children: [_jsx("h4", { style: { margin: '0 0 12px 0', color: '#60a5fa' }, children: "Full Checkout Data" }), _jsx(TreeView, { data: context.debugCheckout.data, name: "checkoutData" })] })] })) : (_jsx("p", { style: { color: '#6b7280' }, children: "No checkout hook active" }))] })), activeTab === 'raw' && (_jsxs("div", { children: [_jsx("h3", { style: { margin: '0 0 16px 0', color: '#60a5fa' }, children: "Raw Context Data" }), _jsx("div", { style: { fontSize: '12px' }, children: _jsx(TreeView, { data: context, name: "tagadaContext", maxLevel: 4 }) })] }))] })] })] }));
382
+ };
383
+ export default DebugDrawer;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * API Query Hook using TanStack Query + Axios
3
+ * Facade pattern for React SDK
4
+ */
5
+ import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
6
+ import { ApiClient } from '../../core/resources/apiClient';
7
+ export declare function setGlobalApiClient(client: ApiClient): void;
8
+ export declare function getGlobalApiClient(): ApiClient;
9
+ export declare function getGlobalApiClientOrNull(): ApiClient | null;
10
+ export declare const queryKeys: {
11
+ readonly checkout: (token: string, currency?: string) => (string | undefined)[];
12
+ readonly promotions: (sessionId: string) => string[];
13
+ readonly orderBumps: (sessionId: string) => string[];
14
+ readonly products: (productIds: string[], options?: Record<string, any>) => (string | string[] | Record<string, any> | undefined)[];
15
+ readonly store: (storeId: string) => string[];
16
+ readonly order: (orderId: string) => string[];
17
+ };
18
+ export declare function useApiQuery<T = unknown>(key: readonly unknown[], url: string | null, options?: Omit<UseQueryOptions<T>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<import("@tanstack/react-query").NoInfer<T>, Error>;
19
+ export declare function useApiMutation<TData = unknown, TVariables = unknown>(mutationFn: (variables: TVariables) => Promise<TData>, options?: UseMutationOptions<TData, Error, TVariables>): import("@tanstack/react-query").UseMutationResult<TData, Error, TVariables, unknown>;
20
+ export declare function useInvalidateQuery(): {
21
+ invalidateCheckout: (token: string) => void;
22
+ invalidatePromotions: (sessionId: string) => void;
23
+ invalidateOrderBumps: (sessionId: string) => void;
24
+ invalidateAll: () => void;
25
+ };
26
+ export declare function usePreloadQuery(): {
27
+ preloadCheckout: (token: string, currency?: string) => void;
28
+ };
@@ -0,0 +1,84 @@
1
+ /**
2
+ * API Query Hook using TanStack Query + Axios
3
+ * Facade pattern for React SDK
4
+ */
5
+ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
6
+ // Global API client instance
7
+ let globalApiClient = null;
8
+ export function setGlobalApiClient(client) {
9
+ globalApiClient = client;
10
+ }
11
+ export function getGlobalApiClient() {
12
+ if (!globalApiClient) {
13
+ throw new Error('API client not initialized. Make sure TagadaProvider is wrapping your app.');
14
+ }
15
+ return globalApiClient;
16
+ }
17
+ export function getGlobalApiClientOrNull() {
18
+ return globalApiClient;
19
+ }
20
+ // Query key builders for consistency
21
+ export const queryKeys = {
22
+ checkout: (token, currency) => ['checkout', token, currency].filter(Boolean),
23
+ promotions: (sessionId) => ['promotions', sessionId],
24
+ orderBumps: (sessionId) => ['order-bumps', sessionId],
25
+ products: (productIds, options) => ['products', productIds, options],
26
+ store: (storeId) => ['store', storeId],
27
+ order: (orderId) => ['order', orderId],
28
+ };
29
+ // Main query hook
30
+ export function useApiQuery(key, url, options) {
31
+ const client = getGlobalApiClient();
32
+ return useQuery({
33
+ queryKey: key,
34
+ queryFn: async () => {
35
+ if (!url)
36
+ throw new Error('URL is required');
37
+ return client.get(url);
38
+ },
39
+ enabled: !!url && (options?.enabled !== false),
40
+ staleTime: 30000, // 30 seconds
41
+ gcTime: 5 * 60 * 1000, // 5 minutes (was cacheTime in v4)
42
+ ...options,
43
+ });
44
+ }
45
+ // Mutation hook
46
+ export function useApiMutation(mutationFn, options) {
47
+ return useMutation({
48
+ mutationFn,
49
+ ...options,
50
+ });
51
+ }
52
+ // Convenience hooks for common operations
53
+ export function useInvalidateQuery() {
54
+ const queryClient = useQueryClient();
55
+ return {
56
+ invalidateCheckout: (token) => {
57
+ void queryClient.invalidateQueries({ queryKey: queryKeys.checkout(token) });
58
+ },
59
+ invalidatePromotions: (sessionId) => {
60
+ void queryClient.invalidateQueries({ queryKey: queryKeys.promotions(sessionId) });
61
+ },
62
+ invalidateOrderBumps: (sessionId) => {
63
+ void queryClient.invalidateQueries({ queryKey: queryKeys.orderBumps(sessionId) });
64
+ },
65
+ invalidateAll: () => {
66
+ void queryClient.invalidateQueries();
67
+ },
68
+ };
69
+ }
70
+ // Preload function for optimistic loading
71
+ export function usePreloadQuery() {
72
+ const queryClient = useQueryClient();
73
+ const client = getGlobalApiClient();
74
+ return {
75
+ preloadCheckout: (token, currency) => {
76
+ const url = `/api/v1/checkout-sessions/${token}/v2${currency ? `?currency=${currency}` : ''}`;
77
+ void queryClient.prefetchQuery({
78
+ queryKey: queryKeys.checkout(token, currency),
79
+ queryFn: () => client.get(url),
80
+ staleTime: 30000,
81
+ });
82
+ },
83
+ };
84
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Checkout Hook using TanStack Query
3
+ * Replaces the coordinator pattern with automatic cache invalidation
4
+ */
5
+ import { CheckoutData, CheckoutInitParams, CheckoutLineItem } from '../../core/resources/checkout';
6
+ export interface UseCheckoutQueryOptions {
7
+ checkoutToken?: string;
8
+ enabled?: boolean;
9
+ }
10
+ export interface UseCheckoutQueryResult {
11
+ checkout: CheckoutData | undefined;
12
+ isLoading: boolean;
13
+ error: Error | null;
14
+ isSuccess: boolean;
15
+ init: (params: CheckoutInitParams) => Promise<{
16
+ checkoutUrl: string;
17
+ checkoutSession: any;
18
+ checkoutToken: string;
19
+ }>;
20
+ refresh: () => Promise<void>;
21
+ updateLineItems: (lineItems: CheckoutLineItem[]) => Promise<any>;
22
+ setItemQuantity: (variantId: string, quantity: number, priceId?: string) => Promise<any>;
23
+ updateCustomer: (data: {
24
+ email: string;
25
+ acceptsMarketing?: boolean;
26
+ }) => Promise<any>;
27
+ updateCustomerAndSessionInfo: (data: {
28
+ customerData: {
29
+ email: string;
30
+ acceptsMarketing?: boolean;
31
+ };
32
+ shippingAddress: any;
33
+ billingAddress?: any;
34
+ differentBillingAddress?: boolean;
35
+ }) => Promise<any>;
36
+ applyPromotionCode: (code: string) => Promise<any>;
37
+ removePromotion: (promotionId: string) => Promise<any>;
38
+ }
39
+ export declare function useCheckoutQuery(options?: UseCheckoutQueryOptions): UseCheckoutQueryResult;