@tagadapay/plugin-sdk 1.0.30 → 2.0.2
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/README.md +504 -414
- package/dist/data/iso3166.d.ts +30 -0
- package/dist/data/iso3166.js +102 -0
- package/dist/react/hooks/useAddress.js +19 -19
- package/dist/react/hooks/useAddressV2.d.ts +53 -0
- package/dist/react/hooks/useAddressV2.js +379 -0
- package/dist/react/hooks/useGoogleAutocomplete.d.ts +69 -0
- package/dist/react/hooks/useGoogleAutocomplete.js +219 -0
- package/dist/react/hooks/useISOData.d.ts +41 -0
- package/dist/react/hooks/useISOData.js +127 -0
- package/dist/react/hooks/usePluginConfig.d.ts +53 -0
- package/dist/react/hooks/usePluginConfig.js +190 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.js +6 -0
- package/dist/react/providers/TagadaProvider.d.ts +5 -1
- package/dist/react/providers/TagadaProvider.js +53 -7
- package/package.json +67 -66
package/README.md
CHANGED
|
@@ -1,414 +1,504 @@
|
|
|
1
|
-
# TagadaPay Plugin SDK
|
|
2
|
-
|
|
3
|
-
A comprehensive SDK for building checkout plugins on the TagadaPay platform. Create custom checkout experiences with React components, payment processing, and advanced features.
|
|
4
|
-
|
|
5
|
-
## 📚 Documentation
|
|
6
|
-
|
|
7
|
-
### Core APIs
|
|
8
|
-
|
|
9
|
-
- **[useCheckout](./README-useCheckout.md)** - Checkout state management and flow control
|
|
10
|
-
- **[setCheckoutInfo](./README-setCheckoutInfo.md)** - Customer information and validation
|
|
11
|
-
- **[useOffers](./README-useOffers.md)** - Dynamic pricing and promotional offers
|
|
12
|
-
- **[Money utilities](./README-money.md)** - Currency formatting and calculations
|
|
13
|
-
- **[URL utilities](./README-urlUtils.md)** - Navigation and routing helpers
|
|
14
|
-
|
|
15
|
-
###
|
|
16
|
-
|
|
17
|
-
- **[
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
###
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
###
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
###
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
1
|
+
# TagadaPay Plugin SDK
|
|
2
|
+
|
|
3
|
+
A comprehensive SDK for building checkout plugins on the TagadaPay platform. Create custom checkout experiences with React components, payment processing, and advanced features.
|
|
4
|
+
|
|
5
|
+
## 📚 Documentation
|
|
6
|
+
|
|
7
|
+
### Core APIs
|
|
8
|
+
|
|
9
|
+
- **[useCheckout](./docs/README-useCheckout.md)** - Checkout state management and flow control
|
|
10
|
+
- **[setCheckoutInfo](./docs/README-setCheckoutInfo.md)** - Customer information and validation
|
|
11
|
+
- **[useOffers](./docs/README-useOffers.md)** - Dynamic pricing and promotional offers
|
|
12
|
+
- **[Money utilities](./docs/README-money.md)** - Currency formatting and calculations
|
|
13
|
+
- **[URL utilities](./docs/README-urlUtils.md)** - Navigation and routing helpers
|
|
14
|
+
|
|
15
|
+
### Plugin Development
|
|
16
|
+
|
|
17
|
+
- **[Plugin Configuration](./docs/PLUGIN_CONFIG.md)** - How to access store context, config, and branding
|
|
18
|
+
- **[Google Autocomplete](./docs/README-google-autocomplete.md)** - Address autocomplete with Google Places API
|
|
19
|
+
- **[ISO Data](./docs/README-iso-data.md)** - Country and region data with Google integration
|
|
20
|
+
|
|
21
|
+
### Examples
|
|
22
|
+
|
|
23
|
+
- **[Vite Checkout Demo](../checkout-vite)** - Complete checkout implementation
|
|
24
|
+
|
|
25
|
+
## 🏗️ Building a Plugin
|
|
26
|
+
|
|
27
|
+
### Plugin Structure
|
|
28
|
+
|
|
29
|
+
Every TagadaPay plugin follows this simple structure:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
my-plugin/
|
|
33
|
+
├── plugin.manifest.json # Plugin metadata & routing
|
|
34
|
+
├── .local.json # Local dev config (auto-injected in production)
|
|
35
|
+
├── config/ # Optional deployment configs
|
|
36
|
+
│ ├── theme-green.json # Config variant A
|
|
37
|
+
│ └── theme-blue.json # Config variant B
|
|
38
|
+
├── src/
|
|
39
|
+
│ └── App.tsx # Your plugin code
|
|
40
|
+
└── dist/ # Built plugin files
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Configuration Flow
|
|
44
|
+
|
|
45
|
+
```mermaid
|
|
46
|
+
graph TD
|
|
47
|
+
A[🛠️ Local Development] --> B[.local.json]
|
|
48
|
+
A --> C[config/*.json]
|
|
49
|
+
B --> D[usePluginConfig()]
|
|
50
|
+
C --> D
|
|
51
|
+
|
|
52
|
+
E[🚀 Production] --> F[Platform Injection]
|
|
53
|
+
F --> G[HTTP Headers & Meta Tags]
|
|
54
|
+
G --> D
|
|
55
|
+
|
|
56
|
+
D --> H[Your Plugin Component]
|
|
57
|
+
|
|
58
|
+
style A fill:#e1f5fe
|
|
59
|
+
style E fill:#f3e5f5
|
|
60
|
+
style D fill:#fff3e0
|
|
61
|
+
style H fill:#e8f5e8
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Essential Files
|
|
65
|
+
|
|
66
|
+
#### 1. **`plugin.manifest.json`** - Plugin Metadata
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"pluginId": "my-awesome-plugin",
|
|
71
|
+
"name": "My Awesome Plugin",
|
|
72
|
+
"version": "1.0.0",
|
|
73
|
+
"mode": "direct-mode",
|
|
74
|
+
"router": {
|
|
75
|
+
"basePath": "/",
|
|
76
|
+
"matcher": ".*",
|
|
77
|
+
"excluder": "/checkout"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### 2. **`.local.json`** - Local Development Context
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"storeId": "store_abc123",
|
|
87
|
+
"accountId": "acc_xyz789",
|
|
88
|
+
"basePath": "/"
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
> ⚠️ **Auto-managed**: This file is only for local dev. In production, the platform injects this data automatically.
|
|
93
|
+
|
|
94
|
+
#### 3. **`config/my-theme.json`** - Optional Deployment Config
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"configName": "green-theme",
|
|
99
|
+
"branding": {
|
|
100
|
+
"primaryColor": "#059669",
|
|
101
|
+
"companyName": "My Store",
|
|
102
|
+
"logoUrl": "https://example.com/logo.png"
|
|
103
|
+
},
|
|
104
|
+
"features": {
|
|
105
|
+
"enableChat": true,
|
|
106
|
+
"maxItems": 10
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
> 📝 **Note**: Config can contain any keys you need - the SDK doesn't enforce a specific structure.
|
|
112
|
+
|
|
113
|
+
## 🚀 Quick Start
|
|
114
|
+
|
|
115
|
+
### Installation
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npm install @tagadapay/plugin-sdk
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Basic Plugin Setup
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import React from 'react';
|
|
125
|
+
import {
|
|
126
|
+
TagadaProvider,
|
|
127
|
+
usePluginConfig,
|
|
128
|
+
useGoogleAutocomplete,
|
|
129
|
+
useISOData,
|
|
130
|
+
} from '@tagadapay/plugin-sdk/react';
|
|
131
|
+
|
|
132
|
+
function MyPlugin() {
|
|
133
|
+
const { storeId, accountId, basePath, config, loading } = usePluginConfig();
|
|
134
|
+
|
|
135
|
+
// Optional: Add address autocomplete
|
|
136
|
+
const { searchPlaces, predictions } = useGoogleAutocomplete({
|
|
137
|
+
apiKey: config?.googleMapsApiKey || 'YOUR_API_KEY',
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// Optional: Add country/region data
|
|
141
|
+
const { countries } = useISOData('en');
|
|
142
|
+
|
|
143
|
+
if (loading) return <div>Loading...</div>;
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<div style={{ '--primary': config?.branding?.primaryColor }}>
|
|
147
|
+
<h1>Welcome to {config?.branding?.companyName}</h1>
|
|
148
|
+
<p>Store: {storeId}</p>
|
|
149
|
+
<p>Base Path: {basePath}</p>
|
|
150
|
+
<p>Available Countries: {Object.keys(countries).length}</p>
|
|
151
|
+
</div>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Wrap your plugin with TagadaProvider
|
|
156
|
+
function App() {
|
|
157
|
+
return (
|
|
158
|
+
<TagadaProvider>
|
|
159
|
+
<MyPlugin />
|
|
160
|
+
</TagadaProvider>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export default App;
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Development vs Production
|
|
168
|
+
|
|
169
|
+
| Environment | Store/Account ID | Deployment Config | How it Works |
|
|
170
|
+
| -------------- | ---------------- | ----------------- | ------------------ |
|
|
171
|
+
| **Local Dev** | `.local.json` | `config/*.json` | Files on disk |
|
|
172
|
+
| **Production** | HTTP Headers | Meta Tags | Platform injection |
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
// ✅ ALWAYS use hooks - works in both environments
|
|
176
|
+
const { storeId, accountId, basePath, config } = usePluginConfig();
|
|
177
|
+
|
|
178
|
+
// ❌ NEVER access directly
|
|
179
|
+
// const config = window.__PLUGIN_CONFIG__; // Doesn't exist!
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## 🎯 Key Features
|
|
183
|
+
|
|
184
|
+
### Payment Processing
|
|
185
|
+
|
|
186
|
+
- Secure tokenized payments
|
|
187
|
+
- Multiple payment method support
|
|
188
|
+
- Real-time validation
|
|
189
|
+
- PCI compliance
|
|
190
|
+
|
|
191
|
+
### Customer Management
|
|
192
|
+
|
|
193
|
+
- Profile management
|
|
194
|
+
- Address validation
|
|
195
|
+
- Order history
|
|
196
|
+
- Preferences
|
|
197
|
+
|
|
198
|
+
### Cart & Pricing
|
|
199
|
+
|
|
200
|
+
- Dynamic pricing
|
|
201
|
+
- Promotional offers
|
|
202
|
+
- Tax calculations
|
|
203
|
+
- Currency conversion
|
|
204
|
+
|
|
205
|
+
### UI Components
|
|
206
|
+
|
|
207
|
+
- Pre-built checkout components
|
|
208
|
+
- Customizable themes
|
|
209
|
+
- Mobile-optimized
|
|
210
|
+
- Accessibility features
|
|
211
|
+
|
|
212
|
+
## 📖 API Reference
|
|
213
|
+
|
|
214
|
+
### Core Hooks
|
|
215
|
+
|
|
216
|
+
#### useCheckout()
|
|
217
|
+
|
|
218
|
+
Primary hook for checkout state management.
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
const {
|
|
222
|
+
customer, // Customer information
|
|
223
|
+
cart, // Shopping cart state
|
|
224
|
+
payment, // Payment details
|
|
225
|
+
shipping, // Shipping information
|
|
226
|
+
loading, // Loading states
|
|
227
|
+
errors, // Error handling
|
|
228
|
+
} = useCheckout();
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
#### useOffers()
|
|
232
|
+
|
|
233
|
+
Hook for managing dynamic offers and pricing.
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
const {
|
|
237
|
+
offers, // Available offers
|
|
238
|
+
applyOffer, // Apply offer function
|
|
239
|
+
removeOffer, // Remove offer function
|
|
240
|
+
total, // Calculated total
|
|
241
|
+
} = useOffers();
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Utility Functions
|
|
245
|
+
|
|
246
|
+
#### setCheckoutInfo()
|
|
247
|
+
|
|
248
|
+
Update checkout information with validation.
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
await setCheckoutInfo({
|
|
252
|
+
customer: {
|
|
253
|
+
email: 'user@example.com',
|
|
254
|
+
firstName: 'John',
|
|
255
|
+
lastName: 'Doe',
|
|
256
|
+
},
|
|
257
|
+
payment: {
|
|
258
|
+
method: 'card',
|
|
259
|
+
token: 'pm_token_123',
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
#### Money utilities
|
|
265
|
+
|
|
266
|
+
Format and calculate monetary values.
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
import { formatMoney, convertCurrency } from '@tagadapay/plugin-sdk';
|
|
270
|
+
|
|
271
|
+
const formatted = formatMoney(2999, 'USD'); // "$29.99"
|
|
272
|
+
const converted = convertCurrency(2999, 'USD', 'EUR'); // 2699
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## 🛠️ Development
|
|
276
|
+
|
|
277
|
+
### Local Development
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
# Install dependencies
|
|
281
|
+
npm install
|
|
282
|
+
|
|
283
|
+
# Start development server
|
|
284
|
+
npm run dev
|
|
285
|
+
|
|
286
|
+
# Build for production
|
|
287
|
+
npm run build
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Testing
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
# Run tests
|
|
294
|
+
npm test
|
|
295
|
+
|
|
296
|
+
# Run tests with coverage
|
|
297
|
+
npm run test:coverage
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Linting
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
# Check code style
|
|
304
|
+
npm run lint
|
|
305
|
+
|
|
306
|
+
# Fix linting issues
|
|
307
|
+
npm run lint:fix
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## 📦 Build & Deploy
|
|
311
|
+
|
|
312
|
+
### Building Your Plugin
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
# Build optimized bundle
|
|
316
|
+
npm run build
|
|
317
|
+
|
|
318
|
+
# Analyze bundle size
|
|
319
|
+
npm run analyze
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Deployment
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
# Deploy using TagadaPay CLI
|
|
326
|
+
npx @tagadapay/plugin-cli deploy
|
|
327
|
+
|
|
328
|
+
# Deploy specific environment
|
|
329
|
+
npx @tagadapay/plugin-cli deploy --env production
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
## 🔧 Configuration
|
|
333
|
+
|
|
334
|
+
### Plugin Configuration
|
|
335
|
+
|
|
336
|
+
```json
|
|
337
|
+
{
|
|
338
|
+
"name": "My Checkout Plugin",
|
|
339
|
+
"version": "1.0.0",
|
|
340
|
+
"description": "Custom checkout experience",
|
|
341
|
+
"main": "dist/index.js",
|
|
342
|
+
"tagadapay": {
|
|
343
|
+
"type": "checkout",
|
|
344
|
+
"mode": "direct",
|
|
345
|
+
"framework": "react"
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## 🔐 Security
|
|
351
|
+
|
|
352
|
+
### Best Practices
|
|
353
|
+
|
|
354
|
+
- Never store sensitive payment data
|
|
355
|
+
- Always validate user inputs
|
|
356
|
+
- Use HTTPS in production
|
|
357
|
+
- Implement proper error handling
|
|
358
|
+
- Follow PCI DSS guidelines
|
|
359
|
+
|
|
360
|
+
### Token Management
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
// ✅ Good: Use tokenized payments
|
|
364
|
+
const paymentToken = await tokenizePayment(cardData);
|
|
365
|
+
await processPayment({ token: paymentToken });
|
|
366
|
+
|
|
367
|
+
// ❌ Bad: Never store raw card data
|
|
368
|
+
// const cardNumber = '4111111111111111'; // Don't do this
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
## 📱 Mobile Optimization
|
|
372
|
+
|
|
373
|
+
### Responsive Design
|
|
374
|
+
|
|
375
|
+
```css
|
|
376
|
+
.checkout-container {
|
|
377
|
+
max-width: 600px;
|
|
378
|
+
margin: 0 auto;
|
|
379
|
+
padding: 16px;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
@media (max-width: 768px) {
|
|
383
|
+
.checkout-container {
|
|
384
|
+
padding: 8px;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.checkout-form {
|
|
388
|
+
font-size: 16px; /* Prevent zoom on iOS */
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Touch Interactions
|
|
394
|
+
|
|
395
|
+
```typescript
|
|
396
|
+
const handleTouchStart = (e) => {
|
|
397
|
+
// Optimize for touch devices
|
|
398
|
+
e.preventDefault();
|
|
399
|
+
// Handle touch interaction
|
|
400
|
+
};
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
## 🌐 Internationalization
|
|
404
|
+
|
|
405
|
+
### Multi-language Support
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
import { useTranslation } from '@tagadapay/plugin-sdk';
|
|
409
|
+
|
|
410
|
+
function CheckoutForm() {
|
|
411
|
+
const { t } = useTranslation();
|
|
412
|
+
|
|
413
|
+
return (
|
|
414
|
+
<form>
|
|
415
|
+
<label>{t('checkout.email')}</label>
|
|
416
|
+
<input type="email" placeholder={t('checkout.email_placeholder')} />
|
|
417
|
+
</form>
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### Currency Support
|
|
423
|
+
|
|
424
|
+
```typescript
|
|
425
|
+
import { useCurrency } from '@tagadapay/plugin-sdk';
|
|
426
|
+
|
|
427
|
+
function PriceDisplay({ amount }) {
|
|
428
|
+
const { formatPrice, currency } = useCurrency();
|
|
429
|
+
|
|
430
|
+
return <span>{formatPrice(amount, currency)}</span>;
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
## 📊 Analytics & Monitoring
|
|
435
|
+
|
|
436
|
+
### Event Tracking
|
|
437
|
+
|
|
438
|
+
```typescript
|
|
439
|
+
import { trackEvent } from '@tagadapay/plugin-sdk';
|
|
440
|
+
|
|
441
|
+
// Track user interactions
|
|
442
|
+
trackEvent('checkout_started', {
|
|
443
|
+
product_id: 'prod_123',
|
|
444
|
+
value: 2999,
|
|
445
|
+
currency: 'USD',
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
// Track conversions
|
|
449
|
+
trackEvent('purchase_completed', {
|
|
450
|
+
transaction_id: 'txn_456',
|
|
451
|
+
value: 2999,
|
|
452
|
+
currency: 'USD',
|
|
453
|
+
});
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### Performance Monitoring
|
|
457
|
+
|
|
458
|
+
```typescript
|
|
459
|
+
import { performance } from '@tagadapay/plugin-sdk';
|
|
460
|
+
|
|
461
|
+
// Measure load times
|
|
462
|
+
performance.mark('checkout-start');
|
|
463
|
+
// ... checkout logic
|
|
464
|
+
performance.mark('checkout-end');
|
|
465
|
+
performance.measure('checkout-duration', 'checkout-start', 'checkout-end');
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
## 🤝 Contributing
|
|
469
|
+
|
|
470
|
+
### Development Setup
|
|
471
|
+
|
|
472
|
+
```bash
|
|
473
|
+
# Clone the repository
|
|
474
|
+
git clone https://github.com/tagadapay/plugin-sdk.git
|
|
475
|
+
|
|
476
|
+
# Install dependencies
|
|
477
|
+
npm install
|
|
478
|
+
|
|
479
|
+
# Start development
|
|
480
|
+
npm run dev
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### Submitting Changes
|
|
484
|
+
|
|
485
|
+
1. Fork the repository
|
|
486
|
+
2. Create a feature branch
|
|
487
|
+
3. Make your changes
|
|
488
|
+
4. Add tests
|
|
489
|
+
5. Submit a pull request
|
|
490
|
+
|
|
491
|
+
## 📄 License
|
|
492
|
+
|
|
493
|
+
MIT License - see [LICENSE](./LICENSE) for details.
|
|
494
|
+
|
|
495
|
+
## 🆘 Support
|
|
496
|
+
|
|
497
|
+
- **Documentation**: [docs.tagadapay.com](https://docs.tagadapay.com)
|
|
498
|
+
- **Discord**: [discord.gg/tagadapay](https://discord.gg/tagadapay)
|
|
499
|
+
- **Email**: support@tagadapay.com
|
|
500
|
+
- **GitHub Issues**: [github.com/tagadapay/plugin-sdk/issues](https://github.com/tagadapay/plugin-sdk/issues)
|
|
501
|
+
|
|
502
|
+
---
|
|
503
|
+
|
|
504
|
+
Built with ❤️ by the TagadaPay team
|