
125 N.W.2d 496 (1963)
Chester THURSTON, Plaintiff and Appellant,
v.
CEDRIC SANDERS COMPANY, a copartnership, consisting of Cedric Sanders, an individual and Sanders Development Company, a foreign corporation, et al., Defendants and Respondents.
No. 10060.
Supreme Court of South Dakota.
December 30, 1963.
*497 Bangs, McCullen, Butler & Foye, Rapid City, for plaintiff and appellant.
Whiting, Lynn, Freiberg & Shultz, Rapid City, for defendants and respondents.
ROBERTS, Judge.
This is an action to recover from defendants upon quantum meruit the reasonable value of services rendered and materials furnished defendants. Holding that the complaint as amended did not state a claim upon which relief could be granted the trial court dismissed the complaint and this appeal is from the order of dismissal.
The complaint sets out allegations which are here summarized. Defendants were at all times material hereto foreign corporations doing business in this state under such circumstances as to require their compliance with the foreign corporation statutes of this state; that on or about June 26, 1961, defendants entered into an express contract with the plaintiff for the performance of certain work and the furnishing of certain materials which contract was to be performed within the state; that plaintiff commenced performance of the contract and furnished labor and materials pursuant thereto; that the written contract being voidable at the election of the plaintiff because of the failure of defendants to comply with the law relating to foreign corporations was disaffirmed by plaintiff; and that the reasonable value of labor and materials furnished by plaintiff is $136,374.33 and of that amount $39,650.00 has not been paid.
SDC 11.2002 declares that no foreign corporation "shall transact business or acquire, hold, or dispose of property in this state until such corporation shall have caused to be filed in the office of the Secretary of State a copy of its charter, articles of association or incorporation and all amendments thereto duly certified by the Secretary of State of the state wherein the corporation was organized". Another section (SDC 11.2103) provides: "Every contract made by or on behalf of any foreign corporation, subject to the provisions of this title affecting the personal liability thereof or relating to property within this state, before it shall have complied with the provisions of this title shall be wholly void on its behalf and on behalf of its assigns but shall be enforceable against it or them." If transactions in this state on the part of a foreign corporation constitute interstate commerce, these statutory provisions do not apply to them. Sioux Remedy Co. v. Cope, 235 U.S. 197, 35 S.Ct. 57, 59 L.Ed. 193; Dakota Photo Engraving Co. v. Woodland, 59 S.D. 523, 241 N.W. 510; Oskey Brothers Petroleum Corporation v. Gorder, S.D., 109 N.W.2d 893.
In determining the sufficiency of a complaint upon motion to dismiss for failure to state a claim the allegations of the complaint should be viewed in the light most favorable to the plaintiff admitting and accepting as true all facts well pleaded. It appears from the allegations of the complaint that the contract and transaction out of which this action arose were no part of *498 interstate commerce in which defendants could engage without the permission of the State of South Dakota.
The complaint is not predicated on the theory that the contract was wrongfully terminated by defendants and that plaintiff was entitled to bring an action on the contract for a breach thereof or that he could treat the contract as rescinded and sue to recover the value of his services and money necessarily expended in carrying out his contract up to the time it was wrongfully terminated. Nor does plaintiff seek a rescission on the ground that his consent to the contract was given by mistake or obtained through duress, fraud or undue influence. Plaintiff contends that under the statutes penalizing noncompliance by a foreign corporation doing business in this state and the facts pleaded he had a right to disaffirm and abandon the contract and sue upon a contract implied by law that defendants pay the reasonable value of the benefits received.
If a contract is deemed void for noncompliance with a statute, it is a nullity conferring no right and creating no obligation as between the parties. A party thereto must then recover, if at all, upon an implied agreement on the part of the party receiving benefits to pay what the same were reasonably worth. Werre v. Northwest Thresher Co., 27 S.D. 486, 131 N.W. 721; Reedy v. Ebsen, 60 S.D. 1, 242 N.W. 592. While the statute (§ 11.2103, supra) declares that a contract made before a corporation shall have complied with its requirements is "wholly void" as to the corporation, it states that the contract nevertheless shall be "enforceable" against the offending corporation. Elwell v. Adder Mach. Co., 136 Wis. 82, 116 N.W. 882, was an action founded on the alleged deceit of defendant corporation in concealing from the plaintiff the fact that it had not obtained a license to do business within the state and thus inducing him to enter into a contract. The Wisconsin Supreme Court considering the same language in the statute of that state said: "The acts prohibited are transacting business within the state, or acquiring or disposing of property within the state, without compliance with the statutory conditions precedent. In making and signing the contract in question, respondent was not acting for the corporation, but for himself. By this act he violated no law, incurred no penalty. * * * This merely means that the corporation was unable, until it obtained a license, to perform on its part, and for this failure of performance the respondent had a right of action on the contract in question under the statute. * * * It is sufficient in the case at bar to determine, as we do, that the existence of this right ex contractu excludes any right of action for deceit or upon any quasi contract liability."
The courts recognize two classes of implied contracts. The one is implied in fact and the other implied in law. Mahan v. Mahan, S.D., 121 N.W.2d 367. Those falling within the second classification generally referred to as quasi or constructive contracts do not arise because of a manifestation of an intention to create them, but rest upon the equitable principle that a person shall not be permitted to enrich himself unjustly at the expense of another. The question then presented is whether the complaint contains allegations which would establish a contract implied in law. In Werre v. Northwest Thresher Co., supra, wherein plaintiff sought to recover from defendant upon an implied obligation to pay for benefits received this court said: "There is no question but what, where there is a valid express contract existing between parties in relation to a transaction fully fixing the rights of each, there is no room for an implied promise, or suit on quantum meruit. Ball v. Dolan, 21 S.D. 619, 114 N.W. 998, 15 L.R.A. (N.S.) 272." The same principle is stated in 98 C.J.S. Work & Labor § 27 as follows: "The rights of the parties are controlled by the contract, and *499 under such circumstances recovery cannot be had on the theory of a quantum meruit". See also Schneider v. Allis-Chalmers Mfg. Co., 196 Wis. 56, 219 N.W. 370; Chandler v. Washington Toll Bridge Authority, 17 Wash.2d 591, 137 P.2d 97; Federal Royalty Co. v. Knox, 5 Cir., 114 F.2d 78. In the case last cited it was held that the action failed too because recovery on a quantum meruit depends on unjust enrichment of the defendant.
The enforceable rights of plaintiff under the contract preclude recovery under the facts alleged in the complaint. The order of dismissal entered in the circuit court is affirmed.
All the Judges concur.
