This guide covers setting up your Stripe account, configuring payment processing, and implementing webhooks for order status updates.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/aluxey/E-Commerce/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- A Stripe account
- Access to your API server configuration
- HTTPS endpoint for webhooks (required for production)
Create Stripe Account
Sign Up for Stripe
- Go to stripe.com
- Click Start now or Sign in
- Complete account registration
- Verify your email address
Get API Keys
Retrieve your API keys for both test and production environments.Access API Keys
- Go to Stripe Dashboard
- Click Developers > API keys
Copy Test Keys
For development:
- Toggle to Test mode (top right)
- Copy the Secret key (starts with
sk_test_) - Copy the Publishable key (starts with
pk_test_)
Test mode uses test card numbers and doesn’t process real payments.
Configure Webhook
Webhooks notify your server when payment status changes.Create Webhook Endpoint
- In Stripe Dashboard, go to Developers > Webhooks
- Click Add endpoint
- Enter your endpoint URL:
- Development: Use Stripe CLI for testing
- Production:
https://your-api-domain.com/api/stripe/webhook
Select Events to Listen
Add these events:
payment_intent.succeeded- Payment completed successfullypayment_intent.payment_failed- Payment failedpayment_intent.canceled- Payment canceled
Test Cards
Use these test card numbers in test mode:| Card Number | Scenario | CVC | Date |
|---|---|---|---|
4242 4242 4242 4242 | Successful payment | Any 3 digits | Any future date |
4000 0000 0000 9995 | Payment declined | Any 3 digits | Any future date |
4000 0025 0000 3155 | Requires authentication (3D Secure) | Any 3 digits | Any future date |
4000 0000 0000 0002 | Card declined | Any 3 digits | Any future date |
Complete test card list: Stripe Testing Cards
Local Webhook Testing
Test webhooks locally using the Stripe CLI.Forward Webhooks to Local Server
whsec_. Use this as your STRIPE_WEBHOOK_SECRET during development.Webhook Implementation
The API server handles three webhook events:Payment Succeeded
Whenpayment_intent.succeeded is received:
- Order status updated to
paid - Order confirmation email sent to shop owner
- Customer receives payment confirmation
/api/src/server.js:52-78
Payment Failed
Whenpayment_intent.payment_failed is received:
- Order status updated to
failed - User can retry payment or create new order
/api/src/server.js:80-89
Payment Canceled
Whenpayment_intent.canceled is received:
- Order status updated to
canceled - No further action required
/api/src/server.js:90-99
Verify Webhook Signatures
The API automatically verifies webhook signatures to prevent tampering: Code reference:/api/src/server.js:38-46
Payment Flow
Here’s how the complete payment flow works:Customer Initiates Checkout
- User adds items to cart
- Clicks “Checkout”
- Frontend calls
/api/checkoutendpoint
Server Creates Payment Intent
- API validates cart items and stock
- Creates order in database with
pendingstatus - Creates Stripe Payment Intent
- Returns
clientSecretto frontend
/api/src/server.js:207-281Customer Completes Payment
- Frontend displays Stripe payment form
- Customer enters card details
- Stripe processes payment
- Payment Intent status changes
Production Checklist
Before going live:- Complete Stripe business profile verification
- Switch to live API keys
- Update webhook endpoint to production URL
- Test webhook with live endpoint
- Configure proper error handling
- Set up Stripe email receipts
- Enable Stripe Radar for fraud detection
- Review and configure payment methods (cards, Apple Pay, Google Pay)
Next Steps
Troubleshooting
Webhook Not Receiving Events
- Verify endpoint URL is correct and accessible
- Check webhook events are selected in Stripe Dashboard
- Ensure endpoint returns
200 OKstatus - Check server logs for errors
Payment Intent Creation Fails
- All products have valid prices in database
- Cart items include
variant_id - Variants exist with non-null prices
Signature Verification Failed
- Wrong
STRIPE_WEBHOOK_SECRET - Request body modified before verification
- Using wrong secret (test vs. production)
express.raw() middleware for the webhook route: