Website logo
⌘K
Getting Started
Introduction
Basic Concepts
Opening an Account
Creating & Configuring Products
Integrating SDK and Configuring License Fulfillment
Activate a Key-Based License
Vendor Platform
Issuing New Licenses
License Detail View
Order Detail View
Customer Detail View
Metadata
Analytics
Settings
Product Configuration
Product Features
Product Custom Fields
Product Versioning
License Policies
Product Bundles
License Entitlements
Consumption Period in License/Features
License Types
Activations & Device Transfers
Features
Floating Features
Custom Fields
License Start Date
License Note
Maintenance Period
Trial Licenses
Floating Licenses
License Activation Types
Portals
End-User Portal
Offline Portal
Air-Gapped Portal
License API
License API Authorization
License Activation/Deactivation
License Check
License Feature Check
Consumption
Floating
Trial Key
Product Details
Device Variables
Changing Password
Versions
Installation File
Customer License Users
SSO URL
Management API
Making API Requests
Management API Authorization
Customer
Product
Order
License
Device
Analytics
SDKs
Tutorials
.NET/C# SDK
.NET/C# Management SDK
C++ SDK
Java SDK
Python SDK
Go SDK
Delphi SDK
Swift/Objective-C SDK
Android SDK
Unity SDK
Errors and Response Codes
Floating Server
API Reference
Deployment
Configuration
Floating Server UI
Securing the Server
Whitelabeling
FAQ
Floating Server Changelog
Integrations
Subscription Integration
Salesforce
FastSpring
Stripe
Shopify
Common Scenarios
Single Sign On (SSO)
Glossary
General
SDK Glossary
Vendor Platform
Product Configuration Glossary
License Configuration
Postman Collections
Frequently Asked Questions
Integrations
SDK
Changelog
License API changelog
Platform changelog
Docs powered by Archbee
SDKs
...
Getting Started
.NET/C# Management SDK

Management SDK Configuration and Usage

9min

This guide is designed to help you configure your application and start using LicenseSpring Management SDK functionality.

As you navigate through this tutorial, you'll acquire the knowledge to issue licenses and manage orders within your .NET application.

Configuration

To initialize the SDK, you must fill in your LicenseSpring Management API key. It can be found on your LicenseSpring account under Settings->Keys:

Document image


Note: API keys for licensing and management SDKs are different.

Copy this value and create the configuration as shown below:

C#
var configuration = new LicenseSpring.ManagementConfiguration( ManagementAPIKey );


Now you can create ManagementService using this configuration object:

C#
var service = new ManagementService( configuration );


Creating licenses

To create a key-based license you need to generate a license key:

C#
string productCode = "CODE";
var licenseKeys = service.LicenseService.GenerateLicenseKey( productCode );


Then create a LicenseDetails object and set the necessary values:

C#
var license1 = new LicenseDetails();
license1.LicenseKey = licenseKeys[0];
license1.EnableMaintenancePeriod = true;
license1.MaintenanceDuration = "3m";


Now you can create an order:

C#
var keyBasedOrderId = service.OrderService.CreateOrder( new[] { license1 }, productCode );


This method allows to specify order info such as customer:

C#
var customer = new Customer()
{
   CompanyName = "TestCompany",
   Email = "someone@test.com"
};
var orderInfo = new Order( customer );
var keyBasedOrderId = service.OrderService.CreateOrder( new[] { license1 }, productCode, orderInfo );


Managing orders

Use the returned order id to get order information and manage the order. For example, get licenses from the order:

C#
ListOrdersRequestDto dto = new ListOrdersRequestDto()
{
   ClientOrderId = keyBasedOrderId 
};
uint count;
var ret = service.OrderService.ListOrders( dto, out count );
License[] licenses = null;
if( count == 1 && ret != null )
   licenses = service.OrderService.ListOrderLicenses( ret[0].Id );


You can also append licenses to an existing order:

C#
licenseKeys = service.LicenseService.GenerateLicenseKey( productCode );
var license2 = new LicenseDetails
{
   LicenseKey = licenseKeys[0],
   Type = LicenseType.Consumption,
   MaxConsumptions = 100,
   AllowOverages = true,
   MaxOverages = 50,
   ResetConsumption = true,
   ConsumptionPeriod = ConsumptionPeriod.Weekly
};
orderInfo = new Order( keyBasedOrderId, customer );
keyBasedOrderId = service.OrderService.CreateOrder(  new[] { license2 }, productCode, orderInfo );


Note: one order cannot contain key-based and user-based licenses. It contains licenses for one product.

User-based licenses

The process of creating a user-based license is almost the same. However, you do not need to generate keys. Also, ensure that the specified product is user-based.

C#
string productCode = "UBCODE";
var license = new LicenseDetails
{
   EnableMaintenancePeriod = true,
   MaintenanceDuration = "7m", // 7 months
   Type = LicenseType.Consumption,
   MaxConsumptions = 10
};
var userBasedOrderId = service.OrderService.CreateOrder( new[] { license }, productCode );


To assign a user to the created license, retrieve the license using the order ID as shown above and assign the user by license ID:

C#
LicenseUser user = new LicenseUser()
{
   Email = "example@email.com",
   IsManager = false
};
service.LicenseService.AssignUser( license.Id, user );




Updated 29 Sep 2023
Did this page help you?
PREVIOUS
Management SDK Installation
NEXT
Java
Docs powered by Archbee
TABLE OF CONTENTS
Configuration
Creating licenses
Managing orders
User-based licenses
Docs powered by Archbee