Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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. #414

Open
bala07890 opened this issue May 16, 2024 · 0 comments

Comments

@bala07890
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant