Converting circular structure to JSON↵ --> starting at object with constructor 'ClientRequest'↵ | property 'socket' -> object with constructor 'TLSSocket'↵ --- property '_httpMessage' closes the circle"

router.post(’/payment/create’ , (req , res) => {

const {nonce , buyerVerificationToken}=req.body



let  payload = {
    "source_id": nonce,
    "verification_token": buyerVerificationToken,
    "autocomplete": true,
    "location_id": "LWRZPAFZ2N5KN",
    "amount_money": { 
      "amount": 100,
      "currency": "USD"
    },
    "idempotency_key": v4()
  }


axios.post("https://connect.squareupsandbox.com/v2/payments" ,payload , {
    headers : {
        
   
  'Content-Type': 'application/json;charset=utf8',

      authorization : `Bearer {{redacted}}`}
 
} ).then(result => {
   return res.status(201).json({
       success : true,
       message : "Payment succesfull",
       result 
   })
}).catch(error => {
    console.log("Error" , error);
    return res.status(500).json({
        success : false,
        message : "Payment rejected",
        result : error.message
    })
})

})

I’m not super familiar with axios, but I believe the authorization header needs to be capitalized, and maybe in single quotes as well ('Authorization'). No idea if that would cause the above error, but the error being reported is not Square-specific so hard to say.

Hello Sir, thanks for your message. I have applied the same suggested but it’s not working and error still the same.

Sorry to hear that. In that case, this sounds like it’s outside of my scope (it doesn’t sound specific to Square). I’m not sure if I will be able to assist with this. This might be better asked on the Axios support, or Stack Overflow unfortunately.