How to tell credit card's country of origin by its number?
Use BinList. It simply tells you the country of origin by checking the first 6 digits of the card number. It has a neat Json based API as well.
At first, I questioned whether this information could be gleened from the credit card number alone.
Then I found it here:
http://en.wikipedia.org/wiki/List_of_Bank_Identification_Numbers
Edit - Don't forget about PCI Compliance if you are taking credit card numbers for payment.
Edit - Apparently the previous wikipedia page has been deleted. This appears to have similar information.
checkout https://binlist.io/ opensource and it looks like they have a maintained csv file on their github page: https://github.com/iannuttall/binlist-data