You didn't do a third version from scratch, did you? I'd do it for my own development and professional growth.
Been there, seen that, got rejected in a similar manner. But each rejection made me a better software engineer (mostly thanks to feedback and self reflection).
You did well to address the feedback, but I believe it would be a great experience for you to rewrite the project from scratch using provided feedback since you already did a great job at two attempts and fixed a lot of issues. That third iteration could be something that helps you grow professionally, something you can branch off of in the future when working on similar projects. Something you can use as a base for teaching others some basic concepts.
I highly recommend doing it.
Oh, and judging by their feedback, they understood your work well enough to be able to write something similar, thus wouldn't really rely on your code. I'm not saying you did great or horrible, I'm just saying that:
Aaaand no. I wouldn't pay for a test task. If you're willing to do it without getting paid in advance, you shouldn't put in more work than you feel comfortable doing for yourself (been there, did that, got annoyed, learned from it, got a better job eventually).
My point: it's a part of the game (hiring process). You find a team that works for you, they check if you can do what they want under conditions they set. They may be unrealistic and they will be unable to hire anyone. They may find their ninja. But you should concentrate on what is important for you - your growth as both a professional and as a person.
Hopefully, someone finds this interesting :)
Ps: Personally I believe the task was way too complex and I would reject it outright and offer to write a portion of using my preferred language and my scope of work, while decreasing complexity to 1-2 hours. If that is not good enough, we part ways without wasting each other's time.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.