Software Licensing - Deactivating License Keys in WordPress Plugins and Themes

Software Licensing is an extension for Easy Digital Downloads that makes it easy to license your digital products. Learn more at the main Easy Digital Downloads website.

With  Software Licensing, after a license has been been activated, it can also be deactivated remotely (since v1.3). Usually the reason to deactivate a license is to permit a license to be activated on an additional site once the activation limit has been reached.

Before reading this documentation, please read through the instructions for how to  activate a license.

The deactivation process is nearly identical to the activation process. We perform a remote request and send the details of the license key we are deactivating. The remote request is done like so:

// data to send in our API request
$api_params = array(
	'edd_action' => 'deactivate_license',
	'license'    => '2ec66bae356be570236531ccba06a45b',
	'item_name'  => 'Sample Plugin', // the name of our product in EDD
	'url'        => home_url()
);
// Send the remote request
$response = wp_remote_post( 'http://yoursite.com', array( 'body' => $api_params, 'timeout' => 15, 'sslverify' => false ) );

The  $response var will be a json object that tells us whether the deactivation request was successful or not. If it is successful, the response will be:

{
	"success": true,
	"license": "deactivated",
	"item_name": "Sample Plugin",
	"expires": '2018-02-02 23:59:59',
	"payment_id": 2444,
	"customer_name": "John Doe",
	"customer_email": "john@sample.com"
}

If the license fails to be deactivated, the response will be:

{
	"success": false,
	"license": "failed",
	"item_name": "Sample Plugin",
	"expires": '2018-02-02 23:59:59',
	"payment_id": 2444,
	"customer_name": "John Doe",
	"customer_email": "john@sample.com"
}

Once a license has been successfully deactivated, the  Site Count column in Downloads > Licenses will be decremented and an entry will be recorded in the log so that admins can see where a license was deactivated from.