question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not getting response after successful payment

See original GitHub issue

Steps 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:closed
  • Created 10 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Znoy108xcommented, Nov 25, 2022

@ankitdas13 thanks a lot that worked !

0reactions
ankitdas13commented, Nov 30, 2022

Closing this issue for now, If someone is facing the same issue you can check this doc for checkout integration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Payment status updates | Stripe Documentation
Monitor and verify payment status, so that you can respond to successful and failing payments.
Read more >
Not receiving any response from server after payment success
I want to use Authorize.Net for payment but got stuck in middle. There is not any Error message, I am using SANDBOX for ......
Read more >
The 3 Most Effective Ways to Deal With Failed Payments
1) Communicate the Failure. Customers may not be aware that their payment failed. While some issuing banks and systems automatically inform them ...
Read more >
Handling system failures during payment communication
If the charge request has either the declined or successful status, then the charge response was correctly received and processed by our system....
Read more >
Fix issues with orders or payments to merchants - Google Pay ...
It may take up to 3 days for your bank to complete the transaction. After the processing period, the transaction status will change...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found