0

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;
1
  • check the doc whether we can use same Token in two APIs Commented Jun 16, 2025 at 5:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.