@tagadapay/plugin-sdk 2.8.0 → 2.8.1
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.
|
@@ -38,11 +38,11 @@ const InitializationLoader = () => (_jsxs("div", { style: {
|
|
|
38
38
|
borderTop: '1.5px solid #9ca3af',
|
|
39
39
|
borderRadius: '50%',
|
|
40
40
|
animation: 'tagada-spin 1s linear infinite',
|
|
41
|
-
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
42
|
-
@keyframes tagada-spin {
|
|
43
|
-
0% { transform: rotate(0deg); }
|
|
44
|
-
100% { transform: rotate(360deg); }
|
|
45
|
-
}
|
|
41
|
+
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
42
|
+
@keyframes tagada-spin {
|
|
43
|
+
0% { transform: rotate(0deg); }
|
|
44
|
+
100% { transform: rotate(360deg); }
|
|
45
|
+
}
|
|
46
46
|
` })] }));
|
|
47
47
|
const TagadaContext = createContext(null);
|
|
48
48
|
export function TagadaProvider({ children, environment, customApiConfig, debugMode, // Remove default, will be set based on environment
|
|
@@ -9,7 +9,7 @@ export interface UsePostPurchasesQueryOptions {
|
|
|
9
9
|
autoInitializeCheckout?: boolean;
|
|
10
10
|
}
|
|
11
11
|
export interface UsePostPurchasesQueryResult {
|
|
12
|
-
offers: PostPurchaseOffer[];
|
|
12
|
+
offers: PostPurchaseOffer[] | undefined;
|
|
13
13
|
isLoading: boolean;
|
|
14
14
|
error: Error | null;
|
|
15
15
|
acceptOffer: (offerId: string, items: PostPurchaseOfferItem[]) => Promise<{
|
|
@@ -165,7 +165,7 @@ export function usePostPurchasesQuery(options) {
|
|
|
165
165
|
}
|
|
166
166
|
}, [session?.customerId, orderId, postPurchasesResource, fetchOrderSummary]);
|
|
167
167
|
// Main post-purchase offers query
|
|
168
|
-
const { data: offers =
|
|
168
|
+
const { data: offers = undefined, isLoading, error, refetch, } = useQuery({
|
|
169
169
|
queryKey: ['post-purchase-offers', orderId],
|
|
170
170
|
queryFn: async () => {
|
|
171
171
|
// Double-check token is available before making the request
|
|
@@ -193,7 +193,7 @@ export function usePostPurchasesQuery(options) {
|
|
|
193
193
|
});
|
|
194
194
|
// Auto-initialize checkout sessions if enabled
|
|
195
195
|
useEffect(() => {
|
|
196
|
-
if (autoInitializeCheckout && offers.length > 0 && session?.customerId && isSessionInitialized) {
|
|
196
|
+
if (autoInitializeCheckout && offers && offers.length > 0 && session?.customerId && isSessionInitialized) {
|
|
197
197
|
// Initialize checkout sessions for all offers
|
|
198
198
|
offers.forEach((offer) => {
|
|
199
199
|
// The initializeOfferCheckout function will check if already initialized or initializing
|
|
@@ -293,21 +293,21 @@ export function usePostPurchasesQuery(options) {
|
|
|
293
293
|
return await postPurchasesResource.initCheckoutSessionWithVariants(offerId, orderId, lineItems);
|
|
294
294
|
},
|
|
295
295
|
getOffer: (offerId) => {
|
|
296
|
-
return offers
|
|
296
|
+
return offers?.find(offer => offer.id === offerId);
|
|
297
297
|
},
|
|
298
298
|
getTotalValue: () => {
|
|
299
|
-
return offers
|
|
299
|
+
return offers?.reduce((total, offer) => {
|
|
300
300
|
return total + offer.summaries.reduce((summaryTotal, summary) => {
|
|
301
301
|
return summaryTotal + summary.totalAmount;
|
|
302
302
|
}, 0);
|
|
303
|
-
}, 0);
|
|
303
|
+
}, 0) ?? 0;
|
|
304
304
|
},
|
|
305
305
|
getTotalSavings: () => {
|
|
306
|
-
return offers
|
|
306
|
+
return offers?.reduce((total, offer) => {
|
|
307
307
|
return total + offer.summaries.reduce((summaryTotal, summary) => {
|
|
308
308
|
return summaryTotal + (summary.totalAmount - summary.totalAdjustedAmount);
|
|
309
309
|
}, 0);
|
|
310
|
-
}, 0);
|
|
310
|
+
}, 0) ?? 0;
|
|
311
311
|
},
|
|
312
312
|
// Checkout session management - exact same as V1
|
|
313
313
|
getCheckoutSessionState: (offerId) => {
|
|
@@ -42,11 +42,11 @@ const InitializationLoader = () => (_jsxs("div", { style: {
|
|
|
42
42
|
borderTop: '1.5px solid #9ca3af',
|
|
43
43
|
borderRadius: '50%',
|
|
44
44
|
animation: 'tagada-spin 1s linear infinite',
|
|
45
|
-
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
46
|
-
@keyframes tagada-spin {
|
|
47
|
-
0% { transform: rotate(0deg); }
|
|
48
|
-
100% { transform: rotate(360deg); }
|
|
49
|
-
}
|
|
45
|
+
} }), _jsx("span", { children: "Loading..." }), _jsx("style", { children: `
|
|
46
|
+
@keyframes tagada-spin {
|
|
47
|
+
0% { transform: rotate(0deg); }
|
|
48
|
+
100% { transform: rotate(360deg); }
|
|
49
|
+
}
|
|
50
50
|
` })] }));
|
|
51
51
|
const isEnvironment = (value) => value === 'production' || value === 'development' || value === 'local';
|
|
52
52
|
const resolveEnvironmentFromVariables = () => {
|
package/package.json
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tagadapay/plugin-sdk",
|
|
3
|
-
"version": "2.8.
|
|
4
|
-
"description": "Modern React SDK for building Tagada Pay plugins",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"require": "./dist/index.js"
|
|
12
|
-
},
|
|
13
|
-
"./react": {
|
|
14
|
-
"types": "./dist/react/index.d.ts",
|
|
15
|
-
"import": "./dist/react/index.js",
|
|
16
|
-
"require": "./dist/react/index.js"
|
|
17
|
-
},
|
|
18
|
-
"./v2": {
|
|
19
|
-
"types": "./dist/v2/index.d.ts",
|
|
20
|
-
"import": "./dist/v2/index.js",
|
|
21
|
-
"require": "./dist/v2/index.js"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "tsc",
|
|
26
|
-
"clean": "rm -rf dist",
|
|
27
|
-
"lint": "echo \"No linting configured\"",
|
|
28
|
-
"test": "jest --no-watchman",
|
|
29
|
-
"test:watch": "jest --watch --no-watchman",
|
|
30
|
-
"test:coverage": "jest --coverage --no-watchman",
|
|
31
|
-
"dev": "tsc --watch",
|
|
32
|
-
"prepublishOnly": "npm run clean && npm run build",
|
|
33
|
-
"publish:patch": "npm version patch && npm publish",
|
|
34
|
-
"publish:minor": "npm version minor && npm publish",
|
|
35
|
-
"publish:major": "npm version major && npm publish",
|
|
36
|
-
"publish:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
|
|
37
|
-
"publish:alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
|
|
38
|
-
"version:patch": "npm version patch",
|
|
39
|
-
"version:minor": "npm version minor",
|
|
40
|
-
"version:major": "npm version major",
|
|
41
|
-
"version:beta": "npm version prerelease --preid=beta",
|
|
42
|
-
"version:alpha": "npm version prerelease --preid=alpha",
|
|
43
|
-
"version:check": "node version-sync.js check",
|
|
44
|
-
"version:sync": "node version-sync.js sync",
|
|
45
|
-
"version:list": "node version-sync.js list",
|
|
46
|
-
"version:next": "node version-sync.js next",
|
|
47
|
-
"postversion": "echo \"✅ Version updated to $(node -p 'require(\"./package.json\").version')\" && (git push && git push --tags || echo \"⚠️ Git push failed - you may need to pull and push manually\")"
|
|
48
|
-
},
|
|
49
|
-
"keywords": [
|
|
50
|
-
"tagadapay",
|
|
51
|
-
"cms",
|
|
52
|
-
"plugin",
|
|
53
|
-
"sdk",
|
|
54
|
-
"react",
|
|
55
|
-
"typescript"
|
|
56
|
-
],
|
|
57
|
-
"author": "Tagada Pay",
|
|
58
|
-
"license": "MIT",
|
|
59
|
-
"dependencies": {
|
|
60
|
-
"@basis-theory/apple-pay-js": "^2.0.2",
|
|
61
|
-
"@basis-theory/basis-theory-js": "^4.30.0",
|
|
62
|
-
"@basis-theory/basis-theory-react": "^1.32.5",
|
|
63
|
-
"@basis-theory/web-threeds": "^1.0.1",
|
|
64
|
-
"@google-pay/button-react": "^3.0.10",
|
|
65
|
-
"@tanstack/react-query": "^5.90.2",
|
|
66
|
-
"axios": "^1.10.0",
|
|
67
|
-
"iso3166-2-db": "^2.3.11",
|
|
68
|
-
"path-to-regexp": "^8.2.0",
|
|
69
|
-
"react-intl": "^7.1.11",
|
|
70
|
-
"swr": "^2.3.6"
|
|
71
|
-
},
|
|
72
|
-
"devDependencies": {
|
|
73
|
-
"@types/jest": "^29.5.0",
|
|
74
|
-
"@types/node": "^18.0.0",
|
|
75
|
-
"@types/react": "^19",
|
|
76
|
-
"@types/react-dom": "^19",
|
|
77
|
-
"jest": "^29.5.0",
|
|
78
|
-
"ts-jest": "^29.1.0",
|
|
79
|
-
"typescript": "^5.0.0"
|
|
80
|
-
},
|
|
81
|
-
"peerDependencies": {
|
|
82
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
83
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
84
|
-
},
|
|
85
|
-
"files": [
|
|
86
|
-
"dist/**/*",
|
|
87
|
-
"README.md"
|
|
88
|
-
],
|
|
89
|
-
"repository": {
|
|
90
|
-
"type": "git",
|
|
91
|
-
"url": "git+https://github.com/tagadapay/plugin-sdk.git"
|
|
92
|
-
},
|
|
93
|
-
"bugs": {
|
|
94
|
-
"url": "https://github.com/tagadapay/plugin-sdk/issues"
|
|
95
|
-
},
|
|
96
|
-
"homepage": "https://github.com/tagadapay/plugin-sdk#readme"
|
|
97
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tagadapay/plugin-sdk",
|
|
3
|
+
"version": "2.8.1",
|
|
4
|
+
"description": "Modern React SDK for building Tagada Pay plugins",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./react": {
|
|
14
|
+
"types": "./dist/react/index.d.ts",
|
|
15
|
+
"import": "./dist/react/index.js",
|
|
16
|
+
"require": "./dist/react/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./v2": {
|
|
19
|
+
"types": "./dist/v2/index.d.ts",
|
|
20
|
+
"import": "./dist/v2/index.js",
|
|
21
|
+
"require": "./dist/v2/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"clean": "rm -rf dist",
|
|
27
|
+
"lint": "echo \"No linting configured\"",
|
|
28
|
+
"test": "jest --no-watchman",
|
|
29
|
+
"test:watch": "jest --watch --no-watchman",
|
|
30
|
+
"test:coverage": "jest --coverage --no-watchman",
|
|
31
|
+
"dev": "tsc --watch",
|
|
32
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
33
|
+
"publish:patch": "npm version patch && npm publish",
|
|
34
|
+
"publish:minor": "npm version minor && npm publish",
|
|
35
|
+
"publish:major": "npm version major && npm publish",
|
|
36
|
+
"publish:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
|
|
37
|
+
"publish:alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
|
|
38
|
+
"version:patch": "npm version patch",
|
|
39
|
+
"version:minor": "npm version minor",
|
|
40
|
+
"version:major": "npm version major",
|
|
41
|
+
"version:beta": "npm version prerelease --preid=beta",
|
|
42
|
+
"version:alpha": "npm version prerelease --preid=alpha",
|
|
43
|
+
"version:check": "node version-sync.js check",
|
|
44
|
+
"version:sync": "node version-sync.js sync",
|
|
45
|
+
"version:list": "node version-sync.js list",
|
|
46
|
+
"version:next": "node version-sync.js next",
|
|
47
|
+
"postversion": "echo \"✅ Version updated to $(node -p 'require(\"./package.json\").version')\" && (git push && git push --tags || echo \"⚠️ Git push failed - you may need to pull and push manually\")"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"tagadapay",
|
|
51
|
+
"cms",
|
|
52
|
+
"plugin",
|
|
53
|
+
"sdk",
|
|
54
|
+
"react",
|
|
55
|
+
"typescript"
|
|
56
|
+
],
|
|
57
|
+
"author": "Tagada Pay",
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@basis-theory/apple-pay-js": "^2.0.2",
|
|
61
|
+
"@basis-theory/basis-theory-js": "^4.30.0",
|
|
62
|
+
"@basis-theory/basis-theory-react": "^1.32.5",
|
|
63
|
+
"@basis-theory/web-threeds": "^1.0.1",
|
|
64
|
+
"@google-pay/button-react": "^3.0.10",
|
|
65
|
+
"@tanstack/react-query": "^5.90.2",
|
|
66
|
+
"axios": "^1.10.0",
|
|
67
|
+
"iso3166-2-db": "^2.3.11",
|
|
68
|
+
"path-to-regexp": "^8.2.0",
|
|
69
|
+
"react-intl": "^7.1.11",
|
|
70
|
+
"swr": "^2.3.6"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@types/jest": "^29.5.0",
|
|
74
|
+
"@types/node": "^18.0.0",
|
|
75
|
+
"@types/react": "^19",
|
|
76
|
+
"@types/react-dom": "^19",
|
|
77
|
+
"jest": "^29.5.0",
|
|
78
|
+
"ts-jest": "^29.1.0",
|
|
79
|
+
"typescript": "^5.0.0"
|
|
80
|
+
},
|
|
81
|
+
"peerDependencies": {
|
|
82
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
83
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
84
|
+
},
|
|
85
|
+
"files": [
|
|
86
|
+
"dist/**/*",
|
|
87
|
+
"README.md"
|
|
88
|
+
],
|
|
89
|
+
"repository": {
|
|
90
|
+
"type": "git",
|
|
91
|
+
"url": "git+https://github.com/tagadapay/plugin-sdk.git"
|
|
92
|
+
},
|
|
93
|
+
"bugs": {
|
|
94
|
+
"url": "https://github.com/tagadapay/plugin-sdk/issues"
|
|
95
|
+
},
|
|
96
|
+
"homepage": "https://github.com/tagadapay/plugin-sdk#readme"
|
|
97
|
+
}
|