1. Overview

The Licensing System is a comprehensive solution for managing software licenses, payments, and customer relationships. This documentation provides detailed information on how to integrate, configure, and utilize the system effectively.

Key Features

  • License Management: Generate, revoke, and manage software licenses with ease.
  • Payment Processing: Integrated payment gateways for seamless transactions.
  • Customer Management: Track customer information, purchase history, and license usage.
  • Analytics & Reporting: Gain insights into sales, license usage, and customer behavior.
  • API & SDK Support: Integrate with your existing systems using our comprehensive API and SDKs.
This documentation is designed for administrators and developers who need to integrate the Licensing System with their software products.

2. Integration Guide

This section provides step-by-step instructions for integrating the Licensing System with your software products.

Integration Methods

There are several ways to integrate the Licensing System with your software:

2.1 SDK Integration

Our SDKs provide the easiest way to integrate license verification into your applications:

Python SDK
from licensing_system import LicenseVerifier

# Initialize the verifier
verifier = LicenseVerifier(api_key="your_api_key")

# Verify a license
result = verifier.verify_license(license_key="LICENSE-KEY-HERE")

if result.is_valid:
    print(f"License is valid. Expires: {result.expiry_date}")
else:
    print(f"License is invalid. Reason: {result.error_message}")
Node.js SDK
const { LicenseVerifier } = require('licensing-system');

// Initialize the verifier
const verifier = new LicenseVerifier({ apiKey: 'your_api_key' });

// Verify a license
verifier.verifyLicense('LICENSE-KEY-HERE')
  .then(result => {
    if (result.isValid) {
      console.log(`License is valid. Expires: ${result.expiryDate}`);
    } else {
      console.log(`License is invalid. Reason: ${result.errorMessage}`);
    }
  })
  .catch(error => {
    console.error('Verification error:', error);
  });
PHP SDK
use LicensingSystem\LicenseVerifier;

// Initialize the verifier
$verifier = new LicenseVerifier(['api_key' => 'your_api_key']);

// Verify a license
$result = $verifier->verifyLicense('LICENSE-KEY-HERE');

if ($result->isValid()) {
    echo "License is valid. Expires: " . $result->getExpiryDate();
} else {
    echo "License is invalid. Reason: " . $result->getErrorMessage();
}
Bash SDK
#!/bin/bash

# Source the SDK
source /path/to/licensing-system.sh

# Initialize the verifier
init_license_verifier "your_api_key"

# Verify a license
verify_license "LICENSE-KEY-HERE"

# Check the result
if [ $? -eq 0 ]; then
    echo "License is valid"
    echo "Expires: $(get_license_expiry)"
else
    echo "License is invalid"
    echo "Reason: $(get_license_error)"
fi

2.2 Direct API Integration

If you prefer to integrate directly with our API, you can use the following endpoints:

# Verify a license
POST /api/v1/licenses/verify
Content-Type: application/json

{
  "license_key": "LICENSE-KEY-HERE",
  "product_id": "PRODUCT-ID",
  "hardware_id": "HARDWARE-ID"  # Optional
}

# Response
{
  "is_valid": true,
  "expiry_date": "2023-12-31T23:59:59Z",
  "features": ["feature1", "feature2"],
  "max_activations": 3,
  "current_activations": 1
}
When using direct API integration, make sure to implement proper error handling and retry mechanisms for network issues.

3. Payment Integration

The Licensing System supports multiple payment gateways to process customer payments securely.

Supported Payment Gateways

  • Stripe: Credit cards, Apple Pay, Google Pay
  • PayPal: Credit cards, PayPal balance
  • Square: Credit cards, digital wallets
  • Authorize.net: Credit cards, e-checks

3.1 Payment Flow

  1. Customer selects a product and clicks "Purchase"
  2. System redirects to the payment gateway
  3. Customer completes payment
  4. Payment gateway sends a webhook notification
  5. System generates and sends license to customer

3.2 Setting Up Payment Gateways

Stripe Integration
// Initialize Stripe
const stripe = require('stripe')('sk_test_YOUR_SECRET_KEY');

// Create a payment intent
const paymentIntent = await stripe.paymentIntents.create({
  amount: 2000, // $20.00
  currency: 'usd',
  payment_method_types: ['card'],
  metadata: {
    product_id: 'PRODUCT-ID',
    customer_id: 'CUSTOMER-ID'
  }
});

// Return the client secret to the frontend
return { clientSecret: paymentIntent.client_secret };
PayPal Integration
// Initialize PayPal
const paypal = require('@paypal/checkout-server-sdk');
let environment = new paypal.core.SandboxEnvironment('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');
let client = new paypal.core.PayPalHttpClient(environment);

// Create an order
let request = new paypal.orders.OrdersCreateRequest();
request.prefer("return=representation");
request.requestBody({
  intent: 'CAPTURE',
  purchase_units: [{
    amount: {
      currency_code: 'USD',
      value: '20.00'
    },
    custom_id: 'PRODUCT-ID'
  }]
});

// Execute the request
const order = await client.execute(request);

3.3 Webhook Configuration

To ensure proper license generation after payment, configure webhooks for your payment gateway:

// Webhook endpoint
app.post('/webhooks/payment', async (req, res) => {
  const sig = req.headers['stripe-signature'];
  let event;

  try {
    event = stripe.webhooks.constructEvent(req.body, sig, 'whsec_YOUR_WEBHOOK_SECRET');
  } catch (err) {
    return res.status(400).send(`Webhook Error: ${err.message}`);
  }

  // Handle the event
  if (event.type === 'payment_intent.succeeded') {
    const paymentIntent = event.data.object;
    
    // Generate license
    const license = await generateLicense({
      product_id: paymentIntent.metadata.product_id,
      customer_id: paymentIntent.metadata.customer_id,
      payment_id: paymentIntent.id
    });
    
    // Send license to customer
    await sendLicenseEmail(license);
  }

  res.json({received: true});
});
For security reasons, always verify webhook signatures and use HTTPS for your webhook endpoints.

4. License Management

This section covers the various operations you can perform with licenses in the Licensing System.

4.1 License Types

  • Single-User License: Valid for one user on one device
  • Multi-User License: Valid for multiple users (specified limit)
  • Site License: Valid for an entire organization or site
  • Subscription License: Valid for a specific time period with automatic renewal
  • Trial License: Valid for a limited time with restricted features

4.2 Generating Licenses

Licenses can be generated manually or automatically after payment:

// Generate a license
const license = await generateLicense({
  product_id: 'PRODUCT-ID',
  customer_id: 'CUSTOMER-ID',
  type: 'single-user',
  duration: 365, // days
  features: ['feature1', 'feature2'],
  max_activations: 1
});

// License key format: XXXX-XXXX-XXXX-XXXX
console.log(`Generated license: ${license.key}`);

4.3 Revoking Licenses

If a license needs to be revoked (e.g., due to violation of terms):

// Revoke a license
await revokeLicense('LICENSE-KEY-HERE', {
  reason: 'Terms violation',
  admin_id: 'ADMIN-ID'
});

// Check if a license is revoked
const isRevoked = await isLicenseRevoked('LICENSE-KEY-HERE');

4.4 Reissuing Licenses

If a customer needs a new license (e.g., after hardware change):

// Reissue a license
const newLicense = await reissueLicense('LICENSE-KEY-HERE', {
  reason: 'Hardware change',
  admin_id: 'ADMIN-ID'
});

console.log(`New license: ${newLicense.key}`);

4.5 Extending Licenses

To extend the duration of an existing license:

// Extend a license
await extendLicense('LICENSE-KEY-HERE', {
  days: 30,
  admin_id: 'ADMIN-ID'
});

// Get license expiry
const expiryDate = await getLicenseExpiry('LICENSE-KEY-HERE');

5. License Verification

The Licensing System provides multiple methods for verifying licenses to prevent unauthorized use of your software.

5.1 Hardware ID Verification

Hardware ID verification ensures that a license is only used on the authorized device:

// Get hardware ID
const hardwareId = getHardwareId();

// Verify license with hardware ID
const result = await verifier.verifyLicense('LICENSE-KEY-HERE', {
  hardware_id: hardwareId
});

if (result.isValid) {
  // License is valid for this hardware
} else {
  // License is not valid for this hardware
}

5.2 Domain Verification

For web applications, you can verify licenses based on the domain:

// Get current domain
const domain = window.location.hostname;

// Verify license with domain
const result = await verifier.verifyLicense('LICENSE-KEY-HERE', {
  domain: domain
});

if (result.isValid) {
  // License is valid for this domain
} else {
  // License is not valid for this domain
}

5.3 IP Verification

For server-side applications, you can verify licenses based on the IP address:

// Get client IP
const clientIp = req.ip;

// Verify license with IP
const result = await verifier.verifyLicense('LICENSE-KEY-HERE', {
  ip: clientIp
});

if (result.isValid) {
  // License is valid for this IP
} else {
  // License is not valid for this IP
}
For maximum security, consider implementing multiple verification methods (e.g., hardware ID + domain).

6. API Reference

This section provides detailed information about the Licensing System API endpoints.

6.1 Authentication

All API requests require authentication using an API key:

// Include the API key in the Authorization header
Authorization: Bearer YOUR_API_KEY

6.2 Endpoints

License Verification

POST /api/v1/licenses/verify
Content-Type: application/json

{
  "license_key": "LICENSE-KEY-HERE",
  "product_id": "PRODUCT-ID",
  "hardware_id": "HARDWARE-ID",  # Optional
  "domain": "example.com",       # Optional
  "ip": "192.168.1.1"           # Optional
}

# Response
{
  "is_valid": true,
  "expiry_date": "2023-12-31T23:59:59Z",
  "features": ["feature1", "feature2"],
  "max_activations": 3,
  "current_activations": 1
}

License Generation

POST /api/v1/licenses/generate
Content-Type: application/json

{
  "product_id": "PRODUCT-ID",
  "customer_id": "CUSTOMER-ID",
  "type": "single-user",
  "duration": 365,
  "features": ["feature1", "feature2"],
  "max_activations": 1
}

# Response
{
  "license_key": "XXXX-XXXX-XXXX-XXXX",
  "created_at": "2023-01-01T00:00:00Z",
  "expiry_date": "2023-12-31T23:59:59Z"
}

License Revocation

POST /api/v1/licenses/revoke
Content-Type: application/json

{
  "license_key": "LICENSE-KEY-HERE",
  "reason": "Terms violation",
  "admin_id": "ADMIN-ID"
}

# Response
{
  "success": true,
  "message": "License revoked successfully"
}

License Extension

POST /api/v1/licenses/extend
Content-Type: application/json

{
  "license_key": "LICENSE-KEY-HERE",
  "days": 30,
  "admin_id": "ADMIN-ID"
}

# Response
{
  "success": true,
  "new_expiry_date": "2024-01-30T23:59:59Z"
}

7. SDK Documentation

This section provides detailed information about the available SDKs for the Licensing System.

7.1 Python SDK

The Python SDK provides a simple interface for license verification:

# Installation
pip install licensing-system

# Usage
from licensing_system import LicenseVerifier

# Initialize the verifier
verifier = LicenseVerifier(api_key="your_api_key")

# Verify a license
result = verifier.verify_license(
    license_key="LICENSE-KEY-HERE",
    product_id="PRODUCT-ID",
    hardware_id="HARDWARE-ID"  # Optional
)

# Check the result
if result.is_valid:
    print(f"License is valid. Expires: {result.expiry_date}")
    print(f"Features: {result.features}")
else:
    print(f"License is invalid. Reason: {result.error_message}")

7.2 Node.js SDK

The Node.js SDK provides a promise-based interface for license verification:

// Installation
npm install licensing-system

// Usage
const { LicenseVerifier } = require('licensing-system');

// Initialize the verifier
const verifier = new LicenseVerifier({ apiKey: 'your_api_key' });

// Verify a license
verifier.verifyLicense('LICENSE-KEY-HERE', {
  productId: 'PRODUCT-ID',
  hardwareId: 'HARDWARE-ID'  // Optional
})
  .then(result => {
    if (result.isValid) {
      console.log(`License is valid. Expires: ${result.expiryDate}`);
      console.log(`Features: ${result.features}`);
    } else {
      console.log(`License is invalid. Reason: ${result.errorMessage}`);
    }
  })
  .catch(error => {
    console.error('Verification error:', error);
  });

7.3 PHP SDK

The PHP SDK provides an object-oriented interface for license verification:

// Installation
composer require licensing-system/licensing-system

// Usage
use LicensingSystem\LicenseVerifier;

// Initialize the verifier
$verifier = new LicenseVerifier(['api_key' => 'your_api_key']);

// Verify a license
$result = $verifier->verifyLicense('LICENSE-KEY-HERE', [
  'product_id' => 'PRODUCT-ID',
  'hardware_id' => 'HARDWARE-ID'  // Optional
]);

// Check the result
if ($result->isValid()) {
    echo "License is valid. Expires: " . $result->getExpiryDate();
    echo "Features: " . implode(', ', $result->getFeatures());
} else {
    echo "License is invalid. Reason: " . $result->getErrorMessage();
}

7.4 Bash SDK

The Bash SDK provides a command-line interface for license verification:

#!/bin/bash

# Source the SDK
source /path/to/licensing-system.sh

# Initialize the verifier
init_license_verifier "your_api_key"

# Verify a license
verify_license "LICENSE-KEY-HERE" "PRODUCT-ID" "HARDWARE-ID"

# Check the result
if [ $? -eq 0 ]; then
    echo "License is valid"
    echo "Expires: $(get_license_expiry)"
    echo "Features: $(get_license_features)"
else
    echo "License is invalid"
    echo "Reason: $(get_license_error)"
fi

8. FAQ

This section answers common questions about the Licensing System.

8.1 License Management

Q: How do I generate a license for a customer?

A: You can generate a license through the admin panel or using the API. In the admin panel, go to the Licenses section, click "Add New License", select the product and customer, and click "Generate".

Q: Can I revoke a license after it has been issued?

A: Yes, you can revoke a license at any time through the admin panel or using the API. Go to the Licenses section, find the license, and click "Revoke".

Q: How do I extend a license?

A: You can extend a license through the admin panel or using the API. Go to the Licenses section, find the license, and click "Extend". Enter the number of days to extend and click "Save".

8.2 Payment Processing

Q: Which payment gateways are supported?

A: The Licensing System supports Stripe, PayPal, Square, and Authorize.net. You can configure these in the Payment Settings section.

Q: How do I set up automatic license generation after payment?

A: Configure the webhook for your payment gateway to point to your webhook endpoint. The system will automatically generate a license when it receives a successful payment notification.

Q: Can I offer different pricing tiers for the same product?

A: Yes, you can create different pricing tiers for a product in the Products section. Each tier can have different features and pricing.

8.3 License Verification

Q: How secure is the license verification process?

A: The license verification process is highly secure. It uses hardware ID, domain, or IP verification to ensure that licenses are only used on authorized devices or servers.

Q: What happens if a customer tries to use a license on multiple devices?

A: If a license has a limit on the number of activations, the system will prevent activation on additional devices once the limit is reached. You can configure this limit when generating the license.

Q: How do I implement offline license verification?

A: For offline verification, you can use the SDK to generate a verification token that can be validated without an internet connection. This is useful for applications that need to work offline.

If you have additional questions, please contact our support team at support@licensingsystem.com.