I have a project which requires me to setup an subscription-based online learning site using Moodle. I checked Moodle and it seems that it can handle this by itself. The pro
I think is possible with a moderate effort.
Check my plugins (GPL) for moodle2 that let moodle support auth and enrolment based on simplesamlphp software.
With those plugins the "moodle part" is done. You can "provisioning/deprovisioning users on courses on the fly", using the user atribute entitlements sent on the saml assertion.
So you only must to add saml support to Magento and develop the logic to add the entitlements to the auth source that you use in your identity provider when a purchase is done.
Edit: