@tagadapay/plugin-sdk 2.2.4 → 2.2.6
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.
|
@@ -188,24 +188,51 @@ export interface CheckoutSessionPreview {
|
|
|
188
188
|
totalAdjustedAmount: number;
|
|
189
189
|
totalPromotionAmount: number;
|
|
190
190
|
}
|
|
191
|
+
export interface CheckoutSummaryItem {
|
|
192
|
+
id: string;
|
|
193
|
+
productId: string;
|
|
194
|
+
variantId: string;
|
|
195
|
+
priceId: string;
|
|
196
|
+
product: {
|
|
197
|
+
name: string;
|
|
198
|
+
description: string;
|
|
199
|
+
};
|
|
200
|
+
variant: {
|
|
201
|
+
name: string;
|
|
202
|
+
description: string;
|
|
203
|
+
imageUrl: string;
|
|
204
|
+
grams: number;
|
|
205
|
+
};
|
|
206
|
+
sku: string;
|
|
207
|
+
unitAmount: number;
|
|
208
|
+
quantity: number;
|
|
209
|
+
amount: number;
|
|
210
|
+
adjustedAmount: number;
|
|
211
|
+
currency: string;
|
|
212
|
+
adjustments: any[];
|
|
213
|
+
recurring: boolean;
|
|
214
|
+
interval?: 'day' | 'week' | 'month' | 'year';
|
|
215
|
+
intervalCount?: number;
|
|
216
|
+
totalBillingCycles?: number;
|
|
217
|
+
unitAmountAfterFirstCycle?: number;
|
|
218
|
+
orderLineItemProduct: {
|
|
219
|
+
name: string;
|
|
220
|
+
};
|
|
221
|
+
orderLineItemVariant: {
|
|
222
|
+
name: string;
|
|
223
|
+
imageUrl: string;
|
|
224
|
+
};
|
|
225
|
+
metadata: {
|
|
226
|
+
originalIds: string[];
|
|
227
|
+
isConsolidated: boolean;
|
|
228
|
+
};
|
|
229
|
+
}
|
|
191
230
|
export interface CheckoutSummary {
|
|
192
231
|
currency: string;
|
|
193
232
|
totalAmount: number;
|
|
194
233
|
totalAdjustedAmount: number;
|
|
195
234
|
totalPromotionAmount: number;
|
|
196
|
-
items:
|
|
197
|
-
id: string;
|
|
198
|
-
name: string;
|
|
199
|
-
description: string | null;
|
|
200
|
-
imageUrl: string | null;
|
|
201
|
-
quantity: number;
|
|
202
|
-
unitAmount: number;
|
|
203
|
-
amount: number;
|
|
204
|
-
adjustedAmount: number;
|
|
205
|
-
currency: string;
|
|
206
|
-
isOrderBump: boolean;
|
|
207
|
-
orderBumpType?: string;
|
|
208
|
-
}[];
|
|
235
|
+
items: CheckoutSummaryItem[];
|
|
209
236
|
adjustments: {
|
|
210
237
|
type: string;
|
|
211
238
|
description: string;
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* - Store ID, Account ID, Base Path: from .local.json (dev) or headers (production)
|
|
6
6
|
* - Deployment Config: from config/*.json (dev) or meta tags (production)
|
|
7
7
|
*/
|
|
8
|
-
export interface PluginConfig {
|
|
8
|
+
export interface PluginConfig<TConfig = Record<string, any>> {
|
|
9
9
|
storeId?: string;
|
|
10
10
|
accountId?: string;
|
|
11
11
|
basePath?: string;
|
|
12
|
-
config?:
|
|
12
|
+
config?: TConfig;
|
|
13
13
|
}
|
|
14
14
|
export interface LocalDevConfig {
|
|
15
15
|
storeId: string;
|
|
@@ -25,11 +25,11 @@ export declare const loadPluginConfig: (configVariant?: string) => Promise<Plugi
|
|
|
25
25
|
* Main hook for plugin configuration
|
|
26
26
|
* Gets config from TagadaProvider context (no parameters needed)
|
|
27
27
|
*/
|
|
28
|
-
export declare const usePluginConfig: () => {
|
|
28
|
+
export declare const usePluginConfig: <TConfig = Record<string, any>>() => {
|
|
29
29
|
storeId: string | undefined;
|
|
30
30
|
accountId: string | undefined;
|
|
31
31
|
basePath: string;
|
|
32
|
-
config:
|
|
32
|
+
config: TConfig;
|
|
33
33
|
loading: boolean;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
@@ -77,12 +77,13 @@ localConfig, }) {
|
|
|
77
77
|
console.warn('⚠️ No store ID found in plugin config. This may cause hooks to fail.');
|
|
78
78
|
}
|
|
79
79
|
setPluginConfig(config);
|
|
80
|
-
console.log('✅ Plugin config loaded:', {
|
|
80
|
+
console.log('✅ Phase 1 & 2 Complete - Plugin config loaded:', {
|
|
81
81
|
storeId: config.storeId,
|
|
82
82
|
accountId: config.accountId,
|
|
83
83
|
basePath: config.basePath,
|
|
84
84
|
hasConfig: !!config.config,
|
|
85
85
|
});
|
|
86
|
+
console.log('🚀 Children can now render - Phase 3 (session init) will continue in background');
|
|
86
87
|
}
|
|
87
88
|
catch (error) {
|
|
88
89
|
console.error('❌ Failed to load plugin config in TagadaProvider:', error);
|
|
@@ -298,7 +299,7 @@ localConfig, }) {
|
|
|
298
299
|
if (hasAttemptedAnonymousToken || !targetStoreId) {
|
|
299
300
|
return;
|
|
300
301
|
}
|
|
301
|
-
console.log('[SDK] 🚀 Starting initialization...');
|
|
302
|
+
console.log('[SDK] 🚀 Starting Phase 3 - Session initialization...');
|
|
302
303
|
if (finalDebugMode) {
|
|
303
304
|
console.debug('[SDK][DEBUG] Creating anonymous token for store:', targetStoreId);
|
|
304
305
|
}
|
|
@@ -328,7 +329,7 @@ localConfig, }) {
|
|
|
328
329
|
setIsInitialized(true);
|
|
329
330
|
setIsLoading(false);
|
|
330
331
|
}
|
|
331
|
-
console.log('[SDK] ✅
|
|
332
|
+
console.log('[SDK] ✅ Phase 3 Complete - Session initialization completed successfully');
|
|
332
333
|
}
|
|
333
334
|
catch (error) {
|
|
334
335
|
console.error('[SDK] ❌ Initialization failed:', error);
|
|
@@ -340,6 +341,7 @@ localConfig, }) {
|
|
|
340
341
|
}
|
|
341
342
|
}, [apiService, hasAttemptedAnonymousToken, initializeSession, finalDebugMode]);
|
|
342
343
|
// Initialize token from storage or create anonymous token
|
|
344
|
+
// This runs in the background after phases 1 & 2 complete, but doesn't block rendering
|
|
343
345
|
useEffect(() => {
|
|
344
346
|
if (isInitializing.current) {
|
|
345
347
|
return;
|
|
@@ -508,9 +510,10 @@ localConfig, }) {
|
|
|
508
510
|
refreshCoordinator,
|
|
509
511
|
]);
|
|
510
512
|
// Determine if we should show loading
|
|
511
|
-
//
|
|
512
|
-
|
|
513
|
-
const
|
|
513
|
+
// Phase 1 & 2 are mandatory: config loading and storeId availability
|
|
514
|
+
// Phase 3 (session initialization) is now optional/non-blocking
|
|
515
|
+
const shouldShowLoading = configLoading || (!storeId && configLoading);
|
|
516
|
+
const canRenderChildren = !configLoading && storeId; // Remove isInitialized requirement
|
|
514
517
|
return (_jsxs(TagadaContext.Provider, { value: contextValue, children: [shouldShowLoading && _jsx(InitializationLoader, {}), finalDebugMode && canRenderChildren && (_jsxs(_Fragment, { children: [_jsx("button", { onClick: () => setIsDebugDrawerOpen(true), style: {
|
|
515
518
|
position: 'fixed',
|
|
516
519
|
bottom: '16px',
|