@reeboot/strapi-payment-plugin 0.0.0 → 0.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 +398 -66
- package/dist/_chunks/Analytics-C2GKvPDX.js +355 -0
- package/dist/_chunks/Analytics-Chydh3dg.mjs +355 -0
- package/dist/_chunks/App-BCbEuN6h.mjs +68 -0
- package/dist/_chunks/App-E2k2mo5p.js +70 -0
- package/dist/_chunks/Customers-B8BlQ1BO.mjs +273 -0
- package/dist/_chunks/Customers-D0O5ET5C.js +273 -0
- package/dist/_chunks/Dashboard-CuqclLak.js +180 -0
- package/dist/_chunks/Dashboard-D8-ifJqB.mjs +180 -0
- package/dist/_chunks/Orders-5WGSzPGo.js +308 -0
- package/dist/_chunks/Orders-ClJJaQrX.mjs +308 -0
- package/dist/_chunks/Payments-CIMyOC3n.js +489 -0
- package/dist/_chunks/Payments-CRnRBf48.mjs +489 -0
- package/dist/_chunks/Settings-BXMLePI_.js +357 -0
- package/dist/_chunks/Settings-TeAvV4RH.mjs +357 -0
- package/dist/_chunks/en-BJocyOVu.mjs +240 -0
- package/dist/_chunks/en-BkVAf_R4.js +240 -0
- package/dist/_chunks/index-BTk7a2T5.js +66 -0
- package/dist/_chunks/index-Bz8V_5zH.mjs +67 -0
- package/dist/admin/index.js +2 -63
- package/dist/admin/index.mjs +2 -63
- package/dist/admin/src/components/AnalyticsChart.d.ts +19 -0
- package/dist/admin/src/components/CustomerList.d.ts +21 -0
- package/dist/admin/src/components/OrderList.d.ts +27 -0
- package/dist/admin/src/components/PaymentCard.d.ts +39 -0
- package/dist/admin/src/components/PaymentList.d.ts +19 -0
- package/dist/admin/src/components/RefundModal.d.ts +15 -0
- package/dist/admin/src/pages/Analytics.d.ts +2 -0
- package/dist/admin/src/pages/Customers.d.ts +2 -0
- package/dist/admin/src/pages/Dashboard.d.ts +2 -0
- package/dist/admin/src/pages/HomePage.d.ts +1 -1
- package/dist/admin/src/pages/Orders.d.ts +2 -0
- package/dist/admin/src/pages/Payments.d.ts +2 -0
- package/dist/admin/src/pages/Settings.d.ts +2 -0
- package/dist/server/index.js +1827 -7101
- package/dist/server/index.mjs +1826 -7100
- package/dist/server/src/config/index.d.ts +2 -10
- package/dist/server/src/content-types/customer/index.d.ts +69 -0
- package/dist/server/src/content-types/index.d.ts +207 -1
- package/dist/server/src/content-types/order/index.d.ts +70 -0
- package/dist/server/src/content-types/payment/index.d.ts +69 -0
- package/dist/server/src/controllers/controller.d.ts +6 -9
- package/dist/server/src/controllers/index.d.ts +30 -35
- package/dist/server/src/controllers/stripe.d.ts +104 -0
- package/dist/server/src/index.d.ts +262 -110
- package/dist/server/src/middlewares/index.d.ts +19 -1
- package/dist/server/src/policies/index.d.ts +3 -1
- package/dist/server/src/routes/{admin-routes.d.ts → admin/index.d.ts} +4 -4
- package/dist/server/src/routes/content-api/index.d.ts +21 -0
- package/dist/server/src/routes/index.d.ts +10 -26
- package/dist/server/src/services/index.d.ts +2 -37
- package/dist/server/src/services/{stripeDriver.d.ts → stripe.d.ts} +52 -28
- package/dist/server/src/types/index.d.ts +179 -0
- package/package.json +20 -24
- package/dist/_chunks/App-BGle38NN.js +0 -1149
- package/dist/_chunks/App-DoUUpjp-.mjs +0 -1149
- package/dist/_chunks/en-B4KWt_jN.js +0 -4
- package/dist/_chunks/en-Byx4XI2L.mjs +0 -4
- package/dist/admin/src/components/Header.d.ts +0 -2
- package/dist/admin/src/components/NavigationMenu.d.ts +0 -2
- package/dist/admin/src/components/Sidebar.d.ts +0 -2
- package/dist/admin/src/components/TransactionDetailsModal.d.ts +0 -18
- package/dist/admin/src/components/TransactionList.d.ts +0 -18
- package/dist/admin/src/pages/ConfigurationPage.d.ts +0 -2
- package/dist/admin/src/pages/DashboardPage.d.ts +0 -2
- package/dist/admin/src/pages/ProductsPage.d.ts +0 -2
- package/dist/admin/src/pages/SubscriptionsPage.d.ts +0 -2
- package/dist/admin/src/pages/TransactionsPage.d.ts +0 -2
- package/dist/server/controllers/product.d.ts +0 -12
- package/dist/server/controllers/subscription.d.ts +0 -12
- package/dist/server/services/product.d.ts +0 -7
- package/dist/server/services/subscription.d.ts +0 -7
- package/dist/server/src/controllers/productController.d.ts +0 -9
- package/dist/server/src/controllers/subscriptionController.d.ts +0 -9
- package/dist/server/src/routes/content-api.d.ts +0 -12
- package/dist/server/src/routes/product-routes.d.ts +0 -13
- package/dist/server/src/routes/refund-routes.d.ts +0 -13
- package/dist/server/src/routes/subscription-routes.d.ts +0 -13
- package/dist/server/src/services/paypalDriver.d.ts +0 -7
- package/dist/server/src/services/service.d.ts +0 -33
- package/jest.config.js +0 -13
package/README.md
CHANGED
|
@@ -1,112 +1,444 @@
|
|
|
1
|
-
# Strapi
|
|
1
|
+
# Strapi Payment Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A comprehensive Stripe integration plugin for Strapi v5 that provides complete payment processing capabilities, customer management, order handling, and webhook management for modern e-commerce applications.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
- Webhook handling for payment status updates
|
|
9
|
-
- Refund processing
|
|
10
|
-
- Payment details retrieval
|
|
11
|
-
- Admin panel configuration interface
|
|
10
|
+
## 🚀 Features
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
### Core Payment Processing
|
|
13
|
+
- **Payment Intent Creation & Management** - Secure payment processing with Stripe Payment Intents
|
|
14
|
+
- **Customer Management** - Create and manage Stripe customers with automatic Strapi synchronization
|
|
15
|
+
- **Order Processing** - Complete order lifecycle management with payment integration
|
|
16
|
+
- **Refund Processing** - Full and partial refund capabilities with audit trails
|
|
17
|
+
- **Webhook Handling** - Automatic webhook processing with signature verification
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
### Advanced Features
|
|
20
|
+
- **Real-time Payment Tracking** - Live payment status updates via webhooks
|
|
21
|
+
- **Admin Dashboard** - Comprehensive admin interface for payment management
|
|
22
|
+
- **Analytics & Reporting** - Payment analytics, revenue tracking, and customer insights
|
|
23
|
+
- **Multi-currency Support** - Support for multiple currencies and payment methods
|
|
24
|
+
- **Security First** - PCI-compliant payment handling with encrypted data storage
|
|
25
|
+
|
|
26
|
+
### Developer Experience
|
|
27
|
+
- **TypeScript Support** - Full TypeScript typing for all operations
|
|
28
|
+
- **RESTful API** - Clean, documented API endpoints following REST conventions
|
|
29
|
+
- **Rate Limiting** - Built-in rate limiting for sensitive operations
|
|
30
|
+
- **Error Handling** - Comprehensive error handling with detailed logging
|
|
31
|
+
- **Admin Interface** - Modern React-based admin panel with responsive design
|
|
32
|
+
|
|
33
|
+
## 📋 Prerequisites
|
|
34
|
+
|
|
35
|
+
- **Strapi v5.33.1+** - Latest Strapi v5 version
|
|
36
|
+
- **Node.js 18+** - Node.js runtime environment
|
|
37
|
+
- **Stripe Account** - Active Stripe account with API keys
|
|
38
|
+
- **Database** - PostgreSQL, MySQL, or SQLite database
|
|
39
|
+
|
|
40
|
+
## 🔧 Installation
|
|
41
|
+
|
|
42
|
+
### Method 1: Copy Plugin to Project
|
|
43
|
+
|
|
44
|
+
1. Copy the `payment-plugin` folder to your Strapi project's plugins directory:
|
|
16
45
|
```bash
|
|
17
|
-
|
|
46
|
+
cp -r payment-plugin /path/to/your/strapi-project/src/plugins/
|
|
18
47
|
```
|
|
19
48
|
|
|
20
|
-
2.
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
|
|
49
|
+
2. Install dependencies:
|
|
50
|
+
```bash
|
|
51
|
+
npm install @stripe/stripe-js stripe
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
3. Configure the plugin in `config/plugins.ts`:
|
|
55
|
+
```typescript
|
|
56
|
+
export default () => ({
|
|
24
57
|
'payment-plugin': {
|
|
25
58
|
enabled: true,
|
|
59
|
+
resolve: './src/plugins/payment-plugin',
|
|
60
|
+
config: {
|
|
61
|
+
stripe: {
|
|
62
|
+
apiVersion: '2024-06-20',
|
|
63
|
+
},
|
|
64
|
+
payment: {
|
|
65
|
+
defaultCurrency: 'usd',
|
|
66
|
+
successUrl: 'http://localhost:3000/payment/success',
|
|
67
|
+
cancelUrl: 'http://localhost:3000/payment/cancel',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
26
70
|
},
|
|
27
|
-
};
|
|
71
|
+
});
|
|
28
72
|
```
|
|
29
73
|
|
|
30
|
-
|
|
74
|
+
### Method 2: Development Setup
|
|
31
75
|
|
|
32
|
-
1.
|
|
76
|
+
1. Navigate to the plugin directory:
|
|
77
|
+
```bash
|
|
78
|
+
cd src/plugins/payment-plugin
|
|
33
79
|
```
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
PAYPAL_CLIENT_SECRET=your_paypal_client_secret
|
|
39
|
-
PAYPAL_WEBHOOK_ID=your_paypal_webhook_id
|
|
80
|
+
|
|
81
|
+
2. Install dependencies:
|
|
82
|
+
```bash
|
|
83
|
+
npm install
|
|
40
84
|
```
|
|
41
85
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
86
|
+
3. Build the plugin:
|
|
87
|
+
```bash
|
|
88
|
+
npm run build
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## ⚙️ Configuration
|
|
92
|
+
|
|
93
|
+
### Environment Variables
|
|
94
|
+
|
|
95
|
+
Add these to your `.env` file:
|
|
96
|
+
|
|
97
|
+
```env
|
|
98
|
+
# Stripe API Configuration
|
|
99
|
+
STRIPE_API_KEY=sk_test_... # Your Stripe secret key
|
|
100
|
+
STRIPE_WEBHOOK_SECRET=whsec_... # Your Stripe webhook endpoint secret
|
|
101
|
+
|
|
102
|
+
# Alternative configuration
|
|
103
|
+
STRIPE_SECRET_KEY=sk_test_...
|
|
104
|
+
STRIPE_PUBLISHABLE_KEY=pk_test_...
|
|
105
|
+
|
|
106
|
+
# Optional: Plugin Configuration
|
|
107
|
+
PAYMENT_PLUGIN_LOG_LEVEL=info
|
|
108
|
+
PAYMENT_PLUGIN_ENABLE_WEBHOOK_LOGGING=true
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Plugin Configuration
|
|
112
|
+
|
|
113
|
+
Update `config/plugins.ts` with your settings:
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
export default () => ({
|
|
117
|
+
'payment-plugin': {
|
|
118
|
+
enabled: true,
|
|
119
|
+
resolve: './src/plugins/payment-plugin',
|
|
120
|
+
config: {
|
|
121
|
+
stripe: {
|
|
122
|
+
apiVersion: '2024-06-20',
|
|
123
|
+
apiKey: process.env.STRIPE_API_KEY,
|
|
124
|
+
webhookSecret: process.env.STRIPE_WEBHOOK_SECRET,
|
|
125
|
+
},
|
|
126
|
+
payment: {
|
|
127
|
+
defaultCurrency: 'usd',
|
|
128
|
+
successUrl: 'https://yourapp.com/payment/success',
|
|
129
|
+
cancelUrl: 'https://yourapp.com/payment/cancel',
|
|
130
|
+
webhookEndpoint: '/api/payment-plugin/webhook',
|
|
131
|
+
},
|
|
132
|
+
logging: {
|
|
133
|
+
level: 'info',
|
|
134
|
+
enableWebhookLogging: true,
|
|
135
|
+
enableDebugLogging: false,
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
```
|
|
46
141
|
|
|
47
|
-
##
|
|
142
|
+
## 🚀 Quick Start
|
|
48
143
|
|
|
49
|
-
###
|
|
144
|
+
### 1. Create a Payment Intent
|
|
50
145
|
|
|
51
146
|
```javascript
|
|
52
|
-
|
|
53
|
-
|
|
147
|
+
const paymentData = {
|
|
148
|
+
amount: 2500, // $25.00 in cents
|
|
149
|
+
currency: 'usd',
|
|
150
|
+
customerId: 1, // Optional: Strapi customer ID
|
|
151
|
+
orderId: 1, // Optional: Strapi order ID
|
|
152
|
+
metadata: {
|
|
153
|
+
product_id: 'prod_123',
|
|
154
|
+
subscription_type: 'premium'
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const response = await fetch('/api/payment-plugin/payments/create-intent', {
|
|
54
159
|
method: 'POST',
|
|
55
160
|
headers: {
|
|
56
161
|
'Content-Type': 'application/json',
|
|
162
|
+
'Authorization': 'Bearer YOUR_JWT_TOKEN'
|
|
57
163
|
},
|
|
58
|
-
body: JSON.stringify(
|
|
59
|
-
gateway: 'stripe', // or 'paypal'
|
|
60
|
-
amount: 1000, // in cents
|
|
61
|
-
currency: 'usd',
|
|
62
|
-
orderId: 'order_123',
|
|
63
|
-
options: {
|
|
64
|
-
// gateway-specific options
|
|
65
|
-
},
|
|
66
|
-
}),
|
|
164
|
+
body: JSON.stringify(paymentData)
|
|
67
165
|
});
|
|
68
|
-
|
|
166
|
+
|
|
167
|
+
const result = await response.json();
|
|
168
|
+
console.log(result.data.client_secret); // Use this for Stripe Elements
|
|
69
169
|
```
|
|
70
170
|
|
|
71
|
-
###
|
|
171
|
+
### 2. Handle Payment on Frontend
|
|
72
172
|
|
|
73
173
|
```javascript
|
|
74
|
-
|
|
75
|
-
|
|
174
|
+
import { loadStripe } from '@stripe/stripe-js';
|
|
175
|
+
|
|
176
|
+
const stripe = await loadStripe('pk_test_...');
|
|
177
|
+
|
|
178
|
+
const { error } = await stripe.confirmCardPayment(clientSecret, {
|
|
179
|
+
payment_method: {
|
|
180
|
+
card: cardElement,
|
|
181
|
+
billing_details: {
|
|
182
|
+
name: 'John Doe',
|
|
183
|
+
email: 'john@example.com'
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
if (error) {
|
|
189
|
+
console.error('Payment failed:', error);
|
|
190
|
+
} else {
|
|
191
|
+
console.log('Payment succeeded!');
|
|
192
|
+
}
|
|
76
193
|
```
|
|
77
194
|
|
|
78
|
-
###
|
|
195
|
+
### 3. Create a Customer
|
|
79
196
|
|
|
80
197
|
```javascript
|
|
81
|
-
|
|
82
|
-
|
|
198
|
+
const customerData = {
|
|
199
|
+
email: 'customer@example.com',
|
|
200
|
+
firstName: 'John',
|
|
201
|
+
lastName: 'Doe',
|
|
202
|
+
phone: '+1234567890',
|
|
203
|
+
address: {
|
|
204
|
+
line1: '123 Main St',
|
|
205
|
+
city: 'New York',
|
|
206
|
+
postal_code: '10001'
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const response = await fetch('/api/payment-plugin/customers', {
|
|
83
211
|
method: 'POST',
|
|
84
212
|
headers: {
|
|
85
213
|
'Content-Type': 'application/json',
|
|
214
|
+
'Authorization': 'Bearer YOUR_JWT_TOKEN'
|
|
86
215
|
},
|
|
87
|
-
body: JSON.stringify(
|
|
88
|
-
gateway: 'stripe', // or 'paypal'
|
|
89
|
-
transactionId: 'pi_123', // or PayPal transaction ID
|
|
90
|
-
amount: 500, // refund amount in cents
|
|
91
|
-
options: {
|
|
92
|
-
// gateway-specific options
|
|
93
|
-
},
|
|
94
|
-
}),
|
|
216
|
+
body: JSON.stringify(customerData)
|
|
95
217
|
});
|
|
96
|
-
const refund = await response.json();
|
|
97
218
|
```
|
|
98
219
|
|
|
99
|
-
###
|
|
220
|
+
### 4. Process Refunds
|
|
100
221
|
|
|
101
222
|
```javascript
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
223
|
+
const refundData = {
|
|
224
|
+
paymentIntentId: 'pi_1234567890',
|
|
225
|
+
amount: 500, // Optional: partial refund
|
|
226
|
+
reason: 'requested_by_customer',
|
|
227
|
+
metadata: {
|
|
228
|
+
reason: 'customer_request'
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
const response = await fetch('/api/payment-plugin/refunds', {
|
|
233
|
+
method: 'POST',
|
|
234
|
+
headers: {
|
|
235
|
+
'Content-Type': 'application/json',
|
|
236
|
+
'Authorization': 'Bearer YOUR_JWT_TOKEN'
|
|
237
|
+
},
|
|
238
|
+
body: JSON.stringify(refundData)
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## 📚 API Documentation
|
|
243
|
+
|
|
244
|
+
The plugin provides comprehensive REST API endpoints:
|
|
245
|
+
|
|
246
|
+
### Content API Routes
|
|
247
|
+
- `POST /api/payment-plugin/payments/create-intent` - Create payment intent
|
|
248
|
+
- `POST /api/payment-plugin/payments/confirm/:id` - Confirm payment
|
|
249
|
+
- `GET /api/payment-plugin/payments/:id` - Get payment details
|
|
250
|
+
- `GET /api/payment-plugin/payments` - List payments
|
|
251
|
+
- `POST /api/payment-plugin/customers` - Create customer
|
|
252
|
+
- `GET /api/payment-plugin/customers/:id` - Get customer details
|
|
253
|
+
- `GET /api/payment-plugin/customers` - List customers
|
|
254
|
+
- `POST /api/payment-plugin/orders` - Create order
|
|
255
|
+
- `GET /api/payment-plugin/orders/:id` - Get order details
|
|
256
|
+
- `GET /api/payment-plugin/orders` - List orders
|
|
257
|
+
- `POST /api/payment-plugin/refunds` - Process refund
|
|
258
|
+
- `GET /api/payment-plugin/status` - Service status
|
|
259
|
+
- `GET /api/payment-plugin/health` - Health check
|
|
260
|
+
|
|
261
|
+
### Admin API Routes
|
|
262
|
+
- `POST /admin/api/payment-plugin/webhook` - Handle Stripe webhooks
|
|
263
|
+
- `GET /admin/api/payment-plugin/admin/dashboard` - Dashboard data
|
|
264
|
+
- `GET /admin/api/payment-plugin/admin/reports` - Payment reports
|
|
265
|
+
- `GET /admin/api/payment-plugin/admin/analytics` - Analytics data
|
|
266
|
+
- `GET /admin/api/payment-plugin/admin/config` - Plugin configuration
|
|
267
|
+
- `PUT /admin/api/payment-plugin/admin/config` - Update configuration
|
|
268
|
+
|
|
269
|
+
For complete API documentation, see [API_REFERENCE.md](./docs/API_REFERENCE.md).
|
|
270
|
+
|
|
271
|
+
## 🔐 Security
|
|
272
|
+
|
|
273
|
+
### Payment Security
|
|
274
|
+
- **PCI Compliance** - Stripe handles all sensitive payment data
|
|
275
|
+
- **Webhook Verification** - All webhooks are cryptographically verified
|
|
276
|
+
- **Data Encryption** - Sensitive data is encrypted at rest and in transit
|
|
277
|
+
- **Audit Logging** - All payment operations are logged for compliance
|
|
278
|
+
|
|
279
|
+
### Access Control
|
|
280
|
+
- **JWT Authentication** - All API endpoints require valid authentication
|
|
281
|
+
- **Role-based Access** - User-specific data filtering
|
|
282
|
+
- **Rate Limiting** - Protection against abuse
|
|
283
|
+
- **Input Validation** - Comprehensive input sanitization
|
|
284
|
+
|
|
285
|
+
### Security Best Practices
|
|
286
|
+
- Never log sensitive payment information
|
|
287
|
+
- Use HTTPS for all webhook endpoints
|
|
288
|
+
- Implement proper error handling
|
|
289
|
+
- Regular security audits and updates
|
|
290
|
+
|
|
291
|
+
See [SECURITY.md](./docs/SECURITY.md) for detailed security guidelines.
|
|
292
|
+
|
|
293
|
+
## 🛠️ Development
|
|
294
|
+
|
|
295
|
+
### Project Structure
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
src/plugins/payment-plugin/
|
|
299
|
+
├── admin/ # Admin panel React components
|
|
300
|
+
├── server/ # Server-side code
|
|
301
|
+
│ ├── src/
|
|
302
|
+
│ │ ├── controllers/ # API controllers
|
|
303
|
+
│ │ ├── services/ # Business logic services
|
|
304
|
+
│ │ ├── routes/ # API routes configuration
|
|
305
|
+
│ │ ├── content-types/ # Database schemas
|
|
306
|
+
│ │ └── types/ # TypeScript type definitions
|
|
307
|
+
├── docs/ # Documentation
|
|
308
|
+
├── package.json # Plugin dependencies
|
|
309
|
+
└── README.md # This file
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Building and Development
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
# Install dependencies
|
|
316
|
+
npm install
|
|
317
|
+
|
|
318
|
+
# Build for production
|
|
319
|
+
npm run build
|
|
320
|
+
|
|
321
|
+
# Watch for changes during development
|
|
322
|
+
npm run watch
|
|
323
|
+
|
|
324
|
+
# Verify plugin structure
|
|
325
|
+
npm run verify
|
|
326
|
+
|
|
327
|
+
# Type checking
|
|
328
|
+
npm run test:ts:front # Frontend TypeScript
|
|
329
|
+
npm run test:ts:back # Backend TypeScript
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Testing
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
# Run all tests
|
|
336
|
+
npm test
|
|
337
|
+
|
|
338
|
+
# Run tests in watch mode
|
|
339
|
+
npm run test:watch
|
|
340
|
+
|
|
341
|
+
# Run specific test suite
|
|
342
|
+
npm run test:unit
|
|
343
|
+
npm run test:integration
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## 🐛 Troubleshooting
|
|
347
|
+
|
|
348
|
+
### Common Issues
|
|
349
|
+
|
|
350
|
+
#### "Stripe API key not found"
|
|
351
|
+
- Ensure `STRIPE_API_KEY` is set in your environment variables
|
|
352
|
+
- Check that the key starts with `sk_test_` (test) or `sk_live_` (live)
|
|
353
|
+
- Verify the key has the correct permissions
|
|
354
|
+
|
|
355
|
+
#### "Webhook signature verification fails"
|
|
356
|
+
- Ensure `STRIPE_WEBHOOK_SECRET` is configured
|
|
357
|
+
- Verify the webhook endpoint URL matches Stripe configuration
|
|
358
|
+
- Check that your webhook endpoint is publicly accessible
|
|
359
|
+
|
|
360
|
+
#### "Failed to create Strapi payment record"
|
|
361
|
+
- Ensure content types are properly registered
|
|
362
|
+
- Check database permissions and connectivity
|
|
363
|
+
- Verify all required fields are provided
|
|
364
|
+
|
|
365
|
+
### Debug Mode
|
|
366
|
+
|
|
367
|
+
Enable detailed logging:
|
|
368
|
+
|
|
369
|
+
```typescript
|
|
370
|
+
// config/plugins.ts
|
|
371
|
+
'payment-plugin': {
|
|
372
|
+
config: {
|
|
373
|
+
logging: {
|
|
374
|
+
level: 'debug',
|
|
375
|
+
enableWebhookLogging: true,
|
|
376
|
+
enableDebugLogging: true,
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
},
|
|
105
380
|
```
|
|
106
381
|
|
|
107
|
-
|
|
382
|
+
### Health Checks
|
|
383
|
+
|
|
384
|
+
Monitor service health:
|
|
385
|
+
- `GET /api/payment-plugin/health` - Basic health check
|
|
386
|
+
- `GET /api/payment-plugin/status` - Detailed service status
|
|
387
|
+
|
|
388
|
+
## 📖 Documentation
|
|
389
|
+
|
|
390
|
+
Complete documentation is available in the `docs/` directory:
|
|
391
|
+
|
|
392
|
+
- [Installation Guide](./docs/INSTALLATION.md) - Detailed installation instructions
|
|
393
|
+
- [Configuration Guide](./docs/CONFIGURATION.md) - Configuration options and examples
|
|
394
|
+
- [API Reference](./docs/API_REFERENCE.md) - Complete API documentation
|
|
395
|
+
- [Usage Guide](./docs/USAGE.md) - Usage examples and best practices
|
|
396
|
+
- [Security Guide](./docs/SECURITY.md) - Security considerations and guidelines
|
|
397
|
+
- [Deployment Guide](./docs/DEPLOYMENT.md) - Production deployment checklist
|
|
398
|
+
|
|
399
|
+
## 🔄 Migration
|
|
400
|
+
|
|
401
|
+
For migration from older versions or different payment systems, see:
|
|
402
|
+
- [Strapi v5 Migration Guide](./STRAPI_V5_MIGRATION_GUIDE.md)
|
|
403
|
+
- [Stripe Service Documentation](./STRIPE_SERVICE_README.md)
|
|
404
|
+
|
|
405
|
+
## 🤝 Contributing
|
|
406
|
+
|
|
407
|
+
We welcome contributions! Please see our contributing guidelines:
|
|
408
|
+
|
|
409
|
+
1. Fork the repository
|
|
410
|
+
2. Create a feature branch
|
|
411
|
+
3. Make your changes
|
|
412
|
+
4. Add tests for new functionality
|
|
413
|
+
5. Submit a pull request
|
|
414
|
+
|
|
415
|
+
### Development Guidelines
|
|
416
|
+
|
|
417
|
+
- Follow TypeScript best practices
|
|
418
|
+
- Add JSDoc comments for all public methods
|
|
419
|
+
- Include unit tests for new features
|
|
420
|
+
- Update documentation for any API changes
|
|
421
|
+
- Follow the existing code style and formatting
|
|
422
|
+
|
|
423
|
+
## 📄 License
|
|
424
|
+
|
|
425
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
426
|
+
|
|
427
|
+
## 🙏 Acknowledgments
|
|
428
|
+
|
|
429
|
+
- [Strapi](https://strapi.io/) - The Headless CMS we all love
|
|
430
|
+
- [Stripe](https://stripe.com/) - Payment processing made simple
|
|
431
|
+
- [Stripe Elements](https://stripe.com/elements) - Beautiful payment UI components
|
|
432
|
+
|
|
433
|
+
## 📞 Support
|
|
434
|
+
|
|
435
|
+
- **Documentation**: Check the `docs/` folder for detailed guides
|
|
436
|
+
- **Issues**: Report bugs and feature requests on GitHub
|
|
437
|
+
- **Community**: Join our Discord community for discussions
|
|
438
|
+
- **Email**: Contact support for enterprise inquiries
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
**Made with ❤️ by the Strapi Community**
|
|
108
443
|
|
|
109
|
-
|
|
110
|
-
2. Install dependencies: `npm install`
|
|
111
|
-
3. Build the plugin: `npm run build`
|
|
112
|
-
4. Link the plugin to your Strapi project: `npm link`
|
|
444
|
+
For the latest updates and announcements, follow us on [Twitter](https://twitter.com/strapijs) and join our [Discord](https://discord.gg/strapi) community.
|