point of sale order contoller
This commit is contained in:
parent
72584b4dd9
commit
fcf344518c
@ -23,11 +23,11 @@ const generateOrderId = async () => {
|
||||
|
||||
export const createOrderCheckout = async (req, res) => {
|
||||
try {
|
||||
const { address, cart, user, SalesType, paymentMode } =
|
||||
const { address, cart, user, paymentMode } =
|
||||
req.body;
|
||||
// console.log(req.body)
|
||||
// Perform validation
|
||||
if (!address || !cart || cart.length === 0 || !SalesType || !user || !paymentMode) {
|
||||
if (!address || !cart || cart.length === 0 || !user || !paymentMode) {
|
||||
return res.status(400).json({ message: "Invalid order data" });
|
||||
}
|
||||
|
||||
@ -71,7 +71,6 @@ export const createOrderCheckout = async (req, res) => {
|
||||
...restOfShippingInfo, // Include other shipping information
|
||||
},
|
||||
user, // Assuming you have authenticated users
|
||||
SalesType,
|
||||
paymentMode,
|
||||
});
|
||||
|
||||
|
@ -76,13 +76,13 @@ export const checkout = async (req, res) => {
|
||||
}
|
||||
|
||||
// Extract required data from request parameters and body
|
||||
const { email } = req.params;
|
||||
const { address, cart, user, SalesType, paymentMode, subtotal } = req.body;
|
||||
// const { email } = req.params;
|
||||
const { address, cart, user, paymentMode, subtotal } = req.body;
|
||||
|
||||
// Check for required parameters
|
||||
if (!email) {
|
||||
return res.status(400).send({ message: "Please enter the email" });
|
||||
}
|
||||
// if (!email) {
|
||||
// return res.status(400).send({ message: "Please enter the email" });
|
||||
// }
|
||||
|
||||
if (cart.length < 1) {
|
||||
return res.status(400).json({ message: "Cart is empty!" });
|
||||
@ -136,7 +136,6 @@ export const checkout = async (req, res) => {
|
||||
...restOfShippingInfo,
|
||||
},
|
||||
user,
|
||||
SalesType,
|
||||
paymentMode,
|
||||
razorpay_order_id: order.id,
|
||||
});
|
||||
@ -372,8 +371,10 @@ export const handlePayment = async (req, res) => {
|
||||
|
||||
// Add any other key-value pairs as needed
|
||||
},
|
||||
success_url: `${process.env.FRONTEND_URL}/cart`,
|
||||
cancel_url: `${process.env.FRONTEND_URL}/error`,
|
||||
// success_url: `${process.env.FRONTEND_URL}/cart`,
|
||||
sccess_url: `httphttp://localhost:5000/#/success`,
|
||||
// cancel_url: `${process.env.FRONTEND_URL}/error`,
|
||||
cancel_url: `http://localhost:5000/#/error`,
|
||||
});
|
||||
// res.json({ sessionId: session.id });
|
||||
|
||||
|
@ -102,13 +102,9 @@ const POSorderSchema = new mongoose.Schema(
|
||||
total_amount: { type: Number, default: 0 },
|
||||
weight: { type: Number, default: 0 },
|
||||
|
||||
SalesType: {
|
||||
type: String,
|
||||
enum: ["inStoreDelivery", "shipToCustomer"],
|
||||
},
|
||||
paymentMode: {
|
||||
type: String,
|
||||
enum: ["QRCode", "Cash","SendPaymentLink"],
|
||||
enum: ["QRCode", "Cash"],
|
||||
},
|
||||
payment_status: {
|
||||
type: String,
|
||||
|
Loading…
Reference in New Issue
Block a user