@tagadapay/plugin-sdk 1.0.25 → 1.0.26
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 +414 -414
- package/dist/react/hooks/useAddress.js +19 -19
- package/dist/react/hooks/useCheckout.js +2 -2
- package/dist/react/hooks/usePostPurchases.d.ts +109 -0
- package/dist/react/hooks/usePostPurchases.js +104 -0
- package/dist/react/index.d.ts +16 -14
- package/dist/react/index.js +8 -7
- package/dist/react/providers/TagadaProvider.js +5 -5
- package/package.json +66 -66
package/README.md
CHANGED
|
@@ -1,414 +1,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](./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
|
-
### Examples
|
|
16
|
-
|
|
17
|
-
- **[Vite Checkout Demo](../checkout-vite)** - Complete checkout implementation
|
|
18
|
-
|
|
19
|
-
## 🚀 Quick Start
|
|
20
|
-
|
|
21
|
-
### Installation
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm install @tagadapay/plugin-sdk
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Basic Usage
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import { useCheckout, setCheckoutInfo } from '@tagadapay/plugin-sdk';
|
|
31
|
-
|
|
32
|
-
function CheckoutPage() {
|
|
33
|
-
const { customer, cart, payment } = useCheckout();
|
|
34
|
-
|
|
35
|
-
const handleSubmit = async (data) => {
|
|
36
|
-
await setCheckoutInfo({
|
|
37
|
-
customer: data.customer,
|
|
38
|
-
payment: data.payment
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<div>
|
|
44
|
-
{/* Your checkout UI */}
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## 🎯 Key Features
|
|
51
|
-
|
|
52
|
-
### Payment Processing
|
|
53
|
-
|
|
54
|
-
- Secure tokenized payments
|
|
55
|
-
- Multiple payment method support
|
|
56
|
-
- Real-time validation
|
|
57
|
-
- PCI compliance
|
|
58
|
-
|
|
59
|
-
### Customer Management
|
|
60
|
-
|
|
61
|
-
- Profile management
|
|
62
|
-
- Address validation
|
|
63
|
-
- Order history
|
|
64
|
-
- Preferences
|
|
65
|
-
|
|
66
|
-
### Cart & Pricing
|
|
67
|
-
|
|
68
|
-
- Dynamic pricing
|
|
69
|
-
- Promotional offers
|
|
70
|
-
- Tax calculations
|
|
71
|
-
- Currency conversion
|
|
72
|
-
|
|
73
|
-
### UI Components
|
|
74
|
-
|
|
75
|
-
- Pre-built checkout components
|
|
76
|
-
- Customizable themes
|
|
77
|
-
- Mobile-optimized
|
|
78
|
-
- Accessibility features
|
|
79
|
-
|
|
80
|
-
## 📖 API Reference
|
|
81
|
-
|
|
82
|
-
### Core Hooks
|
|
83
|
-
|
|
84
|
-
#### useCheckout()
|
|
85
|
-
|
|
86
|
-
Primary hook for checkout state management.
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
const {
|
|
90
|
-
customer, // Customer information
|
|
91
|
-
cart, // Shopping cart state
|
|
92
|
-
payment, // Payment details
|
|
93
|
-
shipping, // Shipping information
|
|
94
|
-
loading, // Loading states
|
|
95
|
-
errors, // Error handling
|
|
96
|
-
} = useCheckout();
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
#### useOffers()
|
|
100
|
-
|
|
101
|
-
Hook for managing dynamic offers and pricing.
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
const {
|
|
105
|
-
offers, // Available offers
|
|
106
|
-
applyOffer, // Apply offer function
|
|
107
|
-
removeOffer, // Remove offer function
|
|
108
|
-
total, // Calculated total
|
|
109
|
-
} = useOffers();
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Utility Functions
|
|
113
|
-
|
|
114
|
-
#### setCheckoutInfo()
|
|
115
|
-
|
|
116
|
-
Update checkout information with validation.
|
|
117
|
-
|
|
118
|
-
```typescript
|
|
119
|
-
await setCheckoutInfo({
|
|
120
|
-
customer: {
|
|
121
|
-
email: 'user@example.com',
|
|
122
|
-
firstName: 'John',
|
|
123
|
-
lastName: 'Doe',
|
|
124
|
-
},
|
|
125
|
-
payment: {
|
|
126
|
-
method: 'card',
|
|
127
|
-
token: 'pm_token_123',
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
#### Money utilities
|
|
133
|
-
|
|
134
|
-
Format and calculate monetary values.
|
|
135
|
-
|
|
136
|
-
```typescript
|
|
137
|
-
import { formatMoney, convertCurrency } from '@tagadapay/plugin-sdk';
|
|
138
|
-
|
|
139
|
-
const formatted = formatMoney(2999, 'USD'); // "$29.99"
|
|
140
|
-
const converted = convertCurrency(2999, 'USD', 'EUR'); // 2699
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## 🛠️ Development
|
|
144
|
-
|
|
145
|
-
### Local Development
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
# Install dependencies
|
|
149
|
-
npm install
|
|
150
|
-
|
|
151
|
-
# Start development server
|
|
152
|
-
npm run dev
|
|
153
|
-
|
|
154
|
-
# Build for production
|
|
155
|
-
npm run build
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### Testing
|
|
159
|
-
|
|
160
|
-
```bash
|
|
161
|
-
# Run tests
|
|
162
|
-
npm test
|
|
163
|
-
|
|
164
|
-
# Run tests with coverage
|
|
165
|
-
npm run test:coverage
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### Linting
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
# Check code style
|
|
172
|
-
npm run lint
|
|
173
|
-
|
|
174
|
-
# Fix linting issues
|
|
175
|
-
npm run lint:fix
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
## 📦 Build & Deploy
|
|
179
|
-
|
|
180
|
-
### Building Your Plugin
|
|
181
|
-
|
|
182
|
-
```bash
|
|
183
|
-
# Build optimized bundle
|
|
184
|
-
npm run build
|
|
185
|
-
|
|
186
|
-
# Analyze bundle size
|
|
187
|
-
npm run analyze
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
### Deployment
|
|
191
|
-
|
|
192
|
-
```bash
|
|
193
|
-
# Deploy using TagadaPay CLI
|
|
194
|
-
npx @tagadapay/plugin-cli deploy
|
|
195
|
-
|
|
196
|
-
# Deploy specific environment
|
|
197
|
-
npx @tagadapay/plugin-cli deploy --env production
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
## 🔧 Configuration
|
|
201
|
-
|
|
202
|
-
### Plugin Configuration
|
|
203
|
-
|
|
204
|
-
```json
|
|
205
|
-
{
|
|
206
|
-
"name": "My Checkout Plugin",
|
|
207
|
-
"version": "1.0.0",
|
|
208
|
-
"description": "Custom checkout experience",
|
|
209
|
-
"main": "dist/index.js",
|
|
210
|
-
"tagadapay": {
|
|
211
|
-
"type": "checkout",
|
|
212
|
-
"mode": "direct",
|
|
213
|
-
"framework": "react"
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
### Environment Variables
|
|
219
|
-
|
|
220
|
-
```env
|
|
221
|
-
TAGADAPAY_API_KEY=your_api_key
|
|
222
|
-
TAGADAPAY_ENVIRONMENT=sandbox
|
|
223
|
-
TAGADAPAY_STORE_ID=your_store_id
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
## 🎨 Styling & Themes
|
|
227
|
-
|
|
228
|
-
### CSS Custom Properties
|
|
229
|
-
|
|
230
|
-
```css
|
|
231
|
-
:root {
|
|
232
|
-
--tagada-primary: #007bff;
|
|
233
|
-
--tagada-secondary: #6c757d;
|
|
234
|
-
--tagada-success: #28a745;
|
|
235
|
-
--tagada-danger: #dc3545;
|
|
236
|
-
--tagada-border-radius: 4px;
|
|
237
|
-
--tagada-font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
|
238
|
-
}
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Component Styling
|
|
242
|
-
|
|
243
|
-
```typescript
|
|
244
|
-
import { styled } from '@tagadapay/plugin-sdk';
|
|
245
|
-
|
|
246
|
-
const StyledButton = styled.button`
|
|
247
|
-
background: var(--tagada-primary);
|
|
248
|
-
color: white;
|
|
249
|
-
border-radius: var(--tagada-border-radius);
|
|
250
|
-
padding: 12px 24px;
|
|
251
|
-
border: none;
|
|
252
|
-
cursor: pointer;
|
|
253
|
-
|
|
254
|
-
&:hover {
|
|
255
|
-
opacity: 0.9;
|
|
256
|
-
}
|
|
257
|
-
`;
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
## 🔐 Security
|
|
261
|
-
|
|
262
|
-
### Best Practices
|
|
263
|
-
|
|
264
|
-
- Never store sensitive payment data
|
|
265
|
-
- Always validate user inputs
|
|
266
|
-
- Use HTTPS in production
|
|
267
|
-
- Implement proper error handling
|
|
268
|
-
- Follow PCI DSS guidelines
|
|
269
|
-
|
|
270
|
-
### Token Management
|
|
271
|
-
|
|
272
|
-
```typescript
|
|
273
|
-
// ✅ Good: Use tokenized payments
|
|
274
|
-
const paymentToken = await tokenizePayment(cardData);
|
|
275
|
-
await processPayment({ token: paymentToken });
|
|
276
|
-
|
|
277
|
-
// ❌ Bad: Never store raw card data
|
|
278
|
-
// const cardNumber = '4111111111111111'; // Don't do this
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
## 📱 Mobile Optimization
|
|
282
|
-
|
|
283
|
-
### Responsive Design
|
|
284
|
-
|
|
285
|
-
```css
|
|
286
|
-
.checkout-container {
|
|
287
|
-
max-width: 600px;
|
|
288
|
-
margin: 0 auto;
|
|
289
|
-
padding: 16px;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
@media (max-width: 768px) {
|
|
293
|
-
.checkout-container {
|
|
294
|
-
padding: 8px;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
.checkout-form {
|
|
298
|
-
font-size: 16px; /* Prevent zoom on iOS */
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
### Touch Interactions
|
|
304
|
-
|
|
305
|
-
```typescript
|
|
306
|
-
const handleTouchStart = (e) => {
|
|
307
|
-
// Optimize for touch devices
|
|
308
|
-
e.preventDefault();
|
|
309
|
-
// Handle touch interaction
|
|
310
|
-
};
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
## 🌐 Internationalization
|
|
314
|
-
|
|
315
|
-
### Multi-language Support
|
|
316
|
-
|
|
317
|
-
```typescript
|
|
318
|
-
import { useTranslation } from '@tagadapay/plugin-sdk';
|
|
319
|
-
|
|
320
|
-
function CheckoutForm() {
|
|
321
|
-
const { t } = useTranslation();
|
|
322
|
-
|
|
323
|
-
return (
|
|
324
|
-
<form>
|
|
325
|
-
<label>{t('checkout.email')}</label>
|
|
326
|
-
<input type="email" placeholder={t('checkout.email_placeholder')} />
|
|
327
|
-
</form>
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
### Currency Support
|
|
333
|
-
|
|
334
|
-
```typescript
|
|
335
|
-
import { useCurrency } from '@tagadapay/plugin-sdk';
|
|
336
|
-
|
|
337
|
-
function PriceDisplay({ amount }) {
|
|
338
|
-
const { formatPrice, currency } = useCurrency();
|
|
339
|
-
|
|
340
|
-
return <span>{formatPrice(amount, currency)}</span>;
|
|
341
|
-
}
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
## 📊 Analytics & Monitoring
|
|
345
|
-
|
|
346
|
-
### Event Tracking
|
|
347
|
-
|
|
348
|
-
```typescript
|
|
349
|
-
import { trackEvent } from '@tagadapay/plugin-sdk';
|
|
350
|
-
|
|
351
|
-
// Track user interactions
|
|
352
|
-
trackEvent('checkout_started', {
|
|
353
|
-
product_id: 'prod_123',
|
|
354
|
-
value: 2999,
|
|
355
|
-
currency: 'USD',
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
// Track conversions
|
|
359
|
-
trackEvent('purchase_completed', {
|
|
360
|
-
transaction_id: 'txn_456',
|
|
361
|
-
value: 2999,
|
|
362
|
-
currency: 'USD',
|
|
363
|
-
});
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
### Performance Monitoring
|
|
367
|
-
|
|
368
|
-
```typescript
|
|
369
|
-
import { performance } from '@tagadapay/plugin-sdk';
|
|
370
|
-
|
|
371
|
-
// Measure load times
|
|
372
|
-
performance.mark('checkout-start');
|
|
373
|
-
// ... checkout logic
|
|
374
|
-
performance.mark('checkout-end');
|
|
375
|
-
performance.measure('checkout-duration', 'checkout-start', 'checkout-end');
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
## 🤝 Contributing
|
|
379
|
-
|
|
380
|
-
### Development Setup
|
|
381
|
-
|
|
382
|
-
```bash
|
|
383
|
-
# Clone the repository
|
|
384
|
-
git clone https://github.com/tagadapay/plugin-sdk.git
|
|
385
|
-
|
|
386
|
-
# Install dependencies
|
|
387
|
-
npm install
|
|
388
|
-
|
|
389
|
-
# Start development
|
|
390
|
-
npm run dev
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
### Submitting Changes
|
|
394
|
-
|
|
395
|
-
1. Fork the repository
|
|
396
|
-
2. Create a feature branch
|
|
397
|
-
3. Make your changes
|
|
398
|
-
4. Add tests
|
|
399
|
-
5. Submit a pull request
|
|
400
|
-
|
|
401
|
-
## 📄 License
|
|
402
|
-
|
|
403
|
-
MIT License - see [LICENSE](./LICENSE) for details.
|
|
404
|
-
|
|
405
|
-
## 🆘 Support
|
|
406
|
-
|
|
407
|
-
- **Documentation**: [docs.tagadapay.com](https://docs.tagadapay.com)
|
|
408
|
-
- **Discord**: [discord.gg/tagadapay](https://discord.gg/tagadapay)
|
|
409
|
-
- **Email**: support@tagadapay.com
|
|
410
|
-
- **GitHub Issues**: [github.com/tagadapay/plugin-sdk/issues](https://github.com/tagadapay/plugin-sdk/issues)
|
|
411
|
-
|
|
412
|
-
---
|
|
413
|
-
|
|
414
|
-
Built with ❤️ by the TagadaPay team
|
|
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
|
+
### Examples
|
|
16
|
+
|
|
17
|
+
- **[Vite Checkout Demo](../checkout-vite)** - Complete checkout implementation
|
|
18
|
+
|
|
19
|
+
## 🚀 Quick Start
|
|
20
|
+
|
|
21
|
+
### Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @tagadapay/plugin-sdk
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Basic Usage
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { useCheckout, setCheckoutInfo } from '@tagadapay/plugin-sdk';
|
|
31
|
+
|
|
32
|
+
function CheckoutPage() {
|
|
33
|
+
const { customer, cart, payment } = useCheckout();
|
|
34
|
+
|
|
35
|
+
const handleSubmit = async (data) => {
|
|
36
|
+
await setCheckoutInfo({
|
|
37
|
+
customer: data.customer,
|
|
38
|
+
payment: data.payment
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div>
|
|
44
|
+
{/* Your checkout UI */}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 🎯 Key Features
|
|
51
|
+
|
|
52
|
+
### Payment Processing
|
|
53
|
+
|
|
54
|
+
- Secure tokenized payments
|
|
55
|
+
- Multiple payment method support
|
|
56
|
+
- Real-time validation
|
|
57
|
+
- PCI compliance
|
|
58
|
+
|
|
59
|
+
### Customer Management
|
|
60
|
+
|
|
61
|
+
- Profile management
|
|
62
|
+
- Address validation
|
|
63
|
+
- Order history
|
|
64
|
+
- Preferences
|
|
65
|
+
|
|
66
|
+
### Cart & Pricing
|
|
67
|
+
|
|
68
|
+
- Dynamic pricing
|
|
69
|
+
- Promotional offers
|
|
70
|
+
- Tax calculations
|
|
71
|
+
- Currency conversion
|
|
72
|
+
|
|
73
|
+
### UI Components
|
|
74
|
+
|
|
75
|
+
- Pre-built checkout components
|
|
76
|
+
- Customizable themes
|
|
77
|
+
- Mobile-optimized
|
|
78
|
+
- Accessibility features
|
|
79
|
+
|
|
80
|
+
## 📖 API Reference
|
|
81
|
+
|
|
82
|
+
### Core Hooks
|
|
83
|
+
|
|
84
|
+
#### useCheckout()
|
|
85
|
+
|
|
86
|
+
Primary hook for checkout state management.
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
const {
|
|
90
|
+
customer, // Customer information
|
|
91
|
+
cart, // Shopping cart state
|
|
92
|
+
payment, // Payment details
|
|
93
|
+
shipping, // Shipping information
|
|
94
|
+
loading, // Loading states
|
|
95
|
+
errors, // Error handling
|
|
96
|
+
} = useCheckout();
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### useOffers()
|
|
100
|
+
|
|
101
|
+
Hook for managing dynamic offers and pricing.
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
const {
|
|
105
|
+
offers, // Available offers
|
|
106
|
+
applyOffer, // Apply offer function
|
|
107
|
+
removeOffer, // Remove offer function
|
|
108
|
+
total, // Calculated total
|
|
109
|
+
} = useOffers();
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Utility Functions
|
|
113
|
+
|
|
114
|
+
#### setCheckoutInfo()
|
|
115
|
+
|
|
116
|
+
Update checkout information with validation.
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
await setCheckoutInfo({
|
|
120
|
+
customer: {
|
|
121
|
+
email: 'user@example.com',
|
|
122
|
+
firstName: 'John',
|
|
123
|
+
lastName: 'Doe',
|
|
124
|
+
},
|
|
125
|
+
payment: {
|
|
126
|
+
method: 'card',
|
|
127
|
+
token: 'pm_token_123',
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### Money utilities
|
|
133
|
+
|
|
134
|
+
Format and calculate monetary values.
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import { formatMoney, convertCurrency } from '@tagadapay/plugin-sdk';
|
|
138
|
+
|
|
139
|
+
const formatted = formatMoney(2999, 'USD'); // "$29.99"
|
|
140
|
+
const converted = convertCurrency(2999, 'USD', 'EUR'); // 2699
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## 🛠️ Development
|
|
144
|
+
|
|
145
|
+
### Local Development
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Install dependencies
|
|
149
|
+
npm install
|
|
150
|
+
|
|
151
|
+
# Start development server
|
|
152
|
+
npm run dev
|
|
153
|
+
|
|
154
|
+
# Build for production
|
|
155
|
+
npm run build
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Testing
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Run tests
|
|
162
|
+
npm test
|
|
163
|
+
|
|
164
|
+
# Run tests with coverage
|
|
165
|
+
npm run test:coverage
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Linting
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Check code style
|
|
172
|
+
npm run lint
|
|
173
|
+
|
|
174
|
+
# Fix linting issues
|
|
175
|
+
npm run lint:fix
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## 📦 Build & Deploy
|
|
179
|
+
|
|
180
|
+
### Building Your Plugin
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Build optimized bundle
|
|
184
|
+
npm run build
|
|
185
|
+
|
|
186
|
+
# Analyze bundle size
|
|
187
|
+
npm run analyze
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Deployment
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Deploy using TagadaPay CLI
|
|
194
|
+
npx @tagadapay/plugin-cli deploy
|
|
195
|
+
|
|
196
|
+
# Deploy specific environment
|
|
197
|
+
npx @tagadapay/plugin-cli deploy --env production
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## 🔧 Configuration
|
|
201
|
+
|
|
202
|
+
### Plugin Configuration
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"name": "My Checkout Plugin",
|
|
207
|
+
"version": "1.0.0",
|
|
208
|
+
"description": "Custom checkout experience",
|
|
209
|
+
"main": "dist/index.js",
|
|
210
|
+
"tagadapay": {
|
|
211
|
+
"type": "checkout",
|
|
212
|
+
"mode": "direct",
|
|
213
|
+
"framework": "react"
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Environment Variables
|
|
219
|
+
|
|
220
|
+
```env
|
|
221
|
+
TAGADAPAY_API_KEY=your_api_key
|
|
222
|
+
TAGADAPAY_ENVIRONMENT=sandbox
|
|
223
|
+
TAGADAPAY_STORE_ID=your_store_id
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## 🎨 Styling & Themes
|
|
227
|
+
|
|
228
|
+
### CSS Custom Properties
|
|
229
|
+
|
|
230
|
+
```css
|
|
231
|
+
:root {
|
|
232
|
+
--tagada-primary: #007bff;
|
|
233
|
+
--tagada-secondary: #6c757d;
|
|
234
|
+
--tagada-success: #28a745;
|
|
235
|
+
--tagada-danger: #dc3545;
|
|
236
|
+
--tagada-border-radius: 4px;
|
|
237
|
+
--tagada-font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Component Styling
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
import { styled } from '@tagadapay/plugin-sdk';
|
|
245
|
+
|
|
246
|
+
const StyledButton = styled.button`
|
|
247
|
+
background: var(--tagada-primary);
|
|
248
|
+
color: white;
|
|
249
|
+
border-radius: var(--tagada-border-radius);
|
|
250
|
+
padding: 12px 24px;
|
|
251
|
+
border: none;
|
|
252
|
+
cursor: pointer;
|
|
253
|
+
|
|
254
|
+
&:hover {
|
|
255
|
+
opacity: 0.9;
|
|
256
|
+
}
|
|
257
|
+
`;
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## 🔐 Security
|
|
261
|
+
|
|
262
|
+
### Best Practices
|
|
263
|
+
|
|
264
|
+
- Never store sensitive payment data
|
|
265
|
+
- Always validate user inputs
|
|
266
|
+
- Use HTTPS in production
|
|
267
|
+
- Implement proper error handling
|
|
268
|
+
- Follow PCI DSS guidelines
|
|
269
|
+
|
|
270
|
+
### Token Management
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
// ✅ Good: Use tokenized payments
|
|
274
|
+
const paymentToken = await tokenizePayment(cardData);
|
|
275
|
+
await processPayment({ token: paymentToken });
|
|
276
|
+
|
|
277
|
+
// ❌ Bad: Never store raw card data
|
|
278
|
+
// const cardNumber = '4111111111111111'; // Don't do this
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## 📱 Mobile Optimization
|
|
282
|
+
|
|
283
|
+
### Responsive Design
|
|
284
|
+
|
|
285
|
+
```css
|
|
286
|
+
.checkout-container {
|
|
287
|
+
max-width: 600px;
|
|
288
|
+
margin: 0 auto;
|
|
289
|
+
padding: 16px;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
@media (max-width: 768px) {
|
|
293
|
+
.checkout-container {
|
|
294
|
+
padding: 8px;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.checkout-form {
|
|
298
|
+
font-size: 16px; /* Prevent zoom on iOS */
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Touch Interactions
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
const handleTouchStart = (e) => {
|
|
307
|
+
// Optimize for touch devices
|
|
308
|
+
e.preventDefault();
|
|
309
|
+
// Handle touch interaction
|
|
310
|
+
};
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## 🌐 Internationalization
|
|
314
|
+
|
|
315
|
+
### Multi-language Support
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
import { useTranslation } from '@tagadapay/plugin-sdk';
|
|
319
|
+
|
|
320
|
+
function CheckoutForm() {
|
|
321
|
+
const { t } = useTranslation();
|
|
322
|
+
|
|
323
|
+
return (
|
|
324
|
+
<form>
|
|
325
|
+
<label>{t('checkout.email')}</label>
|
|
326
|
+
<input type="email" placeholder={t('checkout.email_placeholder')} />
|
|
327
|
+
</form>
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Currency Support
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
import { useCurrency } from '@tagadapay/plugin-sdk';
|
|
336
|
+
|
|
337
|
+
function PriceDisplay({ amount }) {
|
|
338
|
+
const { formatPrice, currency } = useCurrency();
|
|
339
|
+
|
|
340
|
+
return <span>{formatPrice(amount, currency)}</span>;
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
## 📊 Analytics & Monitoring
|
|
345
|
+
|
|
346
|
+
### Event Tracking
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
import { trackEvent } from '@tagadapay/plugin-sdk';
|
|
350
|
+
|
|
351
|
+
// Track user interactions
|
|
352
|
+
trackEvent('checkout_started', {
|
|
353
|
+
product_id: 'prod_123',
|
|
354
|
+
value: 2999,
|
|
355
|
+
currency: 'USD',
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// Track conversions
|
|
359
|
+
trackEvent('purchase_completed', {
|
|
360
|
+
transaction_id: 'txn_456',
|
|
361
|
+
value: 2999,
|
|
362
|
+
currency: 'USD',
|
|
363
|
+
});
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### Performance Monitoring
|
|
367
|
+
|
|
368
|
+
```typescript
|
|
369
|
+
import { performance } from '@tagadapay/plugin-sdk';
|
|
370
|
+
|
|
371
|
+
// Measure load times
|
|
372
|
+
performance.mark('checkout-start');
|
|
373
|
+
// ... checkout logic
|
|
374
|
+
performance.mark('checkout-end');
|
|
375
|
+
performance.measure('checkout-duration', 'checkout-start', 'checkout-end');
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## 🤝 Contributing
|
|
379
|
+
|
|
380
|
+
### Development Setup
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
# Clone the repository
|
|
384
|
+
git clone https://github.com/tagadapay/plugin-sdk.git
|
|
385
|
+
|
|
386
|
+
# Install dependencies
|
|
387
|
+
npm install
|
|
388
|
+
|
|
389
|
+
# Start development
|
|
390
|
+
npm run dev
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Submitting Changes
|
|
394
|
+
|
|
395
|
+
1. Fork the repository
|
|
396
|
+
2. Create a feature branch
|
|
397
|
+
3. Make your changes
|
|
398
|
+
4. Add tests
|
|
399
|
+
5. Submit a pull request
|
|
400
|
+
|
|
401
|
+
## 📄 License
|
|
402
|
+
|
|
403
|
+
MIT License - see [LICENSE](./LICENSE) for details.
|
|
404
|
+
|
|
405
|
+
## 🆘 Support
|
|
406
|
+
|
|
407
|
+
- **Documentation**: [docs.tagadapay.com](https://docs.tagadapay.com)
|
|
408
|
+
- **Discord**: [discord.gg/tagadapay](https://discord.gg/tagadapay)
|
|
409
|
+
- **Email**: support@tagadapay.com
|
|
410
|
+
- **GitHub Issues**: [github.com/tagadapay/plugin-sdk/issues](https://github.com/tagadapay/plugin-sdk/issues)
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
Built with ❤️ by the TagadaPay team
|
|
@@ -277,25 +277,25 @@ export function useAddress(options = {}) {
|
|
|
277
277
|
// Custom styles for Google Places dropdown
|
|
278
278
|
useEffect(() => {
|
|
279
279
|
if (enableGooglePlaces && !document.getElementById('google-places-custom-styles')) {
|
|
280
|
-
const autocompleteStyles = `
|
|
281
|
-
.pac-container {
|
|
282
|
-
border-radius: 8px;
|
|
283
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
284
|
-
border: 1px solid #e2e8f0;
|
|
285
|
-
margin-top: 4px;
|
|
286
|
-
font-family: inherit;
|
|
287
|
-
z-index: 9999;
|
|
288
|
-
}
|
|
289
|
-
.pac-item {
|
|
290
|
-
padding: 10px 12px;
|
|
291
|
-
font-size: 14px;
|
|
292
|
-
cursor: pointer;
|
|
293
|
-
border-top: 1px solid #f3f4f6;
|
|
294
|
-
}
|
|
295
|
-
.pac-item:first-child { border-top: none; }
|
|
296
|
-
.pac-item:hover { background-color: #f8fafc; }
|
|
297
|
-
.pac-item-selected, .pac-item-selected:hover { background-color: #eef2ff; }
|
|
298
|
-
.pac-matched { font-weight: 600; }
|
|
280
|
+
const autocompleteStyles = `
|
|
281
|
+
.pac-container {
|
|
282
|
+
border-radius: 8px;
|
|
283
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
284
|
+
border: 1px solid #e2e8f0;
|
|
285
|
+
margin-top: 4px;
|
|
286
|
+
font-family: inherit;
|
|
287
|
+
z-index: 9999;
|
|
288
|
+
}
|
|
289
|
+
.pac-item {
|
|
290
|
+
padding: 10px 12px;
|
|
291
|
+
font-size: 14px;
|
|
292
|
+
cursor: pointer;
|
|
293
|
+
border-top: 1px solid #f3f4f6;
|
|
294
|
+
}
|
|
295
|
+
.pac-item:first-child { border-top: none; }
|
|
296
|
+
.pac-item:hover { background-color: #f8fafc; }
|
|
297
|
+
.pac-item-selected, .pac-item-selected:hover { background-color: #eef2ff; }
|
|
298
|
+
.pac-matched { font-weight: 600; }
|
|
299
299
|
`;
|
|
300
300
|
const styleElement = document.createElement('style');
|
|
301
301
|
styleElement.id = 'google-places-custom-styles';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useCurrency } from '../hooks/useCurrency';
|
|
2
3
|
import { useTagadaContext } from '../providers/TagadaProvider';
|
|
3
4
|
import { getCheckoutToken } from '../utils/urlUtils';
|
|
4
|
-
import { useCurrency } from '../hooks/useCurrency';
|
|
5
5
|
export function useCheckout(options = {}) {
|
|
6
6
|
const { apiService, updateCheckoutDebugData, refreshCoordinator, store, currency } = useTagadaContext();
|
|
7
7
|
const { code: currentCurrency } = useCurrency();
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export interface PostPurchaseOfferItem {
|
|
2
|
+
id: string;
|
|
3
|
+
productId: string;
|
|
4
|
+
variantId: string;
|
|
5
|
+
product: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
};
|
|
9
|
+
variant: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
imageUrl: string;
|
|
13
|
+
grams: number | null;
|
|
14
|
+
};
|
|
15
|
+
unitAmount: number;
|
|
16
|
+
quantity: number;
|
|
17
|
+
amount: number;
|
|
18
|
+
adjustedAmount: number;
|
|
19
|
+
}
|
|
20
|
+
export interface PostPurchaseOfferSummary {
|
|
21
|
+
currency: string;
|
|
22
|
+
totalAmount: number;
|
|
23
|
+
totalAdjustedAmount: number;
|
|
24
|
+
items: PostPurchaseOfferItem[];
|
|
25
|
+
}
|
|
26
|
+
export interface PostPurchaseOfferLineItem {
|
|
27
|
+
id: string;
|
|
28
|
+
quantity: number;
|
|
29
|
+
price: {
|
|
30
|
+
variant: {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
description: string | null;
|
|
34
|
+
grams: number | null;
|
|
35
|
+
product: {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface PostPurchaseOffer {
|
|
44
|
+
id: string;
|
|
45
|
+
titleTrans: Record<string, string> | null;
|
|
46
|
+
summaries: PostPurchaseOfferSummary[];
|
|
47
|
+
offerLineItems: PostPurchaseOfferLineItem[];
|
|
48
|
+
}
|
|
49
|
+
export interface UsePostPurchasesOptions {
|
|
50
|
+
/**
|
|
51
|
+
* OrderID to fetch post-purchase offers for
|
|
52
|
+
*/
|
|
53
|
+
orderId: string;
|
|
54
|
+
/**
|
|
55
|
+
* Whether to fetch offers automatically on mount
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
enabled?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface UsePostPurchasesResult {
|
|
61
|
+
/**
|
|
62
|
+
* Array of fetched post-purchase offers
|
|
63
|
+
*/
|
|
64
|
+
offers: PostPurchaseOffer[];
|
|
65
|
+
/**
|
|
66
|
+
* Loading state
|
|
67
|
+
*/
|
|
68
|
+
isLoading: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Error state
|
|
71
|
+
*/
|
|
72
|
+
error: Error | null;
|
|
73
|
+
/**
|
|
74
|
+
* Refetch post-purchase offers
|
|
75
|
+
*/
|
|
76
|
+
refetch: () => Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Get offer by ID from the loaded offers
|
|
79
|
+
*/
|
|
80
|
+
getOffer: (offerId: string) => PostPurchaseOffer | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Get total value of all post-purchase offers
|
|
83
|
+
*/
|
|
84
|
+
getTotalValue: () => number;
|
|
85
|
+
/**
|
|
86
|
+
* Get total savings across all post-purchase offers
|
|
87
|
+
*/
|
|
88
|
+
getTotalSavings: () => number;
|
|
89
|
+
/**
|
|
90
|
+
* Initialize a checkout session for a post-purchase offer
|
|
91
|
+
*/
|
|
92
|
+
initCheckoutSession: (offerId: string, orderId: string) => Promise<{
|
|
93
|
+
checkoutSessionId: string;
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Initialize a checkout session for a post-purchase offer with specific variants
|
|
97
|
+
*/
|
|
98
|
+
initCheckoutSessionWithVariants: (offerId: string, orderId: string, lineItems: Array<{
|
|
99
|
+
variantId: string;
|
|
100
|
+
quantity: number;
|
|
101
|
+
}>) => Promise<{
|
|
102
|
+
checkoutSessionId: string;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Pay with a checkout session for a post-purchase offer
|
|
106
|
+
*/
|
|
107
|
+
payWithCheckoutSession: (checkoutSessionId: string, orderId?: string) => Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
export declare function usePostPurchases(options: UsePostPurchasesOptions): UsePostPurchasesResult;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { useTagadaContext } from '../providers/TagadaProvider';
|
|
3
|
+
export function usePostPurchases(options) {
|
|
4
|
+
const { apiService } = useTagadaContext();
|
|
5
|
+
const { orderId, enabled = true } = options;
|
|
6
|
+
const [offers, setOffers] = useState([]);
|
|
7
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
8
|
+
const [error, setError] = useState(null);
|
|
9
|
+
const fetchOffers = useCallback(async () => {
|
|
10
|
+
if (!orderId) {
|
|
11
|
+
setOffers([]);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
setIsLoading(true);
|
|
15
|
+
setError(null);
|
|
16
|
+
try {
|
|
17
|
+
const response = await apiService.fetch(`/api/v1/post-purchase/${orderId}/offers`, {
|
|
18
|
+
method: 'GET',
|
|
19
|
+
});
|
|
20
|
+
setOffers(response || []);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
const error = err instanceof Error ? err : new Error('Failed to fetch post-purchase offers');
|
|
24
|
+
setError(error);
|
|
25
|
+
console.error('[SDK] Failed to fetch post-purchase offers:', error);
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
setIsLoading(false);
|
|
29
|
+
}
|
|
30
|
+
}, [orderId]);
|
|
31
|
+
const initCheckoutSession = useCallback(async (offerId, orderId) => {
|
|
32
|
+
const response = await apiService.fetch(`/api/v1/checkout/offer/init`, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
body: JSON.stringify({
|
|
35
|
+
offerId: offerId,
|
|
36
|
+
returnUrl: window.location.href,
|
|
37
|
+
customerId: '',
|
|
38
|
+
orderId,
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
return response;
|
|
42
|
+
}, []);
|
|
43
|
+
const initCheckoutSessionWithVariants = useCallback(async (offerId, orderId, lineItems) => {
|
|
44
|
+
const response = await apiService.fetch(`/api/v1/offers/${offerId}/transform-to-checkout`, {
|
|
45
|
+
method: 'POST',
|
|
46
|
+
body: JSON.stringify({
|
|
47
|
+
offerId: offerId,
|
|
48
|
+
lineItems: lineItems,
|
|
49
|
+
returnUrl: window.location.href,
|
|
50
|
+
mainOrderId: orderId,
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
return response;
|
|
54
|
+
}, []);
|
|
55
|
+
const payWithCheckoutSession = useCallback(async (checkoutSessionId, orderId) => {
|
|
56
|
+
const response = await apiService.fetch(`/api/v1/checkout-sessions/${checkoutSessionId}/pay`, {
|
|
57
|
+
method: 'POST',
|
|
58
|
+
body: JSON.stringify({
|
|
59
|
+
checkoutSessionId,
|
|
60
|
+
metadata: {
|
|
61
|
+
comingFromPostPurchase: true,
|
|
62
|
+
postOrder: orderId,
|
|
63
|
+
},
|
|
64
|
+
}),
|
|
65
|
+
});
|
|
66
|
+
return response;
|
|
67
|
+
}, []);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (enabled && orderId) {
|
|
70
|
+
fetchOffers();
|
|
71
|
+
}
|
|
72
|
+
}, [enabled, orderId, fetchOffers]);
|
|
73
|
+
const getOffer = useCallback((offerId) => {
|
|
74
|
+
return offers.find((offer) => offer.id === offerId);
|
|
75
|
+
}, [offers]);
|
|
76
|
+
const getTotalValue = useCallback(() => {
|
|
77
|
+
return offers.reduce((total, offer) => {
|
|
78
|
+
return (total +
|
|
79
|
+
offer.summaries.reduce((summaryTotal, summary) => {
|
|
80
|
+
return summaryTotal + summary.totalAmount;
|
|
81
|
+
}, 0));
|
|
82
|
+
}, 0);
|
|
83
|
+
}, [offers]);
|
|
84
|
+
const getTotalSavings = useCallback(() => {
|
|
85
|
+
return offers.reduce((total, offer) => {
|
|
86
|
+
return (total +
|
|
87
|
+
offer.summaries.reduce((summaryTotal, summary) => {
|
|
88
|
+
return summaryTotal + (summary.totalAmount - summary.totalAdjustedAmount);
|
|
89
|
+
}, 0));
|
|
90
|
+
}, 0);
|
|
91
|
+
}, [offers]);
|
|
92
|
+
return {
|
|
93
|
+
offers,
|
|
94
|
+
isLoading,
|
|
95
|
+
error,
|
|
96
|
+
refetch: fetchOffers,
|
|
97
|
+
getOffer,
|
|
98
|
+
getTotalValue,
|
|
99
|
+
getTotalSavings,
|
|
100
|
+
initCheckoutSession,
|
|
101
|
+
initCheckoutSessionWithVariants,
|
|
102
|
+
payWithCheckoutSession,
|
|
103
|
+
};
|
|
104
|
+
}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -2,28 +2,30 @@
|
|
|
2
2
|
* React SDK exports
|
|
3
3
|
*/
|
|
4
4
|
export { TagadaProvider } from './providers/TagadaProvider';
|
|
5
|
+
export { useAddress } from './hooks/useAddress';
|
|
6
|
+
export { useAuth } from './hooks/useAuth';
|
|
5
7
|
export { useCheckout } from './hooks/useCheckout';
|
|
6
|
-
export { useProducts } from './hooks/useProducts';
|
|
7
|
-
export { useOffers } from './hooks/useOffers';
|
|
8
|
-
export { useOrderBump } from './hooks/useOrderBump';
|
|
9
|
-
export { useSession } from './hooks/useSession';
|
|
10
8
|
export { useCurrency } from './hooks/useCurrency';
|
|
11
9
|
export { useCustomer } from './hooks/useCustomer';
|
|
12
10
|
export { useEnvironment } from './hooks/useEnvironment';
|
|
13
11
|
export { useLocale } from './hooks/useLocale';
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
12
|
+
export { useOffers } from './hooks/useOffers';
|
|
13
|
+
export { useOrderBump } from './hooks/useOrderBump';
|
|
14
|
+
export { usePostPurchases } from './hooks/usePostPurchases';
|
|
15
|
+
export { useProducts } from './hooks/useProducts';
|
|
16
|
+
export { useSession } from './hooks/useSession';
|
|
16
17
|
export { useOrder } from './hooks/useOrder';
|
|
17
18
|
export type { UseOrderOptions, UseOrderResult } from './hooks/useOrder';
|
|
18
19
|
export { usePayment } from './hooks/usePayment';
|
|
19
20
|
export { usePaymentPolling } from './hooks/usePaymentPolling';
|
|
20
21
|
export { useThreeds } from './hooks/useThreeds';
|
|
21
22
|
export { useThreedsModal } from './hooks/useThreedsModal';
|
|
22
|
-
export type {
|
|
23
|
-
export type {
|
|
24
|
-
export type { UseOrderBumpOptions, UseOrderBumpResult
|
|
25
|
-
export type {
|
|
26
|
-
export type {
|
|
27
|
-
export type {
|
|
28
|
-
export type {
|
|
29
|
-
export {
|
|
23
|
+
export type { AuthState, Currency, Customer, Environment, EnvironmentConfig, Locale, Order, OrderAddress, OrderItem, OrderSummary, PickupPoint, Session, Store, } from './types';
|
|
24
|
+
export type { CheckoutData, CheckoutInitParams, CheckoutLineItem, CheckoutSession, Promotion, UseCheckoutOptions, UseCheckoutResult, } from './hooks/useCheckout';
|
|
25
|
+
export type { OrderBumpPreview, UseOrderBumpOptions, UseOrderBumpResult } from './hooks/useOrderBump';
|
|
26
|
+
export type { PostPurchaseOffer, PostPurchaseOfferItem, PostPurchaseOfferLineItem, PostPurchaseOfferSummary, UsePostPurchasesOptions, UsePostPurchasesResult, } from './hooks/usePostPurchases';
|
|
27
|
+
export type { AddressData, AddressField, Country, State, UseAddressOptions, UseAddressResult, } from './hooks/useAddress';
|
|
28
|
+
export type { Payment, PaymentPollingHook, PollingOptions } from './hooks/usePaymentPolling';
|
|
29
|
+
export type { PaymentInstrument, ThreedsChallenge, ThreedsHook, ThreedsOptions, ThreedsProvider, ThreedsSession, } from './hooks/useThreeds';
|
|
30
|
+
export type { ApplePayToken, CardPaymentMethod, PaymentHook, PaymentInstrumentResponse, PaymentOptions, PaymentResponse, } from './hooks/usePayment';
|
|
31
|
+
export { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits, } from './utils/money';
|
package/dist/react/index.js
CHANGED
|
@@ -5,17 +5,18 @@
|
|
|
5
5
|
// Provider exports
|
|
6
6
|
export { TagadaProvider } from './providers/TagadaProvider';
|
|
7
7
|
// Hook exports
|
|
8
|
+
export { useAddress } from './hooks/useAddress';
|
|
9
|
+
export { useAuth } from './hooks/useAuth';
|
|
8
10
|
export { useCheckout } from './hooks/useCheckout';
|
|
9
|
-
export { useProducts } from './hooks/useProducts';
|
|
10
|
-
export { useOffers } from './hooks/useOffers';
|
|
11
|
-
export { useOrderBump } from './hooks/useOrderBump';
|
|
12
|
-
export { useSession } from './hooks/useSession';
|
|
13
11
|
export { useCurrency } from './hooks/useCurrency';
|
|
14
12
|
export { useCustomer } from './hooks/useCustomer';
|
|
15
13
|
export { useEnvironment } from './hooks/useEnvironment';
|
|
16
14
|
export { useLocale } from './hooks/useLocale';
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
15
|
+
export { useOffers } from './hooks/useOffers';
|
|
16
|
+
export { useOrderBump } from './hooks/useOrderBump';
|
|
17
|
+
export { usePostPurchases } from './hooks/usePostPurchases';
|
|
18
|
+
export { useProducts } from './hooks/useProducts';
|
|
19
|
+
export { useSession } from './hooks/useSession';
|
|
19
20
|
// Order hook exports
|
|
20
21
|
export { useOrder } from './hooks/useOrder';
|
|
21
22
|
// Payment hooks exports
|
|
@@ -26,4 +27,4 @@ export { useThreedsModal } from './hooks/useThreedsModal';
|
|
|
26
27
|
// Component exports (if any)
|
|
27
28
|
// export { SomeComponent } from './components/SomeComponent';
|
|
28
29
|
// Utility exports
|
|
29
|
-
export { formatMoney, formatMoneyWithoutSymbol, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits,
|
|
30
|
+
export { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits, } from './utils/money';
|
|
@@ -22,11 +22,11 @@ const InitializationLoader = () => (_jsx("div", { style: {
|
|
|
22
22
|
backgroundSize: '200% 100%',
|
|
23
23
|
animation: 'tagada-loading 1.5s ease-in-out infinite',
|
|
24
24
|
zIndex: 9999,
|
|
25
|
-
}, children: _jsx("style", { children: `
|
|
26
|
-
@keyframes tagada-loading {
|
|
27
|
-
0% { background-position: 200% 0; }
|
|
28
|
-
100% { background-position: -200% 0; }
|
|
29
|
-
}
|
|
25
|
+
}, children: _jsx("style", { children: `
|
|
26
|
+
@keyframes tagada-loading {
|
|
27
|
+
0% { background-position: 200% 0; }
|
|
28
|
+
100% { background-position: -200% 0; }
|
|
29
|
+
}
|
|
30
30
|
` }) }));
|
|
31
31
|
const TagadaContext = createContext(null);
|
|
32
32
|
export function TagadaProvider({ children, environment, customApiConfig, debugMode, // Remove default, will be set based on environment
|
package/package.json
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tagadapay/plugin-sdk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Modern React SDK for building Tagada Pay plugins",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsc",
|
|
9
|
-
"clean": "rm -rf dist",
|
|
10
|
-
"lint": "echo \"No linting configured\"",
|
|
11
|
-
"test": "echo \"No tests yet\" && exit 0",
|
|
12
|
-
"dev": "tsc --watch",
|
|
13
|
-
"prepublishOnly": "npm run clean && npm run build",
|
|
14
|
-
"publish:patch": "npm version patch && npm publish",
|
|
15
|
-
"publish:minor": "npm version minor && npm publish",
|
|
16
|
-
"publish:major": "npm version major && npm publish",
|
|
17
|
-
"publish:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
|
|
18
|
-
"publish:alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
|
|
19
|
-
"version:patch": "npm version patch",
|
|
20
|
-
"version:minor": "npm version minor",
|
|
21
|
-
"version:major": "npm version major",
|
|
22
|
-
"version:beta": "npm version prerelease --preid=beta",
|
|
23
|
-
"version:alpha": "npm version prerelease --preid=alpha"
|
|
24
|
-
},
|
|
25
|
-
"keywords": [
|
|
26
|
-
"tagadapay",
|
|
27
|
-
"cms",
|
|
28
|
-
"plugin",
|
|
29
|
-
"sdk",
|
|
30
|
-
"react",
|
|
31
|
-
"typescript"
|
|
32
|
-
],
|
|
33
|
-
"author": "Tagada Pay",
|
|
34
|
-
"license": "MIT",
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"@basis-theory/apple-pay-js": "^2.0.2",
|
|
37
|
-
"@basis-theory/basis-theory-js": "^4.30.0",
|
|
38
|
-
"@basis-theory/basis-theory-react": "^1.32.5",
|
|
39
|
-
"@basis-theory/web-threeds": "^1.0.1",
|
|
40
|
-
"axios": "^1.6.0",
|
|
41
|
-
"react-google-autocomplete": "^2.7.3",
|
|
42
|
-
"react-intl": "^7.1.11"
|
|
43
|
-
},
|
|
44
|
-
"devDependencies": {
|
|
45
|
-
"@types/node": "^18.0.0",
|
|
46
|
-
"@types/react": "^19",
|
|
47
|
-
"@types/react-dom": "^19",
|
|
48
|
-
"typescript": "^5.0.0"
|
|
49
|
-
},
|
|
50
|
-
"peerDependencies": {
|
|
51
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
52
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
53
|
-
},
|
|
54
|
-
"files": [
|
|
55
|
-
"dist/**/*",
|
|
56
|
-
"README.md"
|
|
57
|
-
],
|
|
58
|
-
"repository": {
|
|
59
|
-
"type": "git",
|
|
60
|
-
"url": "git+https://github.com/tagadapay/plugin-sdk.git"
|
|
61
|
-
},
|
|
62
|
-
"bugs": {
|
|
63
|
-
"url": "https://github.com/tagadapay/plugin-sdk/issues"
|
|
64
|
-
},
|
|
65
|
-
"homepage": "https://github.com/tagadapay/plugin-sdk#readme"
|
|
66
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tagadapay/plugin-sdk",
|
|
3
|
+
"version": "1.0.26",
|
|
4
|
+
"description": "Modern React SDK for building Tagada Pay plugins",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"clean": "rm -rf dist",
|
|
10
|
+
"lint": "echo \"No linting configured\"",
|
|
11
|
+
"test": "echo \"No tests yet\" && exit 0",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
14
|
+
"publish:patch": "npm version patch && npm publish",
|
|
15
|
+
"publish:minor": "npm version minor && npm publish",
|
|
16
|
+
"publish:major": "npm version major && npm publish",
|
|
17
|
+
"publish:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
|
|
18
|
+
"publish:alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
|
|
19
|
+
"version:patch": "npm version patch",
|
|
20
|
+
"version:minor": "npm version minor",
|
|
21
|
+
"version:major": "npm version major",
|
|
22
|
+
"version:beta": "npm version prerelease --preid=beta",
|
|
23
|
+
"version:alpha": "npm version prerelease --preid=alpha"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"tagadapay",
|
|
27
|
+
"cms",
|
|
28
|
+
"plugin",
|
|
29
|
+
"sdk",
|
|
30
|
+
"react",
|
|
31
|
+
"typescript"
|
|
32
|
+
],
|
|
33
|
+
"author": "Tagada Pay",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@basis-theory/apple-pay-js": "^2.0.2",
|
|
37
|
+
"@basis-theory/basis-theory-js": "^4.30.0",
|
|
38
|
+
"@basis-theory/basis-theory-react": "^1.32.5",
|
|
39
|
+
"@basis-theory/web-threeds": "^1.0.1",
|
|
40
|
+
"axios": "^1.6.0",
|
|
41
|
+
"react-google-autocomplete": "^2.7.3",
|
|
42
|
+
"react-intl": "^7.1.11"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^18.0.0",
|
|
46
|
+
"@types/react": "^19",
|
|
47
|
+
"@types/react-dom": "^19",
|
|
48
|
+
"typescript": "^5.0.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
52
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
53
|
+
},
|
|
54
|
+
"files": [
|
|
55
|
+
"dist/**/*",
|
|
56
|
+
"README.md"
|
|
57
|
+
],
|
|
58
|
+
"repository": {
|
|
59
|
+
"type": "git",
|
|
60
|
+
"url": "git+https://github.com/tagadapay/plugin-sdk.git"
|
|
61
|
+
},
|
|
62
|
+
"bugs": {
|
|
63
|
+
"url": "https://github.com/tagadapay/plugin-sdk/issues"
|
|
64
|
+
},
|
|
65
|
+
"homepage": "https://github.com/tagadapay/plugin-sdk#readme"
|
|
66
|
+
}
|