creatawebhoodforabusiness
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
index.ts
https://Victoria1234--ee50f49a3fb911f0867076b3cceeab13.web.val.run
A fully functional webhook system for handling order notifications in your business. This system can receive order events from e-commerce platforms, payment processors, or other systems and send appropriate notifications.
Your webhook system is now live and ready to use!
- Demo Interface: View the live demo interface
- Webhook Endpoint:
https://Victoria1234--ee50f49a3fb911f0867076b3cceeab13.web.val.run/webhook/orders
- Orders API:
https://Victoria1234--ee50f49a3fb911f0867076b3cceeab13.web.val.run/api/orders
- ✅ Webhook Receiver: Secure endpoint to receive order notifications
- ✅ Order Processing: Validates and processes order data
- ✅ Email Notifications: Sends order confirmations to customers and business
- ✅ Database Storage: Stores order history for tracking
- ✅ Security: Validates webhook signatures for security
- ✅ Demo Interface: Interactive testing and monitoring dashboard
- ✅ REST API: Full CRUD operations for order management
├── backend/
│ ├── database/
│ │ ├── migrations.ts # Database schema setup
│ │ └── queries.ts # Order database operations
│ ├── routes/
│ │ ├── webhook.ts # Webhook endpoint handler
│ │ └── orders.ts # Order management API
│ └── index.ts # Main server entry point
├── frontend/
│ └── index.html # Demo interface
├── shared/
│ └── types.ts # Shared TypeScript types
└── README.md
-
Environment Variables (optional):
WEBHOOK_SECRET
: Secret key for validating webhook signaturesBUSINESS_EMAIL
: Email address to receive order notifications
-
The webhook endpoint is available at:
/webhook/orders
Send POST requests to the webhook endpoint with order data:
curl -X POST https://your-domain.web.val.run/webhook/orders \ -H "Content-Type: application/json" \ -d '{ "event": "order.created", "data": { "orderId": "ORD-12345", "customerEmail": "customer@example.com", "customerName": "John Doe", "items": [ { "name": "Product Name", "quantity": 2, "price": 29.99 } ], "total": 59.98, "status": "paid", "timestamp": "2024-01-15T10:30:00Z" } }'
- ✅ Validates the webhook signature (if configured)
- ✅ Processes the order data
- ✅ Stores the order in the database
- ✅ Sends email notifications to customer and business
- ✅ Returns a success response
GET /api/orders
- Get recent ordersGET /api/orders/:orderId
- Get specific orderGET /api/orders/customer/:email
- Get orders by customerGET /api/status
- System statusGET /webhook/health
- Webhook health check
{ "event": "order.created", "data": { "orderId": "ORD-12345", "customerEmail": "customer@example.com", "customerName": "John Doe", "items": [ { "name": "Product Name", "quantity": 2, "price": 29.99, "sku": "PROD-001" // optional } ], "total": 59.98, "status": "paid", // paid, pending, shipped, delivered, cancelled "timestamp": "2024-01-15T10:30:00Z", "shippingAddress": { // optional "street": "123 Main St", "city": "Anytown", "state": "CA", "zipCode": "12345", "country": "USA" }, "metadata": {} // optional additional data } }
- Optional webhook signature validation using
x-webhook-signature
header - Input validation for all order data
- SQL injection protection through parameterized queries
- CORS enabled for web interface
The system automatically sends:
- Customer confirmation emails with order details
- Business notification emails (if
BUSINESS_EMAIL
is configured)
Your order notification webhook system is fully functional and ready for production use. You can:
- Test it now using the demo interface
- Integrate it with your e-commerce platform
- Monitor orders through the API endpoints
- Customize the email templates and business logic as needed