3

I am trying to integrate Paytm payment gateway Refund Api in my admin panel. I have implemented the code according to Refund Api documentation but when I hit the refund request it gives me error message "Invalid refund request" with error code "600".

https://developer.paytm.com/docs/refund-api/

   $paytmParams = array();
    $time = time();
    /* body parameters */
    $paytmParams["body"] = array(
        "mid" => 'XXXXXXXXXXXXXXXXXXXX',
        "txnType" => 'REFUND',
        "orderId" => '310',
        "txnId" => '20190914111212800110168261187592346',
        "refId" => 'ORD_REFUND_' . $time,
        "refundAmount" => 1,
    );

    $paytm = new EncodePaytm();
    $checksum = $paytm->getChecksumFromString(json_encode($paytmParams["body"]), "XXXXXXXXXXXX");

    $paytmParams["head"] = array(
        "clientId" => "C11",
        "signature" => "$checksum",
    );

    /* prepare JSON string for request */
    $post_data = json_encode($paytmParams);

    /* for Production */
    $url = "https://securegw.paytm.in/refund/apply";

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "Content-Type: application/json",
    ));
    $response = curl_exec($ch);
    $response = json_decode($response);

(
    [head] => stdClass Object
        (
            [clientId] => C11
            [responseTimestamp] => 1568657632715
            [signature] => zeA1va5JfpiRTrmhytx8TdEr6djuFUtnf8zvpxPljgMr5jNo/uZNsHBcRJfjcfsR8gKZDupPjt4/nodRDcaoq5rJ4UmEtWTJMfSG3ZHZKo4=
            [version] => v1
        )

    [body] => stdClass Object
        (
            [orderId] => 310
            [mid] => XXXXXXXXXXXXXXXXXXXX
            [resultInfo] => stdClass Object
                (
                    [resultStatus] => TXN_FAILURE
                    [resultCode] => 600
                    [resultMsg] => Invalid refund request
                )

            [txnId] => 20190914111212800110168261187592346
            [refundAmount] => 1
        )

)

Please help me why I am getting this error. I am stuck at this point from two days.

MaartenDev
  • 5,631
  • 5
  • 21
  • 33
Harry
  • 31
  • 4

0 Answers0