This paper provides efficient solutions to maximize profit for commercial ridesharing services, under a pricing model with detour-based discounts for passengers. We propose greedy heuristics for real-time ride matching that offer different trade-offs between optimality and speed. Simulations on New York City (NYC) taxi trip data show that our heuristics are up to 90% optimal and 10^5 times faster than the (necessarily) exponential-time optimal algorithm. Commercial ridesharing service providers generate significant savings by matching multiple ride requests using heuristic methods. The resulting savings are typically shared between the service provider (in the form of increased profit) and the ridesharing passengers (in the form of discounts). It is not clear a priori how this split should be effected, since higher discounts would encourage more ridesharing, thereby increasing total savings, but the fraction of savings taken as profit is reduced. We simulate a scenario where the decisions of the passengers to opt for ridesharing depend on the discount offered by the service provider. We provide an adaptive learning algorithm IDFLA that learns the optimal profit-maximizing discount factor for the provider. An evaluation over NYC data shows that IDFLA, on average, learns the optimal discount factor in under 16 iterations. Finally, we investigate the impact of imposing a detour-aware routing policy based on sequential individual rationality, a recently proposed concept. Such restricted policies offer a better ride experience, increasing the provider's market share, but at the cost of decreased average per-ride profit due to the reduced number of matched rides. We construct a model that captures these opposing effects, wherein simulations based on NYC data show that a 7% increase in market share would suffice to offset the decreased average per-ride profit.