Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KEY_NOT_CONFIGURED error showing in phonepe php integration

Tags:

php

phonepe

I am trying to integrate phonepe payment gateway which is working correctly in UAT server but not working in production server. I am getting an error in response once payment is done.

public function request(Request $request)
    {
        $input = $request->all();
        $orderId = $input['orderId'];

        $firebaseController = new FirebaseController();
        $order = $firebaseController->getOrder($orderId);
        $price = $firebaseController->getPrice($order)*100;

        //Calculating UserRef i.e. userId from firebase field
        $fullUserDocPath = $order['userRef']->name();
        $userRef = explode('/', $fullUserDocPath)[6];

        $data = array (
          'merchantId' => getenv('PHONEPE_PRD_MERCHANT_ID'), //merchantid is correct
          'merchantTransactionId' => $orderId,
          'merchantUserId' => $userRef,
          'amount' => 100,
          'redirectUrl' => route('response'),
          'redirectMode' => 'POST',
          'callbackUrl' => route('response'),
          'mobileNumber' => substr($order['phoneNumber'], 3),
          'paymentInstrument' =>
           array (
            'type' => 'PAY_PAGE',
          ),
        );


        $encode = base64_encode(json_encode($data));

        $saltKey = getenv('PHONEPE_PRD_SALT');
        $saltIndex = getenv('PHONEPE_PRD_SALT_INDEX');

        $string = $encode.'/pg/v1/pay'.$saltKey;
        $sha256 = hash('sha256',$string);

        $finalXHeader = $sha256.'###'.$saltIndex;

        $response = Curl::to('https://api.phonepe.com/apis/hermes/pg/v1/pay')
                ->withHeader('Content-Type:application/json')
                ->withHeader('X-VERIFY:'.$finalXHeader)
                ->withData(json_encode(['request' => $encode]))
                ->post();

        $rData = json_decode($response);

        return redirect()->to($rData->data->instrumentResponse->redirectInfo->url);

    }

Now, I am being redirected to phonepe production server, and money is getting debited but the response I am recieving is not correct. Kindly help

I am getting below error response

"code" => "KEY_NOT_CONFIGURED",
"message" => "key not found for the merchant"
like image 708
Rishabh Avatar asked Dec 06 '25 07:12

Rishabh


1 Answers

You are using production key & merchant Id in UAT environment

Please visit this link to get test merchant Id and test key for UAT environment

like image 191
ArreX Dev Avatar answered Dec 08 '25 21:12

ArreX Dev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!