Use the below endpoint to fetch token id using Payment id.
 Curl  PHP  Node.JS  Python  Go  Response 
Copy curl -u <YOUR_KEY_ID>:<YOUR_KEY_SECRET> \
-X GET https://api.razorpay.com/v1/payments/pay_1Aa00000000001
  
Copy $api  = new  Api($key_id , $secret );
$api ->payment->fetch($paymentId );
Copy var  instance = new  Razorpay ({ key_id : 'YOUR_KEY_ID' , key_secret : 'YOUR_SECRET'  })
instance.payments .fetch (paymentId)
Copy client = razorpay.Client(auth=("YOUR_ID" , "YOUR_SECRET" ))
client.token.fetch(paymentId)
Copy import  ( razorpay "github.com/razorpay/razorpay-go"  )
client := razorpay.NewClient("YOUR_KEY_ID" , "YOUR_SECRET" )
body, err := client.Payment.Fetch("<paymentId>" , nil , nil )
Copy { 
  "id" :  "pay_FHfqtkRzWvxky4" , 
  "entity" :  "payment" , 
  "amount" :  100 , 
  "currency" :  "INR" , 
  "status" :  "captured" , 
  "order_id" :  "order_FHfnswDdfu96HQ" , 
  "invoice_id" :  null , 
  "international" :  false , 
  "method" :  "card" , 
  "amount_refunded" :  0 , 
  "refund_status" :  null , 
  "captured" :  true , 
  "description" :  null , 
  "card_id" :  "card_F0zoXUp4IPPGoI" , 
  "bank" :  null , 
  "wallet" :  null , 
  "vpa" :  null , 
  "email" :  "gaurav.kumar@example.com" , 
  "contact" :  "+919876543210" , 
  "customer_id" :  "cust_DtHaBuooGHTuyZ" , 
  "token_id" :  "token_FHfn3rIiM1Z8nr" , 
  "notes" :  { 
    "note_key 1" :  "Beam me up Scotty" , 
    "note_key 2" :  "Tea. Earl Gray. Hot." 
  } , 
  "fee" :  0 , 
  "tax" :  0 , 
  "error_code" :  null , 
  "error_description" :  null , 
  "error_source" :  null , 
  "error_step" :  null , 
  "error_reason" :  null , 
  "acquirer_data" :  { 
    "auth_code" :  "541898" 
  } , 
  "created_at" :  1595449871 
}