@reeboot/strapi-payment-plugin 0.0.1 → 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 +378 -119
- 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/admin/src/pluginId.d.ts +1 -1
- package/dist/server/index.js +1746 -984
- package/dist/server/index.mjs +1748 -986
- package/dist/server/src/bootstrap.d.ts +5 -11
- package/dist/server/src/config/index.d.ts +0 -10
- package/dist/server/src/content-types/customer/index.d.ts +69 -0
- package/dist/server/src/content-types/index.d.ts +123 -39
- package/dist/server/src/content-types/{product.d.ts → order/index.d.ts} +26 -19
- package/dist/server/src/content-types/{subscription.d.ts → payment/index.d.ts} +30 -21
- package/dist/server/src/controllers/controller.d.ts +5 -12
- package/dist/server/src/controllers/index.d.ts +29 -34
- package/dist/server/src/controllers/stripe.d.ts +104 -0
- package/dist/server/src/index.d.ts +179 -139
- 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 +11 -16
- package/dist/server/src/services/index.d.ts +2 -38
- package/dist/server/src/services/{stripeDriver.d.ts → stripe.d.ts} +52 -59
- package/dist/server/src/types/index.d.ts +179 -0
- package/package.json +20 -25
- package/dist/_chunks/App-DD7GyuRr.mjs +0 -1424
- package/dist/_chunks/App-KZVBFRwo.js +0 -1424
- 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/src/controllers/product.d.ts +0 -18
- package/dist/server/src/controllers/subscription.d.ts +0 -16
- package/dist/server/src/controllers/webhook.d.ts +0 -10
- package/dist/server/src/routes/content-api.d.ts +0 -12
- package/dist/server/src/routes/product.d.ts +0 -2
- package/dist/server/src/routes/refund-routes.d.ts +0 -13
- package/dist/server/src/routes/subscription.d.ts +0 -5
- package/dist/server/src/routes/webhook.d.ts +0 -15
- package/dist/server/src/services/paypalDriver.d.ts +0 -47
- package/dist/server/src/services/product.d.ts +0 -7
- package/dist/server/src/services/service.d.ts +0 -26
- package/dist/server/src/services/subscription.d.ts +0 -9
- package/dist/server/src/services/sync.d.ts +0 -13
- package/jest.config.js +0 -13
package/README.md
CHANGED
|
@@ -1,185 +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
|
-
|
|
6
|
-
Strapi
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
## 🚀 Features
|
|
9
11
|
|
|
10
|
-
|
|
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
|
|
11
18
|
|
|
12
|
-
|
|
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
|
|
13
25
|
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
- Payment link generation for products
|
|
21
|
-
- Import products from Stripe
|
|
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
|
|
22
32
|
|
|
23
|
-
##
|
|
33
|
+
## 📋 Prerequisites
|
|
24
34
|
|
|
25
|
-
1
|
|
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:
|
|
45
|
+
```bash
|
|
46
|
+
cp -r payment-plugin /path/to/your/strapi-project/src/plugins/
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
2. Install dependencies:
|
|
26
50
|
```bash
|
|
27
|
-
npm install @
|
|
51
|
+
npm install @stripe/stripe-js stripe
|
|
28
52
|
```
|
|
29
53
|
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
module.exports = {
|
|
54
|
+
3. Configure the plugin in `config/plugins.ts`:
|
|
55
|
+
```typescript
|
|
56
|
+
export default () => ({
|
|
34
57
|
'payment-plugin': {
|
|
35
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
|
+
},
|
|
36
70
|
},
|
|
37
|
-
};
|
|
71
|
+
});
|
|
38
72
|
```
|
|
39
73
|
|
|
40
|
-
|
|
74
|
+
### Method 2: Development Setup
|
|
41
75
|
|
|
42
|
-
1.
|
|
76
|
+
1. Navigate to the plugin directory:
|
|
77
|
+
```bash
|
|
78
|
+
cd src/plugins/payment-plugin
|
|
43
79
|
```
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
PAYPAL_CLIENT_SECRET=your_paypal_client_secret
|
|
49
|
-
PAYPAL_WEBHOOK_ID=your_paypal_webhook_id
|
|
80
|
+
|
|
81
|
+
2. Install dependencies:
|
|
82
|
+
```bash
|
|
83
|
+
npm install
|
|
50
84
|
```
|
|
51
85
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
86
|
+
3. Build the plugin:
|
|
87
|
+
```bash
|
|
88
|
+
npm run build
|
|
89
|
+
```
|
|
56
90
|
|
|
57
|
-
##
|
|
91
|
+
## ⚙️ Configuration
|
|
58
92
|
|
|
59
|
-
###
|
|
93
|
+
### Environment Variables
|
|
60
94
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
},
|
|
75
137
|
},
|
|
76
|
-
}
|
|
138
|
+
},
|
|
77
139
|
});
|
|
78
|
-
const payment = await response.json();
|
|
79
140
|
```
|
|
80
141
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
```javascript
|
|
84
|
-
// POST /strapi-payment-plugin/webhook/:gateway
|
|
85
|
-
// The webhook URL should be configured in your Stripe/PayPal dashboard
|
|
86
|
-
```
|
|
142
|
+
## 🚀 Quick Start
|
|
87
143
|
|
|
88
|
-
###
|
|
144
|
+
### 1. Create a Payment Intent
|
|
89
145
|
|
|
90
146
|
```javascript
|
|
91
|
-
|
|
92
|
-
|
|
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', {
|
|
93
159
|
method: 'POST',
|
|
94
160
|
headers: {
|
|
95
161
|
'Content-Type': 'application/json',
|
|
162
|
+
'Authorization': 'Bearer YOUR_JWT_TOKEN'
|
|
96
163
|
},
|
|
97
|
-
body: JSON.stringify(
|
|
98
|
-
gateway: 'stripe', // or 'paypal'
|
|
99
|
-
transactionId: 'pi_123', // or PayPal transaction ID
|
|
100
|
-
amount: 500, // refund amount in cents
|
|
101
|
-
options: {
|
|
102
|
-
// gateway-specific options
|
|
103
|
-
},
|
|
104
|
-
}),
|
|
164
|
+
body: JSON.stringify(paymentData)
|
|
105
165
|
});
|
|
106
|
-
|
|
166
|
+
|
|
167
|
+
const result = await response.json();
|
|
168
|
+
console.log(result.data.client_secret); // Use this for Stripe Elements
|
|
107
169
|
```
|
|
108
170
|
|
|
109
|
-
###
|
|
171
|
+
### 2. Handle Payment on Frontend
|
|
110
172
|
|
|
111
173
|
```javascript
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
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
|
+
});
|
|
116
187
|
|
|
117
|
-
|
|
188
|
+
if (error) {
|
|
189
|
+
console.error('Payment failed:', error);
|
|
190
|
+
} else {
|
|
191
|
+
console.log('Payment succeeded!');
|
|
192
|
+
}
|
|
193
|
+
```
|
|
118
194
|
|
|
119
|
-
|
|
195
|
+
### 3. Create a Customer
|
|
120
196
|
|
|
121
197
|
```javascript
|
|
122
|
-
|
|
123
|
-
|
|
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', {
|
|
124
211
|
method: 'POST',
|
|
125
212
|
headers: {
|
|
126
213
|
'Content-Type': 'application/json',
|
|
214
|
+
'Authorization': 'Bearer YOUR_JWT_TOKEN'
|
|
127
215
|
},
|
|
128
|
-
body: JSON.stringify(
|
|
129
|
-
data: {
|
|
130
|
-
name: 'Product Name',
|
|
131
|
-
description: 'Product Description',
|
|
132
|
-
price: 100, // in dollars
|
|
133
|
-
currency: 'USD',
|
|
134
|
-
isSubscription: false,
|
|
135
|
-
},
|
|
136
|
-
}),
|
|
216
|
+
body: JSON.stringify(customerData)
|
|
137
217
|
});
|
|
138
|
-
const product = await response.json();
|
|
139
218
|
```
|
|
140
219
|
|
|
141
|
-
|
|
220
|
+
### 4. Process Refunds
|
|
142
221
|
|
|
143
222
|
```javascript
|
|
144
|
-
|
|
145
|
-
|
|
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', {
|
|
146
233
|
method: 'POST',
|
|
234
|
+
headers: {
|
|
235
|
+
'Content-Type': 'application/json',
|
|
236
|
+
'Authorization': 'Bearer YOUR_JWT_TOKEN'
|
|
237
|
+
},
|
|
238
|
+
body: JSON.stringify(refundData)
|
|
147
239
|
});
|
|
148
|
-
const result = await response.json();
|
|
149
240
|
```
|
|
150
241
|
|
|
151
|
-
|
|
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
|
|
152
296
|
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
|
159
310
|
```
|
|
160
311
|
|
|
161
|
-
|
|
312
|
+
### Building and Development
|
|
162
313
|
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
+
},
|
|
169
378
|
},
|
|
170
|
-
|
|
171
|
-
stripeProductId: 'prod_123',
|
|
172
|
-
}),
|
|
173
|
-
});
|
|
174
|
-
const result = await response.json();
|
|
379
|
+
},
|
|
175
380
|
```
|
|
176
381
|
|
|
177
|
-
|
|
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
|
|
178
439
|
|
|
179
|
-
|
|
180
|
-
2. Install dependencies: `npm install`
|
|
181
|
-
3. Build the plugin: `npm run build`
|
|
182
|
-
4. Link the plugin to your Strapi project: `npm link`
|
|
440
|
+
---
|
|
183
441
|
|
|
442
|
+
**Made with ❤️ by the Strapi Community**
|
|
184
443
|
|
|
185
|
-
|
|
444
|
+
For the latest updates and announcements, follow us on [Twitter](https://twitter.com/strapijs) and join our [Discord](https://discord.gg/strapi) community.
|