My friend (which is not a native English speaker) asked me to send him on Whats-app the pictures of the books that I bought, and his comment to it was: "Good buy!". I had an immediate connotation with "Good bye!". Therefore, I'm not sure if it's idiomatic to say so or not (while the word buy also functions as a noun). I would think for example about "Good purchase!". So which of them is idiomatic? and his choice can be understood orally in English speaking countries?
While there could be a "fork handles/four candles" type joke made around the similarity between good buy and goodbye, there is no immediate association. These are just a pair of (close) homophones: two expressions that happen to sound the same. There is a small difference in stress. In "good buy", each word has equal stress. In "goodbye" the stress falls on "bye" and so it is pronounced more like "g'dbye"
In context we pick one meaning and mentally ignore the other one. Think how in your native language there are words or expressions that are homophones, and (unless someone is making a deliberate joke) you don't usually get confused.
In writing the spelling is different, so there is no chance of confusion at all. There is no reason to associate "good buy" with "goodbye".
There is nothing odd about exclaiming "Good buy!" or saying "That was a good buy". You could say "good purchase" instead, it would be equally correct.