Not getting response after successful payment
See original GitHub issueSteps to reproduce the behavior
const PROCEED_PAYMENT_HANDLER = async () => { const { data : {Order} } = await axios.post("http://localhost:5000/api/razor/PayInit", { amount: location.state.TotalPrice }, { withCredentials: true }) const { data : {Key}} = await axios.get("http://localhost:5000/api/razor/getKey", { withCredentials: true }) const options = { "key": Key, "amount": Order.amount, "currency": "INR", "name": "Pepper Fry Payment Page", "description": "Order Payment", "image": "https://cdn.icon-icons.com/icons2/3310/PNG/96/library_books_school_shelving_rack_furniture_icon_209277.png", "order_id": Order.id, "callback_url": "http://localhost:5000/api/razor/PayVerification/", "prefill": { "name": CustomerData.Name, "email": CustomerData.Email, "contact": CustomerData.PhoneNumber }, "notes": { "address": "Razorpay Corporate Office" }, "theme": { "color": "#E85B45" } }; const rzp1 = new window.Razorpay(options); rzp1.open() }
Expected behavior
I expected to return this ! but it didn’t
{ "razorpay_payment_id": "pay_29QQoUBi66xm2f", "razorpay_order_id": "order_9A33XWu170gUtm", "razorpay_signature": "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d" }
Actual behavior
My code returend this
{}
Code snippets
Frontend Code
`
const PROCEED_PAYMENT_HANDLER = async () => {
const { data : {Order} } = await axios.post("http://localhost:5000/api/razor/PayInit", { amount: location.state.TotalPrice }, { withCredentials: true })
const { data : {Key}} = await axios.get("http://localhost:5000/api/razor/getKey", { withCredentials: true })
const options = {
"key": Key,
"amount": Order.amount,
"currency": "INR",
"name": "Pepper Fry Payment Page",
"description": "Order Payment",
"image": "https://cdn.icon-icons.com/icons2/3310/PNG/96/library_books_school_shelving_rack_furniture_icon_209277.png",
"order_id": Order.id,
"callback_url": "http://localhost:5000/api/razor/PayVerification/",
"prefill": {
"name": CustomerData.Name,
"email": CustomerData.Email,
"contact": CustomerData.PhoneNumber
},
"notes": {
"address": "Razorpay Corporate Office"
},
"theme": {
"color": "#E85B45"
}
};
const rzp1 = new window.Razorpay(options);
rzp1.open()
}
`
Backend Code
`
const express = require("express");
const router = express.Router();
const Razorpay = require("razorpay");
const { checkerCustomer } = require("../middleware/checker");
const crypto = require("crypto");
const instance = new Razorpay({
key_id: process.env.RAZOR_API_KEY,
key_secret: process.env.RAZOR_SECRET_KEY,
});
router.post("/razor/PayInit", checkerCustomer, async (req, res) => {
const options = {
amount: req.body.amount * 100,
currency: "INR",
};
const order = await instance.orders.create(options);
res.status(200).json({ success: true, Order: order });
});
router.post("/razor/PayVerification", async (req, res) => {
try {
console.log(req.body);
res.status(200).json({ success: true });
} catch (err) {
res.status(500).json({ success: false });
}
});
router.get("/razor/getKey", checkerCustomer, async (req, res) => {
try {
res.status(200).json({ success: true, Key: process.env.RAZOR_API_KEY });
} catch (err) {
return res.status(501).json({ success: false, error: err });
}
});
module.exports = router;
`
Node version
v16.14.2
Library version
v2.8.4
Additional Information
No response
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (2 by maintainers)
@ankitdas13 thanks a lot that worked !
Closing this issue for now, If someone is facing the same issue you can check this doc for checkout integration.