I cannot get it to provide a correct valid credit card number.
You create a card number from a random digits. Would you expect this set of random digits to pass your validation?
You could make your validation function do just validation, then you can call it in a loop with your generator function to ensure that only a valid random set is returned. I have no idea how likely it is to take.