I made a purchase on Amazon last year with a credit card. The price included a deposit for customs charges, if any.
About a month later i cancelled the credit card and got a new one - i forgot about the Amazon purchase as i had received the goods , no issues.
Four months after that i got a notification that the customs deposit had been refunded to my old credit card, which by now is long cancelled.
Two days later the refund arrived into my credit card account. As others have said, it is the account linked to the ccard that remains the same regardless of the card number used.