i am getting problem of getting unauthenticated in the phonepe refund api. also i am using that token in the payment time it’s working fine.
$data = $this->getAuthKey();
$payment = Payment::where('id', $paymentId)->first();
$token = $data['access_token'];
// $token = $payment->auth_key;
$url = 'https://api.phonepe.com/apis/pg/payments/v2/refund';
$amount = $payment->amount * 100;
$refund_id = 'REF' . $paymentId . uniqid();
$order_id = $payment->transaction_id;
$payload = [
"merchantRefundId" => $refund_id,
"originalMerchantOrderId" => $order_id,
"amount" => $amount,
];
$response = Http::withHeaders([
'Content-Type' => 'application/json',
'Authorization' => 'O-Bearer ' . $token,
])->post($url, $payload);
$response = $response->json();
return $response;