You have exactly the right perspective on this situation. I trust that you have a written contract that defines what and when you are paid. (For example, $30 per hour payable weekly.)

Some contracts pay at the end of a project; but if I were you, I would require more frequent payment.

Regardless, if you provided the services that the contract specified you would and/or that you were directed to provide, you are owed the amount agreed upon. It is immaterial whether the company through which you worked was paid or not.