I want to recive long url from instamojo payment respose script option in a php

I’m integrating the Instamojo payment gateway into a website using core PHP.
I wrote some script that is working well enough on the test.instamojo.com (Which is a test version of their portal) but When I changed the credentials for the live testing (means I have removed test level credentials and put all real-time credentials like their live URL, Private key, Auth Key of our account) It’s started showing error in the variable where I want to receive the long URL to redirect for the payment.

The Instamojo response is

{
    "success": true,
    "payment_request": {
        "id": "47a321d9*****************bbb55f64",
        "phone": "+9170******55",
        "email": "a*******@gmail.com",
        "buyer_name": "Aman",
        "amount": "100.00",
        "purpose": "FIFA",
        "expires_at": null,
        "status": "Pending",
        "send_sms": true,
        "send_email": true,
        "sms_status": "Pending",
        "email_status": "Pending",
        "shorturl": null,
        "longurl": "https://www.instamojo.com/@EXAMPLE/47a321d95c5c4d7f8e0e7742bbb55f64",
        "redirect_url": "http://www.example.com/thankyou.php/",
        "webhook": null,
        "allow_repeated_payments": false,
        "created_at": "2022-09-10T09:16:12.104302Z",
        "modified_at": "2022-09-10T09:16:12.104336Z"
    }
}

This is my Php Code

<?php
$ch = curl_init();
    
curl_setopt($ch, CURLOPT_URL, 'https://www.instamojo.com/api/1.1/payment-requests/');
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER,
            array("X-Api-Key:*****************************************",
                  "X-Auth-Token:**************************************"));
$payload = Array(
    'purpose' => 'FIFA',
    'amount' => '100',
    'phone' => '70*****55',
    'buyer_name' => 'Aman',
    'redirect_url' => 'http://www.example.com/thankyou.php/',
    'send_email' => true,
    'send_sms' => true,
    'email' => 'a******@gmail.com',
    'allow_repeated_payments' => false
);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));
$response = curl_exec($ch);
curl_close($ch); 

header('location:'.$response->payment_request->longurl);

?>

I’m getting an error (red line within $ response) at
header(‘location:’.$response->payment_request->longurl);