Along with the code comes a test script in the /examples folder of the plugin. This plugin allows you to post data to the API for testing purposes.
Note: This is a Developer level section. If you are unfamiliar with code and resolving potential conflicts, hire us for assistance. We are able to provide support under our Support Policy.
Example code
A WooCommerce-powered shop using the WooCommerce serial numbers is listening for API requests via the wc-api
request set to serial-numbers-api. All API requests can be called like this:
$data = wp_remote_get( 'http://yoursite.com/?wc-api=serial-numbers-api&request=request_key&...');
CHECK
The check API call is used to check if a license has been activated. The call must contain the email address of the license, the serial key and the product id linked to the license. It will return information about the current activations.
Status Endpoint
http://yoursite.com?wc-api=serial-numbers-api
Parameter | Type | Description |
---|---|---|
request |
string | check |
email |
string | Activation email |
serial_key |
string | The license key provided to the customer. |
product_id |
integer | Product ID |
ACTIVATE
The activate
API call is used to activate a single use of a license. The call must contain the email address of the license, the license key and the product ID linked to the license.
Activate Endpoint
http://wcserialnumbers.test?wc-api=serial-numbers-api
Parameter | Type | Description |
---|---|---|
request |
string | activate |
email |
string | Activation email |
serial_key |
string | The license key provided to the customer. |
product_id |
integer | Product ID |
instance |
string | This can be used anything specific, like domain. |
platform |
string | Decided by user, can be anything.(Optional) |
DEACTIVATE
The deactivation API call deactivates a single use of a license. The call must contain the email address of the license, the serial key and the instance (set by activation call) of the activation. If the instance is left blank, activation for this license is deactivated.
Deactivate Endpoint
http://wcserialnumbers.test?wc-api=serial-numbers-api
Parameter | Type | Description |
---|---|---|
request |
string | deactivate |
email |
string | Activation email |
serial_key |
string | The license key provided to the customer. |
product_id |
integer | Product ID |
instance |
string | Instance set at the time of activation |