razorpay / razorpay/razorpay-node

Your account does not have enough balance to carry out the refund operation. You can add funds to your account from your Razorpay dashboard or capture new payments.

Open
#414 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
243
Forks
129
PR merge metrics
No merged PRs in 30d

Description

Steps to reproduce the behavior

code: 'BAD_REQUEST_ERROR',
description: 'Your account does not have enough balance to carry out the refund operation. You can add funds to your account from your Razorpay dashboard or capture new payments.',
source: 'NA',
step: 'NA',
reason: 'NA',
metadata: {}

Expected behavior

code is correct and I have amount in that account

Actual behavior

code is correct and I have amount in that account

Code snippets
exports.refundInstants = [
    auth,
    async (req, res) => {
        try {
            const workTransaction = await WorkTransactionModel.findOne({ _id: req.body.id }, { paymentId: 1, status: 1, paidAmount: 1 });
            if (!workTransaction) return apiResponse.ErrorResponse(res, "workTransactionId not found!");

            // if (workTransaction.status == constants.RAZORPAY_STATUS_PAID) {
                // const refundData = {
                //     amount: workTransaction.paidAmount,
                //     speed: 'optimum'
                // };
                //  axios.post(`https://api.razorpay.com/v1/payments/${workTransaction.paymentId}/refund`, refundData, {
                //     auth: {
                //         username: process.env.RAZORPAY_KEY_ID,
                //         password: process.env.RAZORPAY_KEY_SECRET
                //     }
                // });
            // }

            var instance = new Razorpay({ key_id:  process.env.RAZORPAY_KEY_ID, key_secret: process.env.RAZORPAY_KEY_SECRET })

            const data = await instance.payments.refund(workTransaction.paymentId, {
                amount: 200,//workTransaction.paidAmount,
                speed: "normal",
 
            });
            return apiResponse.successResponseWithData(res, "successfully refund");
        } catch (error) {
            console.error("Error occurred during refund process:", error);
            return apiResponse.ErrorResponse(res, "Error occurred during refund process");
        }
    }
]
Node version

Node v16.4.12

Library version

razorpay-node v2.8.4

Additional Information

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the refundInstants handler in the issue and inspect the instance.payments.refund call, including its payment ID and amount. Reproduce with Node v16.4.12 and razorpay-node v2.8.4 while checking the supplied Razorpay error details. Done requires determining whether this is an integration or account issue or a library defect, with a documented reproducible outcome.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.