Not any secret, I use something similar to this
https://github.com/junian/Standard.Licensing
But at the end of the day, one need to handle payments, tax reporting etc. I use Stripe for most of this.
I think that there is saas solutions that has .net sdks.