Skip to content

Commit

Permalink
Update server
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyashkadam authored May 2, 2023
1 parent 1c7ffbb commit f23352c
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions server/routes/payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,48 +32,48 @@ router.post('/checkout', async (req, res) => {

router.post('/paymentVerification', async (req, res) => {

// const { razorpay_order_id, razorpay_payment_id, razorpay_signature } =
// req.body;
const { razorpay_order_id, razorpay_payment_id, razorpay_signature } =
req.body;

// await Payment.create({
// razorpay_order_id,
// razorpay_payment_id,
// razorpay_signature,
// });
await Payment.create({
razorpay_order_id,
razorpay_payment_id,
razorpay_signature,
});

// res.redirect(
// `${clientURL}paymentsuccess?reference=${razorpay_payment_id}`
// );
res.redirect(
`${clientURL}paymentsuccess?reference=${razorpay_payment_id}`
);

const { razorpay_order_id, razorpay_payment_id, razorpay_signature } =
req.body;
// const { razorpay_order_id, razorpay_payment_id, razorpay_signature } =
// req.body;

const body = razorpay_order_id + "|" + razorpay_payment_id;
// const body = razorpay_order_id + "|" + razorpay_payment_id;

const expectedSignature = crypto
.createHmac("sha256", process.env.RAZORPAY_APT_SECRET)
.update(body.toString())
.digest("hex");
// const expectedSignature = crypto
// .createHmac("sha256", process.env.RAZORPAY_APT_SECRET)
// .update(body.toString())
// .digest("hex");

const isAuthentic = expectedSignature === razorpay_signature;
// const isAuthentic = expectedSignature === razorpay_signature;

if (isAuthentic) {
// Database comes here
// if (isAuthentic) {
// // Database comes here

await Payment.create({
razorpay_order_id,
razorpay_payment_id,
razorpay_signature,
});
// await Payment.create({
// razorpay_order_id,
// razorpay_payment_id,
// razorpay_signature,
// });

res.redirect(
`${clientURL}paymentsuccess?reference=${razorpay_payment_id}`
);
} else {
res.status(400).json({
success: false,
});
}
// res.redirect(
// `${clientURL}paymentsuccess?reference=${razorpay_payment_id}`
// );
// } else {
// res.status(400).json({
// success: false,
// });
// }

});

Expand Down

0 comments on commit f23352c

Please sign in to comment.