Credit Card question from a pretend adult

exm ♥️
So. I went to Macy's, and I bought a hat for a gift using my credit card.  Payed off the balance w my debit card the next day. I found something better to gift and would like to return the hat. Now I'm wondering .....when I get a refund, will the total go back and be deducted from my credit card balance? And will the payment be refunded back to my debit card? Or will the payment go straight back onto my debit? Is that even how credit cards work??