Security Hardening, Redis Infrastructure & Catalog Intelligence
Eliminated critical checkout vulnerabilities through authoritative server-side price resolution and payment replay prevention, implemented automated webhook order recovery for closed tabs, hardened production Redis modules (event bus, workflows, cache, locking), eliminated redeploy cold-start settings race conditions, added default best-seller sorting, dynamic live store counters with midnight revalidation, and direct backend out-of-stock reflection.
Detailed Changes
- FixedAuthoritative Server-Side Pricing: Eliminated client-supplied item pricing in checkout handoff and payment creation. All item prices and line-item subtotals are now looked up and calculated authoritatively against the Medusa PostgreSQL catalog.
- FixedPayment Replay Prevention: Added cryptographic and database validation to ensure every Razorpay payment matches the exact order total in paise, and verified that a payment ID cannot be replayed across multiple orders.
- FixedClosed-Tab Order Recovery Webhook: Implemented studio_pending_razorpay_orders PostgreSQL tracking table and automated payment.captured / order.paid webhook fulfillment, guaranteeing orders are never lost if customers close their tab after paying.
- RefactorProduction Redis Architecture: Configured official Medusa Redis modules for BullMQ event-bus (@medusajs/event-bus-redis), workflow engine (@medusajs/workflow-engine-redis), cache (@medusajs/cache-redis), and distributed locking (@medusajs/medusa/locking with @medusajs/medusa/locking-redis provider). Dispatches order.placed event to BullMQ.
- FixedCold-Start Settings Race Condition: Replaced unawaited background PostgreSQL queries with memoized async coalescing loaders (loadPickupSettingsAsync, loadPincodeRulesAsync, evaluatePincodeAsync), guaranteeing accurate delivery rates immediately upon server boots and redeploys.
- AddedBest-Selling Default Catalog Sort: Catalog products are now sorted by studio best-seller scoring by default, placing hero Sojat henna cones and kits at the top of the collection with clear "Sort: Best Selling" filter selection.
- AddedDynamic Store Stats & Midnight Revalidation: Added /store/store-stats endpoint providing real-time live product counts (26 Live in store) and delivered counts (5,500+ Products Delivered, properly filtering legacy imported WooCommerce orders). Added daily 12:00 AM midnight background cron to trigger Next.js cache revalidation.
- FixedBackend Out-of-Stock Reflection: Added +metadata,+variants.metadata to /store/products query fields and updated product normalization so products and variants marked out of stock in Medusa Admin immediately reflect as "Out of Stock" with disabled Add to Bag buttons on the storefront.
- FixedFooter Contact Icons Hover Contrast: Restored optimal icon contrast for WhatsApp, Email, and Call buttons in the footer, ensuring crisp visibility against terracotta hover states.