Where exactly are you getting that example from? It looks incomplete.
You should just save the output of the API call to some variable, then return the client_secret
for example:
$intent = $stripe->paymentIntents->create([
'amount' => 1200,
'currency' => 'usd',
'payment_method_types' => ['card']
]);
$this->response([ 'success' =>'1' ,'status' => 'success', 'message' => $intent->client_secret], REST_Controller::HTTP_OK);
CLICK HERE to find out more related problems solutions.