node.jspayumoney

How to initiate refund by payu?


I am working on payu API integration using nodejs. In a test environment where I am getting the response like:

{"status":-1,"rows":0,"message":"Something went Wrong  guid 3hnlpif04nu9nbascn1mom27le sessionId  null","result":null,"guid":"3hnlpif04nu9nbascn1mom27le","sessionId":"null","errorCode":null}

Here is my code

        let url = `https://test.payumoney.com/treasury/merchant/refundPayment`;
        url = `${url}?paymentId=${paymentID}&refundAmount=${transaction["amount"]}&merchantKey=${config['PAYU_MONEY'].merchantKey}`;
        logger.debug("PayuService: initiateRefund: Refund attempt url: ", { url } );

        let res = await request.post(url, {
            headers: {
                'authorization': config['PAYU_MONEY'].authHeader,
                'cache-control': 'no-cache',
                'Content-Type': 'application/json'
            }
        })

Where, paymentID is from payu transaction response 'payuMoneyId'.


Solution

  • Refund API doesn't work in test/sandbox environment.

    Please find the Refund API below for live environment:

    https://www.payumoney.com/treasury/merchant/refundPayment?merchantKey=merchantkeyvalue&paymentId=1234&refundAmount=10

    Please pass the Merchant Key, Payment ID, Amount

    in Params and Authorization Header in Headers.