@xenterprises/fastify-xstripe 1.0.0
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/.dockerignore +62 -0
- package/.env.example +116 -0
- package/API.md +574 -0
- package/CHANGELOG.md +96 -0
- package/EXAMPLES.md +883 -0
- package/LICENSE +15 -0
- package/MIGRATION.md +374 -0
- package/QUICK_START.md +179 -0
- package/README.md +331 -0
- package/SECURITY.md +465 -0
- package/TESTING.md +357 -0
- package/index.d.ts +309 -0
- package/package.json +53 -0
- package/server/app.js +557 -0
- package/src/handlers/defaultHandlers.js +355 -0
- package/src/handlers/exampleHandlers.js +278 -0
- package/src/handlers/index.js +8 -0
- package/src/index.js +10 -0
- package/src/utils/helpers.js +220 -0
- package/src/webhooks/webhooks.js +72 -0
- package/src/xStripe.js +45 -0
- package/test/handlers.test.js +959 -0
- package/test/xStripe.integration.test.js +409 -0
package/.dockerignore
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Git
|
|
2
|
+
.git
|
|
3
|
+
.gitignore
|
|
4
|
+
.gitattributes
|
|
5
|
+
|
|
6
|
+
# Node modules (will be installed in container)
|
|
7
|
+
node_modules
|
|
8
|
+
npm-debug.log*
|
|
9
|
+
yarn-debug.log*
|
|
10
|
+
yarn-error.log*
|
|
11
|
+
lerna-debug.log*
|
|
12
|
+
|
|
13
|
+
# Dependencies
|
|
14
|
+
.npm
|
|
15
|
+
.eslintcache
|
|
16
|
+
*.tsbuildinfo
|
|
17
|
+
|
|
18
|
+
# Temporary files
|
|
19
|
+
.DS_Store
|
|
20
|
+
Thumbs.db
|
|
21
|
+
*.tmp
|
|
22
|
+
.env.local
|
|
23
|
+
.env.*.local
|
|
24
|
+
|
|
25
|
+
# IDE
|
|
26
|
+
.vscode
|
|
27
|
+
.idea
|
|
28
|
+
*.swp
|
|
29
|
+
*.swo
|
|
30
|
+
*.swn
|
|
31
|
+
*~
|
|
32
|
+
|
|
33
|
+
# Test & Coverage
|
|
34
|
+
coverage
|
|
35
|
+
.nyc_output
|
|
36
|
+
test
|
|
37
|
+
*.test.js
|
|
38
|
+
|
|
39
|
+
# Build artifacts (if any)
|
|
40
|
+
dist
|
|
41
|
+
build
|
|
42
|
+
out
|
|
43
|
+
|
|
44
|
+
# Docker files (not needed in image)
|
|
45
|
+
Dockerfile*
|
|
46
|
+
docker-compose*.yml
|
|
47
|
+
.dockerignore
|
|
48
|
+
|
|
49
|
+
# CI/CD
|
|
50
|
+
.github
|
|
51
|
+
.gitlab-ci.yml
|
|
52
|
+
|
|
53
|
+
# Documentation (optional - include if you want docs in image)
|
|
54
|
+
# *.md
|
|
55
|
+
|
|
56
|
+
# Example/demo files
|
|
57
|
+
examples
|
|
58
|
+
demo
|
|
59
|
+
|
|
60
|
+
# Logs
|
|
61
|
+
logs
|
|
62
|
+
*.log
|
package/.env.example
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# ============================================================================
|
|
2
|
+
# xStripe Fastify Plugin - Environment Configuration
|
|
3
|
+
# ============================================================================
|
|
4
|
+
# This file defines environment variables for the xStripe module.
|
|
5
|
+
# Copy this to .env and update values for your environment.
|
|
6
|
+
# ============================================================================
|
|
7
|
+
|
|
8
|
+
# ============================================================================
|
|
9
|
+
# SERVER CONFIGURATION
|
|
10
|
+
# ============================================================================
|
|
11
|
+
|
|
12
|
+
# Server port (default: 3000)
|
|
13
|
+
PORT=3000
|
|
14
|
+
|
|
15
|
+
# Node environment (development | production | test)
|
|
16
|
+
NODE_ENV=development
|
|
17
|
+
|
|
18
|
+
# Server hostname/domain (used in webhook URLs and responses)
|
|
19
|
+
# Update this to your actual domain in production
|
|
20
|
+
DOMAIN=http://localhost:3000
|
|
21
|
+
|
|
22
|
+
# ============================================================================
|
|
23
|
+
# STRIPE CONFIGURATION - REQUIRED
|
|
24
|
+
# ============================================================================
|
|
25
|
+
|
|
26
|
+
# Stripe API Key (Secret Key)
|
|
27
|
+
# Get from: https://dashboard.stripe.com/apikeys
|
|
28
|
+
# Format: sk_test_... (test mode) or sk_live_... (production)
|
|
29
|
+
# NEVER commit this value - use environment variables only
|
|
30
|
+
STRIPE_API_KEY=sk_test_your_key_here
|
|
31
|
+
|
|
32
|
+
# Stripe Webhook Signing Secret
|
|
33
|
+
# Get from: https://dashboard.stripe.com/webhooks
|
|
34
|
+
# Copy the "Signing secret" for your webhook endpoint
|
|
35
|
+
# Format: whsec_...
|
|
36
|
+
STRIPE_WEBHOOK_SECRET=whsec_your_secret_here
|
|
37
|
+
|
|
38
|
+
# ============================================================================
|
|
39
|
+
# WEBHOOK CONFIGURATION
|
|
40
|
+
# ============================================================================
|
|
41
|
+
|
|
42
|
+
# Webhook endpoint path (relative to domain)
|
|
43
|
+
# Default: /webhooks/stripe
|
|
44
|
+
# STRIPE_WEBHOOK_PATH=/webhooks/stripe
|
|
45
|
+
|
|
46
|
+
# Webhook events to listen for (space or comma-separated)
|
|
47
|
+
# Default: all supported events
|
|
48
|
+
# Examples:
|
|
49
|
+
# customer.created,customer.updated,customer.deleted
|
|
50
|
+
# invoice.created,invoice.finalized,invoice.paid
|
|
51
|
+
# charge.succeeded,charge.failed
|
|
52
|
+
# STRIPE_WEBHOOK_EVENTS=*
|
|
53
|
+
|
|
54
|
+
# ============================================================================
|
|
55
|
+
# LOGGING & MONITORING
|
|
56
|
+
# ============================================================================
|
|
57
|
+
|
|
58
|
+
# Fastify logger level (trace, debug, info, warn, error, fatal)
|
|
59
|
+
LOG_LEVEL=info
|
|
60
|
+
|
|
61
|
+
# Enable webhook event logging
|
|
62
|
+
# LOG_WEBHOOK_EVENTS=true
|
|
63
|
+
|
|
64
|
+
# Enable handler execution logging
|
|
65
|
+
# LOG_HANDLER_EXECUTION=true
|
|
66
|
+
|
|
67
|
+
# ============================================================================
|
|
68
|
+
# ERROR HANDLING & RECOVERY
|
|
69
|
+
# ============================================================================
|
|
70
|
+
|
|
71
|
+
# Retry failed webhook handler executions
|
|
72
|
+
# ENABLE_HANDLER_RETRY=false
|
|
73
|
+
|
|
74
|
+
# Max retry attempts for failed handlers
|
|
75
|
+
# HANDLER_RETRY_MAX_ATTEMPTS=3
|
|
76
|
+
|
|
77
|
+
# Retry delay in milliseconds
|
|
78
|
+
# HANDLER_RETRY_DELAY_MS=5000
|
|
79
|
+
|
|
80
|
+
# ============================================================================
|
|
81
|
+
# SECURITY
|
|
82
|
+
# ============================================================================
|
|
83
|
+
|
|
84
|
+
# Enable HTTPS enforcement (if behind reverse proxy)
|
|
85
|
+
# HTTPS_ONLY=false
|
|
86
|
+
|
|
87
|
+
# Rate limiting: max webhook requests per minute
|
|
88
|
+
# WEBHOOK_RATE_LIMIT_WINDOW=1m
|
|
89
|
+
# WEBHOOK_RATE_LIMIT_MAX=1000
|
|
90
|
+
|
|
91
|
+
# Timeout for webhook handler execution (milliseconds)
|
|
92
|
+
# Default: 30000 (30 seconds)
|
|
93
|
+
# WEBHOOK_HANDLER_TIMEOUT=30000
|
|
94
|
+
|
|
95
|
+
# ============================================================================
|
|
96
|
+
# STRIPE ACCOUNT CONFIGURATION
|
|
97
|
+
# ============================================================================
|
|
98
|
+
|
|
99
|
+
# Stripe API Version (optional - uses account default if not set)
|
|
100
|
+
# Format: YYYY-MM-DD or leave empty
|
|
101
|
+
# STRIPE_API_VERSION=
|
|
102
|
+
|
|
103
|
+
# Enable Stripe CLI webhooks in development
|
|
104
|
+
# Set to true if using: stripe listen --forward-to localhost:3000/webhooks/stripe
|
|
105
|
+
# STRIPE_CLI_MODE=false
|
|
106
|
+
|
|
107
|
+
# ============================================================================
|
|
108
|
+
# DATABASE/STORAGE (optional - for persisting event data)
|
|
109
|
+
# ============================================================================
|
|
110
|
+
|
|
111
|
+
# Database URL for event persistence (optional)
|
|
112
|
+
# Example: postgresql://user:pass@localhost/stripe_events
|
|
113
|
+
# DATABASE_URL=
|
|
114
|
+
|
|
115
|
+
# Enable event persistence
|
|
116
|
+
# PERSIST_WEBHOOK_EVENTS=false
|