@tagadapay/plugin-sdk 2.4.38 → 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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/react/hooks/useCheckout.js +21 -33
- package/dist/react/hooks/useCheckoutSession.d.ts +19 -0
- package/dist/react/hooks/useCheckoutSession.js +108 -0
- package/dist/react/hooks/useCheckoutToken.d.ts +17 -0
- package/dist/react/hooks/useCheckoutToken.js +80 -0
- package/dist/react/hooks/useOrderBump.js +94 -29
- package/dist/react/hooks/useOrderBumpV2.d.ts +17 -0
- package/dist/react/hooks/useOrderBumpV2.js +95 -0
- package/dist/react/hooks/useOrderBumpV3.d.ts +23 -0
- package/dist/react/hooks/useOrderBumpV3.js +109 -0
- package/dist/react/hooks/usePayment.d.ts +1 -1
- package/dist/react/hooks/usePayment.js +2 -18
- package/dist/react/hooks/usePluginConfig.js +2 -13
- package/dist/react/hooks/usePostPurchases.js +11 -5
- package/dist/react/hooks/useProducts.js +2 -16
- package/dist/react/index.d.ts +9 -1
- package/dist/react/index.js +5 -1
- package/dist/react/providers/TagadaProvider.d.ts +0 -1
- package/dist/react/providers/TagadaProvider.js +16 -12
- package/dist/react/services/apiService.d.ts +1 -0
- package/dist/react/services/apiService.js +3 -0
- package/dist/v2/core/googleAutocomplete.d.ts +65 -0
- package/dist/v2/core/googleAutocomplete.js +94 -0
- package/dist/v2/core/index.d.ts +8 -0
- package/dist/v2/core/index.js +11 -0
- package/dist/v2/core/isoData.d.ts +50 -0
- package/dist/v2/core/isoData.js +103 -0
- package/dist/v2/core/resources/apiClient.d.ts +25 -0
- package/dist/v2/core/resources/apiClient.js +95 -0
- package/dist/v2/core/resources/checkout.d.ts +189 -0
- package/dist/v2/core/resources/checkout.js +119 -0
- package/dist/v2/core/resources/index.d.ts +13 -0
- package/dist/v2/core/resources/index.js +13 -0
- package/dist/v2/core/resources/offers.d.ts +98 -0
- package/dist/v2/core/resources/offers.js +115 -0
- package/dist/v2/core/resources/orders.d.ts +40 -0
- package/dist/v2/core/resources/orders.js +59 -0
- package/dist/v2/core/resources/payments.d.ts +140 -0
- package/dist/v2/core/resources/payments.js +126 -0
- package/dist/v2/core/resources/postPurchases.d.ts +182 -0
- package/dist/v2/core/resources/postPurchases.js +116 -0
- package/dist/v2/core/resources/products.d.ts +29 -0
- package/dist/v2/core/resources/products.js +49 -0
- package/dist/v2/core/resources/promotions.d.ts +45 -0
- package/dist/v2/core/resources/promotions.js +87 -0
- package/dist/v2/core/resources/threeds.d.ts +23 -0
- package/dist/v2/core/resources/threeds.js +15 -0
- package/dist/v2/core/utils/checkout.d.ts +24 -0
- package/dist/v2/core/utils/checkout.js +30 -0
- package/dist/v2/core/utils/currency.d.ts +28 -0
- package/dist/v2/core/utils/currency.js +272 -0
- package/dist/v2/core/utils/index.d.ts +12 -0
- package/dist/v2/core/utils/index.js +12 -0
- package/dist/v2/core/utils/order.d.ts +159 -0
- package/dist/v2/core/utils/order.js +42 -0
- package/dist/v2/core/utils/orderBump.d.ts +40 -0
- package/dist/v2/core/utils/orderBump.js +47 -0
- package/dist/v2/core/utils/pluginConfig.d.ts +43 -0
- package/dist/v2/core/utils/pluginConfig.js +155 -0
- package/dist/v2/core/utils/postPurchases.d.ts +32 -0
- package/dist/v2/core/utils/postPurchases.js +42 -0
- package/dist/v2/core/utils/products.d.ts +58 -0
- package/dist/v2/core/utils/products.js +64 -0
- package/dist/v2/core/utils/promotions.d.ts +24 -0
- package/dist/v2/core/utils/promotions.js +30 -0
- package/dist/v2/index.d.ts +19 -0
- package/dist/v2/index.js +15 -0
- package/dist/v2/react/components/DebugDrawer.d.ts +7 -0
- package/dist/v2/react/components/DebugDrawer.js +383 -0
- package/dist/v2/react/hooks/useApiQuery.d.ts +28 -0
- package/dist/v2/react/hooks/useApiQuery.js +84 -0
- package/dist/v2/react/hooks/useCheckoutQuery.d.ts +39 -0
- package/dist/v2/react/hooks/useCheckoutQuery.js +208 -0
- package/dist/v2/react/hooks/useCheckoutToken.d.ts +17 -0
- package/dist/v2/react/hooks/useCheckoutToken.js +80 -0
- package/dist/v2/react/hooks/useCurrency.d.ts +9 -0
- package/dist/v2/react/hooks/useCurrency.js +21 -0
- package/dist/v2/react/hooks/useGeoLocation.d.ts +138 -0
- package/dist/v2/react/hooks/useGeoLocation.js +126 -0
- package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +74 -0
- package/dist/v2/react/hooks/useGoogleAutocomplete.js +207 -0
- package/dist/v2/react/hooks/useISOData.d.ts +61 -0
- package/dist/v2/react/hooks/useISOData.js +176 -0
- package/dist/v2/react/hooks/useOffersQuery.d.ts +65 -0
- package/dist/v2/react/hooks/useOffersQuery.js +353 -0
- package/dist/v2/react/hooks/useOrderBumpQuery.d.ts +20 -0
- package/dist/v2/react/hooks/useOrderBumpQuery.js +88 -0
- package/dist/v2/react/hooks/useOrderQuery.d.ts +29 -0
- package/dist/v2/react/hooks/useOrderQuery.js +98 -0
- package/dist/v2/react/hooks/usePaymentPolling.d.ts +45 -0
- package/dist/v2/react/hooks/usePaymentPolling.js +153 -0
- package/dist/v2/react/hooks/usePaymentQuery.d.ts +19 -0
- package/dist/v2/react/hooks/usePaymentQuery.js +283 -0
- package/dist/v2/react/hooks/usePluginConfig.d.ts +16 -0
- package/dist/v2/react/hooks/usePluginConfig.js +36 -0
- package/dist/v2/react/hooks/usePostPurchasesQuery.d.ts +63 -0
- package/dist/v2/react/hooks/usePostPurchasesQuery.js +365 -0
- package/dist/v2/react/hooks/useProductsQuery.d.ts +31 -0
- package/dist/v2/react/hooks/useProductsQuery.js +102 -0
- package/dist/v2/react/hooks/usePromotionsQuery.d.ts +28 -0
- package/dist/v2/react/hooks/usePromotionsQuery.js +97 -0
- package/dist/v2/react/hooks/useThreeds.d.ts +36 -0
- package/dist/v2/react/hooks/useThreeds.js +166 -0
- package/dist/v2/react/hooks/useThreedsModal.d.ts +13 -0
- package/dist/v2/react/hooks/useThreedsModal.js +343 -0
- package/dist/v2/react/index.d.ts +38 -0
- package/dist/v2/react/index.js +27 -0
- package/dist/v2/react/providers/TagadaProvider.d.ts +63 -0
- package/dist/v2/react/providers/TagadaProvider.js +680 -0
- package/package.json +10 -3
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Currency Utility Functions
|
|
3
|
+
* Pure functions for currency management
|
|
4
|
+
*/
|
|
5
|
+
export class CurrencyUtils {
|
|
6
|
+
/**
|
|
7
|
+
* Get currency from context or fallback to default
|
|
8
|
+
*/
|
|
9
|
+
static getCurrency(context, defaultCurrency = 'USD') {
|
|
10
|
+
// Handle case where context.currency might be a Currency object or string
|
|
11
|
+
let currencyCode;
|
|
12
|
+
if (typeof context?.currency === 'string') {
|
|
13
|
+
currencyCode = context.currency;
|
|
14
|
+
}
|
|
15
|
+
else if (context?.currency?.code) {
|
|
16
|
+
currencyCode = context.currency.code;
|
|
17
|
+
}
|
|
18
|
+
else if (context?.store?.presentmentCurrencies?.[0]) {
|
|
19
|
+
currencyCode = context.store.presentmentCurrencies[0];
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
currencyCode = defaultCurrency;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
code: currencyCode,
|
|
26
|
+
symbol: this.getCurrencySymbol(currencyCode),
|
|
27
|
+
name: this.getCurrencyName(currencyCode),
|
|
28
|
+
decimalPlaces: this.getDecimalPlaces(currencyCode),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get currency symbol
|
|
33
|
+
*/
|
|
34
|
+
static getCurrencySymbol(code) {
|
|
35
|
+
const symbols = {
|
|
36
|
+
USD: '$',
|
|
37
|
+
EUR: '€',
|
|
38
|
+
GBP: '£',
|
|
39
|
+
JPY: '¥',
|
|
40
|
+
CAD: 'C$',
|
|
41
|
+
AUD: 'A$',
|
|
42
|
+
CHF: 'CHF',
|
|
43
|
+
CNY: '¥',
|
|
44
|
+
SEK: 'kr',
|
|
45
|
+
NOK: 'kr',
|
|
46
|
+
DKK: 'kr',
|
|
47
|
+
PLN: 'zł',
|
|
48
|
+
CZK: 'Kč',
|
|
49
|
+
HUF: 'Ft',
|
|
50
|
+
RON: 'lei',
|
|
51
|
+
BGN: 'лв',
|
|
52
|
+
HRK: 'kn',
|
|
53
|
+
RUB: '₽',
|
|
54
|
+
UAH: '₴',
|
|
55
|
+
TRY: '₺',
|
|
56
|
+
BRL: 'R$',
|
|
57
|
+
ARS: '$',
|
|
58
|
+
CLP: '$',
|
|
59
|
+
COP: '$',
|
|
60
|
+
MXN: '$',
|
|
61
|
+
PEN: 'S/',
|
|
62
|
+
UYU: '$U',
|
|
63
|
+
VEF: 'Bs',
|
|
64
|
+
ZAR: 'R',
|
|
65
|
+
EGP: '£',
|
|
66
|
+
MAD: 'د.م.',
|
|
67
|
+
TND: 'د.ت',
|
|
68
|
+
DZD: 'د.ج',
|
|
69
|
+
LYD: 'ل.د',
|
|
70
|
+
NGN: '₦',
|
|
71
|
+
GHS: '₵',
|
|
72
|
+
KES: 'KSh',
|
|
73
|
+
UGX: 'USh',
|
|
74
|
+
TZS: 'TSh',
|
|
75
|
+
ETB: 'Br',
|
|
76
|
+
ZMW: 'ZK',
|
|
77
|
+
BWP: 'P',
|
|
78
|
+
SZL: 'L',
|
|
79
|
+
LSL: 'L',
|
|
80
|
+
NAD: 'N$',
|
|
81
|
+
MUR: '₨',
|
|
82
|
+
SCR: '₨',
|
|
83
|
+
KWD: 'د.ك',
|
|
84
|
+
BHD: 'د.ب',
|
|
85
|
+
QAR: 'ر.ق',
|
|
86
|
+
AED: 'د.إ',
|
|
87
|
+
OMR: 'ر.ع.',
|
|
88
|
+
YER: '﷼',
|
|
89
|
+
SAR: 'ر.س',
|
|
90
|
+
JOD: 'د.ا',
|
|
91
|
+
LBP: 'ل.ل',
|
|
92
|
+
ILS: '₪',
|
|
93
|
+
INR: '₹',
|
|
94
|
+
PKR: '₨',
|
|
95
|
+
BDT: '৳',
|
|
96
|
+
LKR: '₨',
|
|
97
|
+
NPR: '₨',
|
|
98
|
+
AFN: '؋',
|
|
99
|
+
KZT: '₸',
|
|
100
|
+
UZS: 'лв',
|
|
101
|
+
KGS: 'лв',
|
|
102
|
+
TJS: 'SM',
|
|
103
|
+
TMT: 'T',
|
|
104
|
+
AZN: '₼',
|
|
105
|
+
GEL: '₾',
|
|
106
|
+
AMD: '֏',
|
|
107
|
+
KRW: '₩',
|
|
108
|
+
THB: '฿',
|
|
109
|
+
VND: '₫',
|
|
110
|
+
IDR: 'Rp',
|
|
111
|
+
MYR: 'RM',
|
|
112
|
+
SGD: 'S$',
|
|
113
|
+
PHP: '₱',
|
|
114
|
+
TWD: 'NT$',
|
|
115
|
+
HKD: 'HK$',
|
|
116
|
+
MOP: 'MOP$',
|
|
117
|
+
BND: 'B$',
|
|
118
|
+
LAK: '₭',
|
|
119
|
+
KHR: '៛',
|
|
120
|
+
MMK: 'K',
|
|
121
|
+
BOB: 'Bs',
|
|
122
|
+
PYG: '₲',
|
|
123
|
+
GTQ: 'Q',
|
|
124
|
+
HNL: 'L',
|
|
125
|
+
NIO: 'C$',
|
|
126
|
+
CRC: '₡',
|
|
127
|
+
PAB: 'B/.',
|
|
128
|
+
DOP: 'RD$',
|
|
129
|
+
JMD: 'J$',
|
|
130
|
+
TTD: 'TT$',
|
|
131
|
+
BBD: 'Bds$',
|
|
132
|
+
XCD: 'EC$',
|
|
133
|
+
AWG: 'ƒ',
|
|
134
|
+
ANG: 'ƒ',
|
|
135
|
+
SRD: '$',
|
|
136
|
+
GYD: 'G$',
|
|
137
|
+
VES: 'Bs.S',
|
|
138
|
+
VED: 'Bs.D',
|
|
139
|
+
};
|
|
140
|
+
return symbols[code] || code;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Get currency name
|
|
144
|
+
*/
|
|
145
|
+
static getCurrencyName(code) {
|
|
146
|
+
const names = {
|
|
147
|
+
USD: 'US Dollar',
|
|
148
|
+
EUR: 'Euro',
|
|
149
|
+
GBP: 'British Pound',
|
|
150
|
+
JPY: 'Japanese Yen',
|
|
151
|
+
CAD: 'Canadian Dollar',
|
|
152
|
+
AUD: 'Australian Dollar',
|
|
153
|
+
CHF: 'Swiss Franc',
|
|
154
|
+
CNY: 'Chinese Yuan',
|
|
155
|
+
SEK: 'Swedish Krona',
|
|
156
|
+
NOK: 'Norwegian Krone',
|
|
157
|
+
DKK: 'Danish Krone',
|
|
158
|
+
PLN: 'Polish Zloty',
|
|
159
|
+
CZK: 'Czech Koruna',
|
|
160
|
+
HUF: 'Hungarian Forint',
|
|
161
|
+
RON: 'Romanian Leu',
|
|
162
|
+
BGN: 'Bulgarian Lev',
|
|
163
|
+
HRK: 'Croatian Kuna',
|
|
164
|
+
RUB: 'Russian Ruble',
|
|
165
|
+
UAH: 'Ukrainian Hryvnia',
|
|
166
|
+
TRY: 'Turkish Lira',
|
|
167
|
+
BRL: 'Brazilian Real',
|
|
168
|
+
ARS: 'Argentine Peso',
|
|
169
|
+
CLP: 'Chilean Peso',
|
|
170
|
+
COP: 'Colombian Peso',
|
|
171
|
+
MXN: 'Mexican Peso',
|
|
172
|
+
PEN: 'Peruvian Sol',
|
|
173
|
+
UYU: 'Uruguayan Peso',
|
|
174
|
+
VEF: 'Venezuelan Bolivar',
|
|
175
|
+
ZAR: 'South African Rand',
|
|
176
|
+
EGP: 'Egyptian Pound',
|
|
177
|
+
MAD: 'Moroccan Dirham',
|
|
178
|
+
TND: 'Tunisian Dinar',
|
|
179
|
+
DZD: 'Algerian Dinar',
|
|
180
|
+
LYD: 'Libyan Dinar',
|
|
181
|
+
NGN: 'Nigerian Naira',
|
|
182
|
+
GHS: 'Ghanaian Cedi',
|
|
183
|
+
KES: 'Kenyan Shilling',
|
|
184
|
+
UGX: 'Ugandan Shilling',
|
|
185
|
+
TZS: 'Tanzanian Shilling',
|
|
186
|
+
ETB: 'Ethiopian Birr',
|
|
187
|
+
ZMW: 'Zambian Kwacha',
|
|
188
|
+
BWP: 'Botswana Pula',
|
|
189
|
+
SZL: 'Swazi Lilangeni',
|
|
190
|
+
LSL: 'Lesotho Loti',
|
|
191
|
+
NAD: 'Namibian Dollar',
|
|
192
|
+
MUR: 'Mauritian Rupee',
|
|
193
|
+
SCR: 'Seychellois Rupee',
|
|
194
|
+
KWD: 'Kuwaiti Dinar',
|
|
195
|
+
BHD: 'Bahraini Dinar',
|
|
196
|
+
QAR: 'Qatari Riyal',
|
|
197
|
+
AED: 'UAE Dirham',
|
|
198
|
+
OMR: 'Omani Rial',
|
|
199
|
+
YER: 'Yemeni Rial',
|
|
200
|
+
SAR: 'Saudi Riyal',
|
|
201
|
+
JOD: 'Jordanian Dinar',
|
|
202
|
+
LBP: 'Lebanese Pound',
|
|
203
|
+
ILS: 'Israeli Shekel',
|
|
204
|
+
INR: 'Indian Rupee',
|
|
205
|
+
PKR: 'Pakistani Rupee',
|
|
206
|
+
BDT: 'Bangladeshi Taka',
|
|
207
|
+
LKR: 'Sri Lankan Rupee',
|
|
208
|
+
NPR: 'Nepalese Rupee',
|
|
209
|
+
AFN: 'Afghan Afghani',
|
|
210
|
+
KZT: 'Kazakhstani Tenge',
|
|
211
|
+
UZS: 'Uzbekistani Som',
|
|
212
|
+
KGS: 'Kyrgyzstani Som',
|
|
213
|
+
TJS: 'Tajikistani Somoni',
|
|
214
|
+
TMT: 'Turkmenistani Manat',
|
|
215
|
+
AZN: 'Azerbaijani Manat',
|
|
216
|
+
GEL: 'Georgian Lari',
|
|
217
|
+
AMD: 'Armenian Dram',
|
|
218
|
+
KRW: 'South Korean Won',
|
|
219
|
+
THB: 'Thai Baht',
|
|
220
|
+
VND: 'Vietnamese Dong',
|
|
221
|
+
IDR: 'Indonesian Rupiah',
|
|
222
|
+
MYR: 'Malaysian Ringgit',
|
|
223
|
+
SGD: 'Singapore Dollar',
|
|
224
|
+
PHP: 'Philippine Peso',
|
|
225
|
+
TWD: 'Taiwan Dollar',
|
|
226
|
+
HKD: 'Hong Kong Dollar',
|
|
227
|
+
MOP: 'Macanese Pataca',
|
|
228
|
+
BND: 'Brunei Dollar',
|
|
229
|
+
LAK: 'Lao Kip',
|
|
230
|
+
KHR: 'Cambodian Riel',
|
|
231
|
+
MMK: 'Myanmar Kyat',
|
|
232
|
+
BOB: 'Bolivian Boliviano',
|
|
233
|
+
PYG: 'Paraguayan Guarani',
|
|
234
|
+
GTQ: 'Guatemalan Quetzal',
|
|
235
|
+
HNL: 'Honduran Lempira',
|
|
236
|
+
NIO: 'Nicaraguan Cordoba',
|
|
237
|
+
CRC: 'Costa Rican Colon',
|
|
238
|
+
PAB: 'Panamanian Balboa',
|
|
239
|
+
DOP: 'Dominican Peso',
|
|
240
|
+
JMD: 'Jamaican Dollar',
|
|
241
|
+
TTD: 'Trinidad and Tobago Dollar',
|
|
242
|
+
BBD: 'Barbadian Dollar',
|
|
243
|
+
XCD: 'East Caribbean Dollar',
|
|
244
|
+
AWG: 'Aruban Florin',
|
|
245
|
+
ANG: 'Netherlands Antillean Guilder',
|
|
246
|
+
SRD: 'Surinamese Dollar',
|
|
247
|
+
GYD: 'Guyanese Dollar',
|
|
248
|
+
VES: 'Venezuelan Bolivar Soberano',
|
|
249
|
+
VED: 'Venezuelan Bolivar Digital',
|
|
250
|
+
};
|
|
251
|
+
return names[code] || code;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Get decimal places for currency
|
|
255
|
+
*/
|
|
256
|
+
static getDecimalPlaces(code) {
|
|
257
|
+
const decimalPlaces = {
|
|
258
|
+
JPY: 0,
|
|
259
|
+
KRW: 0,
|
|
260
|
+
VND: 0,
|
|
261
|
+
IDR: 0,
|
|
262
|
+
LAK: 0,
|
|
263
|
+
KHR: 0,
|
|
264
|
+
MMK: 0,
|
|
265
|
+
PYG: 0,
|
|
266
|
+
VEF: 0,
|
|
267
|
+
VES: 0,
|
|
268
|
+
VED: 0,
|
|
269
|
+
};
|
|
270
|
+
return decimalPlaces[code] ?? 2;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Utility Functions
|
|
3
|
+
* Pure functions without React dependencies
|
|
4
|
+
*/
|
|
5
|
+
export * from './products';
|
|
6
|
+
export * from './order';
|
|
7
|
+
export * from './currency';
|
|
8
|
+
export * from './pluginConfig';
|
|
9
|
+
export * from './checkout';
|
|
10
|
+
export * from './promotions';
|
|
11
|
+
export * from './postPurchases';
|
|
12
|
+
export * from './orderBump';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Utility Functions
|
|
3
|
+
* Pure functions without React dependencies
|
|
4
|
+
*/
|
|
5
|
+
export * from './products';
|
|
6
|
+
export * from './order';
|
|
7
|
+
export * from './currency';
|
|
8
|
+
export * from './pluginConfig';
|
|
9
|
+
export * from './checkout';
|
|
10
|
+
export * from './promotions';
|
|
11
|
+
export * from './postPurchases';
|
|
12
|
+
export * from './orderBump';
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order Utility Functions
|
|
3
|
+
* Pure functions for order data manipulation
|
|
4
|
+
*/
|
|
5
|
+
export interface OrderLineItem {
|
|
6
|
+
id: string;
|
|
7
|
+
orderId: string;
|
|
8
|
+
productId: string;
|
|
9
|
+
variantId: string;
|
|
10
|
+
priceId: string;
|
|
11
|
+
sku: string;
|
|
12
|
+
unitAmount: number;
|
|
13
|
+
quantity: number;
|
|
14
|
+
amount: number;
|
|
15
|
+
adjustedAmount: number;
|
|
16
|
+
currency: string;
|
|
17
|
+
adjustments?: Record<string, unknown>[];
|
|
18
|
+
recurring: boolean;
|
|
19
|
+
rebillMode?: string | null;
|
|
20
|
+
rebillStepIntervalMs?: number | null;
|
|
21
|
+
interval: string;
|
|
22
|
+
intervalCount: number;
|
|
23
|
+
totalBillingCycles: number;
|
|
24
|
+
unitAmountAfterFirstCycle: number;
|
|
25
|
+
subscriptionSettings?: Record<string, unknown> | null;
|
|
26
|
+
orderLineItemProduct: {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
storefrontProductId: string;
|
|
31
|
+
originalProductId: string;
|
|
32
|
+
orderLineItemId: string;
|
|
33
|
+
};
|
|
34
|
+
orderLineItemVariant: {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
price: number | null;
|
|
38
|
+
currency: string | null;
|
|
39
|
+
imageUrl: string;
|
|
40
|
+
description: string | null;
|
|
41
|
+
storefrontVariantId: string | null;
|
|
42
|
+
originalVariantId: string;
|
|
43
|
+
orderLineItemId: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface Order {
|
|
47
|
+
id: string;
|
|
48
|
+
storeId: string;
|
|
49
|
+
accountId: string;
|
|
50
|
+
createdAt: string;
|
|
51
|
+
updatedAt: string;
|
|
52
|
+
status: string;
|
|
53
|
+
cancelledAt?: string | null;
|
|
54
|
+
cancelledReason?: string | null;
|
|
55
|
+
paidAt?: string | null;
|
|
56
|
+
paidAmount: number;
|
|
57
|
+
openAt: string;
|
|
58
|
+
abandonedAt?: string | null;
|
|
59
|
+
currency: string;
|
|
60
|
+
externalCustomerType?: string | null;
|
|
61
|
+
externalCustomerId?: string | null;
|
|
62
|
+
externalOrderId?: string | null;
|
|
63
|
+
billingAddress?: {
|
|
64
|
+
company: string;
|
|
65
|
+
firstName: string;
|
|
66
|
+
lastName: string;
|
|
67
|
+
address1: string;
|
|
68
|
+
city: string;
|
|
69
|
+
country: string;
|
|
70
|
+
state: string;
|
|
71
|
+
postal: string;
|
|
72
|
+
phone: string;
|
|
73
|
+
email?: string;
|
|
74
|
+
};
|
|
75
|
+
shippingAddress?: {
|
|
76
|
+
company: string;
|
|
77
|
+
firstName: string;
|
|
78
|
+
lastName: string;
|
|
79
|
+
address1: string;
|
|
80
|
+
city: string;
|
|
81
|
+
country: string;
|
|
82
|
+
state: string;
|
|
83
|
+
postal: string;
|
|
84
|
+
phone: string;
|
|
85
|
+
};
|
|
86
|
+
pickupAddress?: Record<string, unknown> | null;
|
|
87
|
+
taxesIncluded: boolean;
|
|
88
|
+
draft: boolean;
|
|
89
|
+
checkoutSessionId: string;
|
|
90
|
+
sessionHash: string;
|
|
91
|
+
customerId: string;
|
|
92
|
+
createdFrom: string;
|
|
93
|
+
paymentInstrumentId: string;
|
|
94
|
+
refundedAt?: string | null;
|
|
95
|
+
refundedAmount?: number | null;
|
|
96
|
+
metadata?: any;
|
|
97
|
+
customer?: {
|
|
98
|
+
id: string;
|
|
99
|
+
email: string;
|
|
100
|
+
firstName: string;
|
|
101
|
+
lastName: string;
|
|
102
|
+
externalCustomerId?: string | null;
|
|
103
|
+
lastOrderId: string;
|
|
104
|
+
accountId: string;
|
|
105
|
+
storeId: string;
|
|
106
|
+
billingAddress?: any;
|
|
107
|
+
shippingAddress?: any;
|
|
108
|
+
currency: string;
|
|
109
|
+
locale: string;
|
|
110
|
+
draft: boolean;
|
|
111
|
+
acceptsMarketing: boolean;
|
|
112
|
+
createdAt: string;
|
|
113
|
+
updatedAt: string;
|
|
114
|
+
metadata?: any;
|
|
115
|
+
device?: Record<string, unknown> | null;
|
|
116
|
+
};
|
|
117
|
+
items: OrderLineItem[];
|
|
118
|
+
summaries?: any[];
|
|
119
|
+
promotions?: any[];
|
|
120
|
+
checkoutSession?: {
|
|
121
|
+
id: string;
|
|
122
|
+
selectedPresentmentCurrency?: string;
|
|
123
|
+
[key: string]: any;
|
|
124
|
+
};
|
|
125
|
+
payments?: any[];
|
|
126
|
+
subscriptions?: any[];
|
|
127
|
+
store?: {
|
|
128
|
+
name: string;
|
|
129
|
+
chargeCurrencies: string[];
|
|
130
|
+
presentmentCurrencies: string[];
|
|
131
|
+
};
|
|
132
|
+
relatedOrders?: Order[];
|
|
133
|
+
}
|
|
134
|
+
export declare class OrderUtils {
|
|
135
|
+
/**
|
|
136
|
+
* Get order line items
|
|
137
|
+
*/
|
|
138
|
+
static getOrderLineItems(order: Order): OrderLineItem[];
|
|
139
|
+
/**
|
|
140
|
+
* Get order total
|
|
141
|
+
*/
|
|
142
|
+
static getOrderTotal(order: Order): number;
|
|
143
|
+
/**
|
|
144
|
+
* Get order status
|
|
145
|
+
*/
|
|
146
|
+
static getOrderStatus(order: Order): string;
|
|
147
|
+
/**
|
|
148
|
+
* Check if order is completed
|
|
149
|
+
*/
|
|
150
|
+
static isOrderCompleted(order: Order): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Check if order is pending
|
|
153
|
+
*/
|
|
154
|
+
static isOrderPending(order: Order): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Check if order is cancelled
|
|
157
|
+
*/
|
|
158
|
+
static isOrderCancelled(order: Order): boolean;
|
|
159
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order Utility Functions
|
|
3
|
+
* Pure functions for order data manipulation
|
|
4
|
+
*/
|
|
5
|
+
export class OrderUtils {
|
|
6
|
+
/**
|
|
7
|
+
* Get order line items
|
|
8
|
+
*/
|
|
9
|
+
static getOrderLineItems(order) {
|
|
10
|
+
return order.items || [];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get order total
|
|
14
|
+
*/
|
|
15
|
+
static getOrderTotal(order) {
|
|
16
|
+
return order.paidAmount || 0;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get order status
|
|
20
|
+
*/
|
|
21
|
+
static getOrderStatus(order) {
|
|
22
|
+
return order.status || 'unknown';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if order is completed
|
|
26
|
+
*/
|
|
27
|
+
static isOrderCompleted(order) {
|
|
28
|
+
return order.status === 'completed' || order.status === 'fulfilled';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if order is pending
|
|
32
|
+
*/
|
|
33
|
+
static isOrderPending(order) {
|
|
34
|
+
return order.status === 'pending' || order.status === 'processing';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Check if order is cancelled
|
|
38
|
+
*/
|
|
39
|
+
static isOrderCancelled(order) {
|
|
40
|
+
return order.status === 'cancelled' || order.status === 'refunded';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order Bump Utility Functions
|
|
3
|
+
* Pure functions for order bump data manipulation
|
|
4
|
+
*/
|
|
5
|
+
export interface OrderBumpOffer {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
price: number;
|
|
10
|
+
currency: string;
|
|
11
|
+
imageUrl?: string;
|
|
12
|
+
isSelected?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface OrderBumpPreview {
|
|
15
|
+
offer: OrderBumpOffer;
|
|
16
|
+
totalAmount: number;
|
|
17
|
+
adjustedAmount: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class OrderBumpUtils {
|
|
20
|
+
/**
|
|
21
|
+
* Check if order bump offer is valid
|
|
22
|
+
*/
|
|
23
|
+
static isValidOffer(offer: OrderBumpOffer): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Toggle order bump selection
|
|
26
|
+
*/
|
|
27
|
+
static toggleSelection(offer: OrderBumpOffer): OrderBumpOffer;
|
|
28
|
+
/**
|
|
29
|
+
* Calculate order bump preview
|
|
30
|
+
*/
|
|
31
|
+
static calculatePreview(offer: OrderBumpOffer, baseAmount?: number): OrderBumpPreview;
|
|
32
|
+
/**
|
|
33
|
+
* Get selected order bumps
|
|
34
|
+
*/
|
|
35
|
+
static getSelectedOffers(offers: OrderBumpOffer[]): OrderBumpOffer[];
|
|
36
|
+
/**
|
|
37
|
+
* Get total for selected order bumps
|
|
38
|
+
*/
|
|
39
|
+
static getSelectedTotal(offers: OrderBumpOffer[]): number;
|
|
40
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order Bump Utility Functions
|
|
3
|
+
* Pure functions for order bump data manipulation
|
|
4
|
+
*/
|
|
5
|
+
export class OrderBumpUtils {
|
|
6
|
+
/**
|
|
7
|
+
* Check if order bump offer is valid
|
|
8
|
+
*/
|
|
9
|
+
static isValidOffer(offer) {
|
|
10
|
+
return !!(offer.id && offer.name && offer.price > 0);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Toggle order bump selection
|
|
14
|
+
*/
|
|
15
|
+
static toggleSelection(offer) {
|
|
16
|
+
return {
|
|
17
|
+
...offer,
|
|
18
|
+
isSelected: !offer.isSelected,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Calculate order bump preview
|
|
23
|
+
*/
|
|
24
|
+
static calculatePreview(offer, baseAmount = 0) {
|
|
25
|
+
const totalAmount = baseAmount + offer.price;
|
|
26
|
+
const adjustedAmount = offer.isSelected ? totalAmount : baseAmount;
|
|
27
|
+
return {
|
|
28
|
+
offer,
|
|
29
|
+
totalAmount,
|
|
30
|
+
adjustedAmount,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get selected order bumps
|
|
35
|
+
*/
|
|
36
|
+
static getSelectedOffers(offers) {
|
|
37
|
+
return offers.filter(offer => offer.isSelected);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get total for selected order bumps
|
|
41
|
+
*/
|
|
42
|
+
static getSelectedTotal(offers) {
|
|
43
|
+
return offers
|
|
44
|
+
.filter(offer => offer.isSelected)
|
|
45
|
+
.reduce((total, offer) => total + offer.price, 0);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin Configuration Utility Functions
|
|
3
|
+
* Pure functions for plugin configuration management
|
|
4
|
+
*/
|
|
5
|
+
export interface PluginConfig<TConfig = Record<string, any>> {
|
|
6
|
+
storeId?: string;
|
|
7
|
+
accountId?: string;
|
|
8
|
+
basePath?: string;
|
|
9
|
+
config?: TConfig;
|
|
10
|
+
productId?: string;
|
|
11
|
+
variants?: Record<string, string>;
|
|
12
|
+
prices?: Record<string, any>;
|
|
13
|
+
defaultCurrency?: string;
|
|
14
|
+
hidePriceId?: string;
|
|
15
|
+
upsellId?: string;
|
|
16
|
+
googleApiKey?: string;
|
|
17
|
+
branding?: any;
|
|
18
|
+
}
|
|
19
|
+
export interface RawPluginConfig<TConfig = Record<string, any>> {
|
|
20
|
+
storeId?: string;
|
|
21
|
+
accountId?: string;
|
|
22
|
+
basePath?: string;
|
|
23
|
+
config?: TConfig;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Core plugin config loading function
|
|
27
|
+
* Handles local dev, production, and raw config
|
|
28
|
+
*/
|
|
29
|
+
export declare const loadPluginConfig: (configVariant?: string, rawConfig?: RawPluginConfig) => Promise<PluginConfig>;
|
|
30
|
+
export declare class PluginConfigUtils {
|
|
31
|
+
/**
|
|
32
|
+
* Get plugin configuration from various sources
|
|
33
|
+
*/
|
|
34
|
+
static getPluginConfig<TConfig = Record<string, any>>(rawConfig?: RawPluginConfig<TConfig>, context?: {
|
|
35
|
+
storeId?: string;
|
|
36
|
+
accountId?: string;
|
|
37
|
+
basePath?: string;
|
|
38
|
+
}): PluginConfig<TConfig>;
|
|
39
|
+
/**
|
|
40
|
+
* Validate plugin configuration
|
|
41
|
+
*/
|
|
42
|
+
static validateConfig(config: PluginConfig): boolean;
|
|
43
|
+
}
|