Your cart is currently empty!
SimpleLicense is a lightweight WooCommerce plugin that generates unique license keys for products if enabled on that product, stores them in WordPress, and provides an external validation endpoint. This setup is ideal for verifying licenses from applications that interact with your WooCommerce store, such as SaaS products, desktop or mobile apps, or other online services.
Key Features for External License Validation
- Unique License Keys for Each Order
SimpleLicense automatically generates a unique license key when a customer completes an order. Each key is tied to the specific product purchased and can be configured with an expiration date or duration. - REST API for License Validation
The SimpleLicense plugin includes a REST API endpoint for validating licenses. This API lets your applications verify if a license is valid and unexpired directly through an HTTP request, enabling secure validation outside WordPress. - Credential-Based Authentication
Validation requests are protected by basic authentication, requiring an application password to prevent unauthorized access. This secure setup is ideal for apps that need to authenticate license holders in real time. - Create daily, monthly, yearly etc licenses from time of purchase
How to Use SimpleLicense for External License Validation
With SimpleLicense, validating licenses from an external application is straightforward. Here’s an example to get you started:
Step 1: Set Up License-Based Products
In WooCommerce, enable licensing for each product by specifying a duration or expiration date for the license. This step ensures a unique license is generated for each purchase and is available for validation.
Step 2: Use the REST API to Validate Licenses
When a customer activates their license from your application, use the SimpleLicense API to confirm the license details. Here’s a JavaScript example for validating a license using fetch
:
Example JavaScript (using Fetch API):
Note: Replace username and application_password with your actual credentials, and YOUR_LICENSE_CODE, PRODUCT_ID, and EMAIL with the license and product ID you want to validate.
fetch('https://yoursite.com/wp-json/simple-license/v1/validate/', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa('username:application_password'),
'Content-Type': 'application/json'
},
body: JSON.stringify({
license: 'YOUR_LICENSE_CODE',
product_id: 'PRODUCT_ID',
email: 'EMAIL'
})
})
.then(response => response.json())
.then(data => {
if (data.valid) {
console.log('License is valid');
} else {
console.log('License is invalid');
}
})
.catch(error => console.error('Error:', error));
Here’s an example using cURL:
curl -X POST https://yoursite.com/wp-json/simple-license/v1/validate/ -u "username:application_password" -H "Content-Type: application/json" -d '{"license": "YOUR_LICENSE_CODE", "product_id": "PRODUCT_ID", "email": "EMAIL"}'
by
Tags: