From Wiki [1]:
SpaceX spent its own capital to develop and fly its previous launcher, Falcon 1, with no pre-arranged sales of launch services. SpaceX developed Falcon 9 with private capital as well, but did have pre-arranged commitments by NASA to purchase several operational flights once specific capabilities were demonstrated.
[1] https://en.wikipedia.org/wiki/Falcon_9