@tagadapay/plugin-sdk 1.0.3 → 1.0.4
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 +307 -368
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,461 +1,396 @@
|
|
|
1
1
|
# TagadaPay Plugin SDK
|
|
2
2
|
|
|
3
|
-
A
|
|
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
4
|
|
|
5
|
-
##
|
|
5
|
+
## 📚 Documentation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- 🔧 **TypeScript Support** - Full type safety with comprehensive TypeScript definitions
|
|
9
|
-
- 🎯 **Checkout Management** - Complete checkout session lifecycle management
|
|
10
|
-
- 💳 **Payment Processing** - Integrated payment processing with 3DS support
|
|
11
|
-
- 📦 **Product Management** - Fetch and manage products, variants, and pricing
|
|
12
|
-
- 🛒 **Order Management** - Comprehensive order data fetching and management
|
|
13
|
-
- 🎁 **Offers & Promotions** - Handle special offers and promotional codes
|
|
14
|
-
- 🌍 **Multi-Environment** - Support for development, staging, and production
|
|
15
|
-
- 📱 **Responsive Design** - Mobile-first design patterns
|
|
7
|
+
### Core APIs
|
|
16
8
|
|
|
17
|
-
|
|
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
|
|
18
20
|
|
|
19
21
|
### Installation
|
|
20
22
|
|
|
21
23
|
```bash
|
|
22
24
|
npm install @tagadapay/plugin-sdk
|
|
23
|
-
# or
|
|
24
|
-
pnpm add @tagadapay/plugin-sdk
|
|
25
|
-
# or
|
|
26
|
-
yarn add @tagadapay/plugin-sdk
|
|
27
25
|
```
|
|
28
26
|
|
|
29
|
-
### Basic
|
|
27
|
+
### Basic Usage
|
|
30
28
|
|
|
31
|
-
```
|
|
32
|
-
import
|
|
33
|
-
import { TagadaProvider, useCheckout, useCustomer } from '@tagadapay/plugin-sdk';
|
|
29
|
+
```typescript
|
|
30
|
+
import { useCheckout, setCheckoutInfo } from '@tagadapay/plugin-sdk';
|
|
34
31
|
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
<TagadaProvider storeId="your-store-id" accountId="your-account-id" environment="development">
|
|
38
|
-
<MyCheckoutPlugin />
|
|
39
|
-
</TagadaProvider>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
32
|
+
function CheckoutPage() {
|
|
33
|
+
const { customer, cart, payment } = useCheckout();
|
|
42
34
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
const handleSubmit = async (data) => {
|
|
36
|
+
await setCheckoutInfo({
|
|
37
|
+
customer: data.customer,
|
|
38
|
+
payment: data.payment
|
|
39
|
+
});
|
|
40
|
+
};
|
|
46
41
|
|
|
47
42
|
return (
|
|
48
43
|
<div>
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
{checkout ? (
|
|
52
|
-
<CheckoutForm checkout={checkout} />
|
|
53
|
-
) : (
|
|
54
|
-
<button
|
|
55
|
-
onClick={() =>
|
|
56
|
-
init({
|
|
57
|
-
lineItems: [{ variantId: 'variant-id', quantity: 1 }],
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
>
|
|
61
|
-
Start Checkout
|
|
62
|
-
</button>
|
|
63
|
-
)}
|
|
44
|
+
{/* Your checkout UI */}
|
|
64
45
|
</div>
|
|
65
46
|
);
|
|
66
47
|
}
|
|
67
48
|
```
|
|
68
49
|
|
|
69
|
-
##
|
|
70
|
-
|
|
71
|
-
### `useCheckout`
|
|
72
|
-
|
|
73
|
-
Manage checkout sessions, line items, and customer information.
|
|
74
|
-
|
|
75
|
-
```tsx
|
|
76
|
-
import { useCheckout } from '@tagadapay/plugin-sdk';
|
|
77
|
-
|
|
78
|
-
function CheckoutComponent() {
|
|
79
|
-
const {
|
|
80
|
-
checkout,
|
|
81
|
-
isLoading,
|
|
82
|
-
error,
|
|
83
|
-
init,
|
|
84
|
-
updateLineItems,
|
|
85
|
-
updateCustomerAndSessionInfo,
|
|
86
|
-
applyPromotionCode,
|
|
87
|
-
} = useCheckout({
|
|
88
|
-
checkoutToken: 'optional-existing-token',
|
|
89
|
-
autoRefresh: true,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// Initialize new checkout
|
|
93
|
-
const startCheckout = async () => {
|
|
94
|
-
await init({
|
|
95
|
-
storeId: 'store-id',
|
|
96
|
-
lineItems: [
|
|
97
|
-
{ variantId: 'variant-1', quantity: 2 },
|
|
98
|
-
{ variantId: 'variant-2', quantity: 1 },
|
|
99
|
-
],
|
|
100
|
-
customer: {
|
|
101
|
-
email: 'customer@example.com',
|
|
102
|
-
currency: 'USD',
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
};
|
|
50
|
+
## 🎯 Key Features
|
|
106
51
|
|
|
107
|
-
|
|
108
|
-
const updateCart = async () => {
|
|
109
|
-
await updateLineItems([{ variantId: 'variant-1', quantity: 3 }]);
|
|
110
|
-
};
|
|
52
|
+
### Payment Processing
|
|
111
53
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
54
|
+
- Secure tokenized payments
|
|
55
|
+
- Multiple payment method support
|
|
56
|
+
- Real-time validation
|
|
57
|
+
- PCI compliance
|
|
116
58
|
|
|
117
|
-
|
|
118
|
-
<div>
|
|
119
|
-
{checkout && (
|
|
120
|
-
<div>
|
|
121
|
-
<h2>Total: {formatMoney(checkout.summary.totalAdjustedAmount, checkout.summary.currency)}</h2>
|
|
122
|
-
{checkout.summary.items.map((item) => (
|
|
123
|
-
<div key={item.id}>
|
|
124
|
-
{item.name} - Qty: {item.quantity} - {formatMoney(item.adjustedAmount, item.currency)}
|
|
125
|
-
</div>
|
|
126
|
-
))}
|
|
127
|
-
</div>
|
|
128
|
-
)}
|
|
129
|
-
</div>
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
```
|
|
59
|
+
### Customer Management
|
|
133
60
|
|
|
134
|
-
|
|
61
|
+
- Profile management
|
|
62
|
+
- Address validation
|
|
63
|
+
- Order history
|
|
64
|
+
- Preferences
|
|
135
65
|
|
|
136
|
-
|
|
66
|
+
### Cart & Pricing
|
|
137
67
|
|
|
138
|
-
|
|
139
|
-
|
|
68
|
+
- Dynamic pricing
|
|
69
|
+
- Promotional offers
|
|
70
|
+
- Tax calculations
|
|
71
|
+
- Currency conversion
|
|
140
72
|
|
|
141
|
-
|
|
142
|
-
const { order, isLoading, error, refetch } = useOrder({
|
|
143
|
-
orderId,
|
|
144
|
-
autoFetch: true,
|
|
145
|
-
});
|
|
73
|
+
### UI Components
|
|
146
74
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
75
|
+
- Pre-built checkout components
|
|
76
|
+
- Customizable themes
|
|
77
|
+
- Mobile-optimized
|
|
78
|
+
- Accessibility features
|
|
150
79
|
|
|
151
|
-
|
|
152
|
-
<div>
|
|
153
|
-
<h1>Order Confirmed!</h1>
|
|
154
|
-
<p>Order #{order.id}</p>
|
|
155
|
-
<p>Status: {order.status}</p>
|
|
156
|
-
<p>Total: {formatMoney(order.paidAmount, order.currency)}</p>
|
|
157
|
-
|
|
158
|
-
<h3>Items:</h3>
|
|
159
|
-
{order.items.map((item) => (
|
|
160
|
-
<div key={item.id}>
|
|
161
|
-
<h4>{item.orderLineItemProduct?.name}</h4>
|
|
162
|
-
<p>Quantity: {item.quantity}</p>
|
|
163
|
-
<p>Price: {formatMoney(item.adjustedAmount, item.currency)}</p>
|
|
164
|
-
</div>
|
|
165
|
-
))}
|
|
166
|
-
|
|
167
|
-
{order.shippingAddress && (
|
|
168
|
-
<div>
|
|
169
|
-
<h3>Shipping Address:</h3>
|
|
170
|
-
<p>
|
|
171
|
-
{order.shippingAddress.firstName} {order.shippingAddress.lastName}
|
|
172
|
-
</p>
|
|
173
|
-
<p>{order.shippingAddress.address1}</p>
|
|
174
|
-
<p>
|
|
175
|
-
{order.shippingAddress.city}, {order.shippingAddress.state} {order.shippingAddress.postal}
|
|
176
|
-
</p>
|
|
177
|
-
</div>
|
|
178
|
-
)}
|
|
179
|
-
</div>
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
```
|
|
80
|
+
## 📖 API Reference
|
|
183
81
|
|
|
184
|
-
###
|
|
185
|
-
|
|
186
|
-
Process payments with support for credit cards, Apple Pay, and 3D Secure.
|
|
187
|
-
|
|
188
|
-
```tsx
|
|
189
|
-
import { usePayment, useCheckout } from '@tagadapay/plugin-sdk';
|
|
190
|
-
|
|
191
|
-
function PaymentForm() {
|
|
192
|
-
const { checkout } = useCheckout();
|
|
193
|
-
const { processCardPayment, isLoading, error } = usePayment();
|
|
194
|
-
|
|
195
|
-
const handlePayment = async (formData: any) => {
|
|
196
|
-
if (!checkout?.checkoutSession?.id) return;
|
|
197
|
-
|
|
198
|
-
try {
|
|
199
|
-
const result = await processCardPayment(
|
|
200
|
-
checkout.checkoutSession.id,
|
|
201
|
-
{
|
|
202
|
-
cardNumber: formData.cardNumber,
|
|
203
|
-
expiryDate: formData.expiryDate,
|
|
204
|
-
cvc: formData.cvc,
|
|
205
|
-
cardholderName: formData.cardholderName,
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
enableThreeds: true,
|
|
209
|
-
onSuccess: (payment) => {
|
|
210
|
-
// Redirect to thank you page
|
|
211
|
-
window.location.href = `/thankyou/${payment.orderId}`;
|
|
212
|
-
},
|
|
213
|
-
onFailure: (error) => {
|
|
214
|
-
console.error('Payment failed:', error);
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
);
|
|
218
|
-
} catch (err) {
|
|
219
|
-
console.error('Payment error:', err);
|
|
220
|
-
}
|
|
221
|
-
};
|
|
82
|
+
### Core Hooks
|
|
222
83
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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();
|
|
233
97
|
```
|
|
234
98
|
|
|
235
|
-
|
|
99
|
+
#### useOffers()
|
|
236
100
|
|
|
237
|
-
|
|
101
|
+
Hook for managing dynamic offers and pricing.
|
|
238
102
|
|
|
239
|
-
```
|
|
240
|
-
|
|
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
|
+
```
|
|
241
111
|
|
|
242
|
-
|
|
243
|
-
const { products, isLoading, getVariant, filterVariants } = useProducts({
|
|
244
|
-
includeVariants: true,
|
|
245
|
-
includePrices: true,
|
|
246
|
-
});
|
|
112
|
+
### Utility Functions
|
|
247
113
|
|
|
248
|
-
|
|
114
|
+
#### setCheckoutInfo()
|
|
249
115
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
</div>
|
|
265
|
-
);
|
|
266
|
-
}
|
|
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
|
+
});
|
|
267
130
|
```
|
|
268
131
|
|
|
269
|
-
|
|
132
|
+
#### Money utilities
|
|
270
133
|
|
|
271
|
-
|
|
134
|
+
Format and calculate monetary values.
|
|
272
135
|
|
|
273
|
-
```
|
|
274
|
-
import {
|
|
136
|
+
```typescript
|
|
137
|
+
import { formatMoney, convertCurrency } from '@tagadapay/plugin-sdk';
|
|
275
138
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
returnUrl: window.location.origin + '/thankyou',
|
|
280
|
-
});
|
|
139
|
+
const formatted = formatMoney(2999, 'USD'); // "$29.99"
|
|
140
|
+
const converted = convertCurrency(2999, 'USD', 'EUR'); // 2699
|
|
141
|
+
```
|
|
281
142
|
|
|
282
|
-
|
|
283
|
-
const { checkoutUrl } = await createCheckoutSession(offerId);
|
|
284
|
-
window.location.href = checkoutUrl;
|
|
285
|
-
};
|
|
143
|
+
## 🛠️ Development
|
|
286
144
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
);
|
|
299
|
-
}
|
|
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
|
|
300
156
|
```
|
|
301
157
|
|
|
302
|
-
|
|
158
|
+
### Testing
|
|
303
159
|
|
|
304
|
-
|
|
160
|
+
```bash
|
|
161
|
+
# Run tests
|
|
162
|
+
npm test
|
|
305
163
|
|
|
306
|
-
|
|
164
|
+
# Run tests with coverage
|
|
165
|
+
npm run test:coverage
|
|
166
|
+
```
|
|
307
167
|
|
|
308
|
-
|
|
309
|
-
import { formatMoney } from '@tagadapay/plugin-sdk';
|
|
168
|
+
### Linting
|
|
310
169
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
formatMoney(2999, 'GBP'); // "£29.99"
|
|
170
|
+
```bash
|
|
171
|
+
# Check code style
|
|
172
|
+
npm run lint
|
|
315
173
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
showDecimals: false,
|
|
319
|
-
}); // "$30"
|
|
174
|
+
# Fix linting issues
|
|
175
|
+
npm run lint:fix
|
|
320
176
|
```
|
|
321
177
|
|
|
322
|
-
##
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
debugMode={true}
|
|
333
|
-
>
|
|
334
|
-
<App />
|
|
335
|
-
</TagadaProvider>
|
|
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
|
|
336
188
|
```
|
|
337
189
|
|
|
338
|
-
|
|
190
|
+
### Deployment
|
|
339
191
|
|
|
340
|
-
|
|
192
|
+
```bash
|
|
193
|
+
# Deploy using TagadaPay CLI
|
|
194
|
+
npx @tagadapay/plugin-cli deploy
|
|
341
195
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
OrderItem,
|
|
346
|
-
CheckoutSession,
|
|
347
|
-
Customer,
|
|
348
|
-
UseCheckoutResult,
|
|
349
|
-
UseOrderResult,
|
|
350
|
-
} from '@tagadapay/plugin-sdk';
|
|
196
|
+
# Deploy specific environment
|
|
197
|
+
npx @tagadapay/plugin-cli deploy --env production
|
|
198
|
+
```
|
|
351
199
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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
|
+
}
|
|
355
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
|
|
356
227
|
|
|
357
|
-
|
|
358
|
-
|
|
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;
|
|
359
238
|
}
|
|
360
239
|
```
|
|
361
240
|
|
|
362
|
-
|
|
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 });
|
|
363
276
|
|
|
364
|
-
|
|
277
|
+
// ❌ Bad: Never store raw card data
|
|
278
|
+
// const cardNumber = '4111111111111111'; // Don't do this
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## 📱 Mobile Optimization
|
|
365
282
|
|
|
366
|
-
|
|
367
|
-
function MyComponent() {
|
|
368
|
-
const { order, error, isLoading } = useOrder({ orderId: 'order-123' });
|
|
283
|
+
### Responsive Design
|
|
369
284
|
|
|
370
|
-
|
|
285
|
+
```css
|
|
286
|
+
.checkout-container {
|
|
287
|
+
max-width: 600px;
|
|
288
|
+
margin: 0 auto;
|
|
289
|
+
padding: 16px;
|
|
290
|
+
}
|
|
371
291
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
title="Failed to load order"
|
|
376
|
-
message={error.message}
|
|
377
|
-
onRetry={() => window.location.reload()}
|
|
378
|
-
/>
|
|
379
|
-
);
|
|
292
|
+
@media (max-width: 768px) {
|
|
293
|
+
.checkout-container {
|
|
294
|
+
padding: 8px;
|
|
380
295
|
}
|
|
381
296
|
|
|
382
|
-
|
|
297
|
+
.checkout-form {
|
|
298
|
+
font-size: 16px; /* Prevent zoom on iOS */
|
|
299
|
+
}
|
|
383
300
|
}
|
|
384
301
|
```
|
|
385
302
|
|
|
386
|
-
|
|
303
|
+
### Touch Interactions
|
|
387
304
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
endpoints: {
|
|
394
|
-
checkout: {
|
|
395
|
-
sessionInit: '/v2/checkout/init',
|
|
396
|
-
sessionStatus: '/v2/checkout/status',
|
|
397
|
-
},
|
|
398
|
-
},
|
|
305
|
+
```typescript
|
|
306
|
+
const handleTouchStart = (e) => {
|
|
307
|
+
// Optimize for touch devices
|
|
308
|
+
e.preventDefault();
|
|
309
|
+
// Handle touch interaction
|
|
399
310
|
};
|
|
400
|
-
|
|
401
|
-
<TagadaProvider customApiConfig={customConfig}>
|
|
402
|
-
<App />
|
|
403
|
-
</TagadaProvider>;
|
|
404
311
|
```
|
|
405
312
|
|
|
406
|
-
|
|
313
|
+
## 🌐 Internationalization
|
|
407
314
|
|
|
408
|
-
|
|
315
|
+
### Multi-language Support
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
import { useTranslation } from '@tagadapay/plugin-sdk';
|
|
319
|
+
|
|
320
|
+
function CheckoutForm() {
|
|
321
|
+
const { t } = useTranslation();
|
|
409
322
|
|
|
410
|
-
```tsx
|
|
411
|
-
// Plugin entry point
|
|
412
|
-
export function MyCheckoutPlugin() {
|
|
413
323
|
return (
|
|
414
|
-
<
|
|
415
|
-
<
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
<Route path="/thankyou/:orderId" element={<ThankYouPage />} />
|
|
419
|
-
</Routes>
|
|
420
|
-
</Router>
|
|
421
|
-
</TagadaProvider>
|
|
324
|
+
<form>
|
|
325
|
+
<label>{t('checkout.email')}</label>
|
|
326
|
+
<input type="email" placeholder={t('checkout.email_placeholder')} />
|
|
327
|
+
</form>
|
|
422
328
|
);
|
|
423
329
|
}
|
|
424
330
|
```
|
|
425
331
|
|
|
426
|
-
|
|
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
|
|
427
345
|
|
|
428
|
-
|
|
429
|
-
- **[Checkout Integration](./README-useCheckout.md)** - Detailed checkout examples
|
|
430
|
-
- **[Payment Processing](./README-useOffers.md)** - Payment integration examples
|
|
431
|
-
- **[Money Formatting](./README-money.md)** - Currency formatting utilities
|
|
346
|
+
### Event Tracking
|
|
432
347
|
|
|
433
|
-
|
|
348
|
+
```typescript
|
|
349
|
+
import { trackEvent } from '@tagadapay/plugin-sdk';
|
|
434
350
|
|
|
435
|
-
|
|
351
|
+
// Track user interactions
|
|
352
|
+
trackEvent('checkout_started', {
|
|
353
|
+
product_id: 'prod_123',
|
|
354
|
+
value: 2999,
|
|
355
|
+
currency: 'USD',
|
|
356
|
+
});
|
|
436
357
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
358
|
+
// Track conversions
|
|
359
|
+
trackEvent('purchase_completed', {
|
|
360
|
+
transaction_id: 'txn_456',
|
|
361
|
+
value: 2999,
|
|
362
|
+
currency: 'USD',
|
|
363
|
+
});
|
|
364
|
+
```
|
|
444
365
|
|
|
445
|
-
###
|
|
366
|
+
### Performance Monitoring
|
|
446
367
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
- [`urlUtils`](./README-urlUtils.md) - URL manipulation utilities
|
|
368
|
+
```typescript
|
|
369
|
+
import { performance } from '@tagadapay/plugin-sdk';
|
|
450
370
|
|
|
451
|
-
|
|
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
|
|
452
379
|
|
|
453
|
-
|
|
454
|
-
- Firefox 88+
|
|
455
|
-
- Safari 14+
|
|
456
|
-
- Edge 90+
|
|
380
|
+
### Development Setup
|
|
457
381
|
|
|
458
|
-
|
|
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
|
|
459
394
|
|
|
460
395
|
1. Fork the repository
|
|
461
396
|
2. Create a feature branch
|
|
@@ -463,13 +398,17 @@ export function MyCheckoutPlugin() {
|
|
|
463
398
|
4. Add tests
|
|
464
399
|
5. Submit a pull request
|
|
465
400
|
|
|
466
|
-
## License
|
|
401
|
+
## 📄 License
|
|
467
402
|
|
|
468
403
|
MIT License - see [LICENSE](./LICENSE) for details.
|
|
469
404
|
|
|
470
|
-
## Support
|
|
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
|
+
---
|
|
471
413
|
|
|
472
|
-
|
|
473
|
-
- 🐛 [Issues](https://github.com/tagadapay/plugin-sdk/issues)
|
|
474
|
-
- 💬 [Discussions](https://github.com/tagadapay/plugin-sdk/discussions)
|
|
475
|
-
- 📧 [Support Email](mailto:support@tagadapay.com)
|
|
414
|
+
Built with ❤️ by the TagadaPay team
|