Each codeshare agreement has different terms, also on a few routes some airlines have a "pooled revenue" arrangement (all flights are shared even if not code-shared). Most code-share is buying seats from the operating carrier at a set price, sometimes with a guaranteed number; then the marketing carrier tries to sell those seats for a higher price, to cover its marketing expense and make a profit. A different kind of codeshare arrangement is to divide a percentage of the ticket price, instead of a set amount. But that is rare (good for pax, though, as the marketing carrier doesn't care how low the price goes). A further complication is payment for FF miles, which could go in either direction (or be not relevant).