Fix order placement 403 error and enhance payment flow with wallet deduction #42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Users were encountering "Failed to place order (403)" errors when attempting to place orders through the frontend. Additionally, the payment flow for wallet transactions required multiple API calls, and the delivery ETA displayed incorrect timing.
Root Causes
Type Mismatch: Frontend was converting
slotIdto integer usingparseInt(), but the backendDeliverySlotmodel uses UUID as the primary key type, causing the order creation to fail with slot not found errors.Missing Payment Context: The backend had no awareness of payment method during order creation, preventing proper wallet handling in a single transaction.
Inefficient Payment Flow: Wallet payments required two separate API calls - one to create the order (PENDING status), and another to deduct from wallet and confirm the order.
Solution
Backend Changes
CreateOrderRequest.javapaymentMethodfield to capture payment type during order creationOrderService.javaWalletServicefor direct wallet operationscreateOrder()method to handle wallet payments atomically:paymentMethod == "wallet": deducts from user's wallet immediatelyCONFIRMEDfor wallet paymentsPENDINGuntil processed through existing payment gateway flowFrontend Changes
Checkout.jsxslotId: parseInt(selectedSlot)toslotId: selectedSlotto preserve UUID string formatpaymentMethodto order creation request payloadpayWithWalletAPI callOrderSuccess.jsxBenefits
Technical
User Experience
Business
Testing
Flow Comparison
Before (Wallet Payment)
After (Wallet Payment)
Card/UPI/COD flows remain unchanged and continue to use the existing payment gateway process.
Files Changed
backend/src/main/java/com/srmiggy/dto/CreateOrderRequest.javabackend/src/main/java/com/srmiggy/service/OrderService.javafrontend/src/pages/Checkout.jsxfrontend/src/pages/OrderSuccess.jsxAll changes are minimal and surgical, maintaining existing code patterns and backward compatibility.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.