It is possible to programmatically manage the following aspects of subscription license Renewals using the License Management web service API :
- Disable Auto-renewal
- Re-enable Auto-renewal
- Increment the Renewals Authorized Until date
- Set a specific Renewals Authorized Until date.
Disable/Enable Auto-renewal of Subscription Licenses
To disable auto-renewal for a given license call DisableAutoRenewal()
with the unique identifier ( LicenseId) of the license to be disabled:
public static void DisableSubscriptionLicenseAutoRenewal( License license, UserCredentials Credentials) { using (var client = CreateLicenseManagementClient(credentials)) { client.DisableAutoRenewal(license.LicenseId); Console.WriteLine("License {0} is disabled for autorenew", license.ActivationKey); } }
To enable Auto-renewal call EnableAutoRenewal()
:
public static void EnableSubscriptionLicenseAutoRenewal(License license, UserCredentials credentials) { using (var client = CreateLicenseManagementClient(credentials)) { client.EnableAutoRenewal(license.LicenseId); Console.WriteLine("License {0} is enabled for autorenew", license.ActivationKey); } }
Increment Renewal Authorization
With subscription licenses that are not auto-renewable, to authorize renewals for one or more future periods (i.e., increment the licence's existing Renewal Authorized Until
date) call AuthorizeRenewal()
with the unique identifier of the license (LicenseId) and the number of periods required:
public static void AuthorizeSubscriptionLicenseRenewal(License license, int numberOfPeriods, UserCredentials credentials) { using (var client = CreateLicenseManagementClient(credentials)) { client.AuthorizeRenewal(license.LicenseId, numberOfPeriods); Console.WriteLine("License {0} is authorized for renewal for {1} License Periods", license.ActivationKey, numberOfPeriods); } }
Set RenewalsAuthorizedUntil Date
Finally, to set an arbitrary RenewalsAuthorisedUntil
date call SetSubscriptionRenewUntil()
with the unique identifier of the license (LicenseId) and the desired DateTime:
The supplied date only controls the last date at which a renewal will be permitted; the resulting Expiration date is computed in the normal manner - the end date of the period during which a given activation takes place.
public static void SetSubscriptionLicenseRenewUntil(License license, DateTime renewUntil, UserCredentials credentials) { using (var client = CreateLicenseManagementClient(credentials)) { client.SetSubscriptionRenewUntil(License.LicenseId, renewUntil); Console.WriteLine("License {0} RenewUntil is set to {1}", license.ActivationKey, renewUntil); } }
Renewal of Subscription Licenses Using Runtime API
Your application is responsible for renewal of subscription licenses when due. In SpAgent it is possible to renew a subscription license at any stage after its RenewedUntil date is reached, even after the Grace Period has expired.
To renew subscription licenses you first query the SpAgent runtime API to get a list of all subscription licenses due for renewal.
var licenses = SpAgent.Product.Licenses.DueForRenewalNow();
Then, for each expired subscription license to be renewed, you must activate the license using the license Activation Key. This can be done using either online or manual (offline) activation mechanism.
Please see the Subscription sample application on GitHub for more details on how to implement Subscription licensing using the SpAgent runtime API.
Comments
0 comments
Article is closed for comments.