Upgrade Licenses
Upgrade licenses let your existing customers transition from their current version or edition to a newer one. A user with My Product Standard can upgrade to My Product Gold, or a user on V1 can upgrade to V2.
The upgrade process involves two serial numbers: the source (current license) and the target (upgrade license). The KEYZY server validates the upgrade path, deletes the source license, and makes the target available for activation.
Prerequisites
- The KEYZY C++ Client Library integrated into your project — see Quick Start if you haven’t done this yet
- A
ProductDatastructure configured with your credentials - An upgrade license created in the KEYZY dashboard — when generating licenses, mark them as upgrade licenses and select which SKU to upgrade from
Setup
Create the activator and obtain the validator:
#include "KeyzyLicenseActivator.h"
Keyzy::ProductData productData(
"YOUR_APP_ID",
"YOUR_API_KEY",
"YOUR_PRODUCT_CODE",
"YOUR_CRYPTION_KEY"
);
std::unique_ptr<Keyzy::KeyzyLicenseActivator> pActivator =
std::make_unique<Keyzy::KeyzyLicenseActivator>(productData);
std::shared_ptr<Keyzy::KeyzyLicenseValidator> pValidator =
pActivator->getLicenseValidator();
Upgrade Using the Stored Serial (Recommended)
If the user’s current license is already activated on the device, the source serial is stored locally. You only need to provide the target (upgrade) serial:
std::string targetSerial = "TARG-ETSE-RIAL-XXXX"; // the upgrade serial
Keyzy::LicenseStatus status = pActivator->upgradeLicense(targetSerial);
if (status == Keyzy::LicenseStatus::VALID)
{
// Upgrade successful on the server — now activate the target serial
status = pActivator->activateSemiOnline(targetSerial);
}
else
{
// Upgrade failed
}
Upgrade with Explicit Serials
If you need to provide both serials explicitly (e.g. the source serial is not stored on the device), use the two-parameter overload:
std::string sourceSerial = "SOUR-CESE-RIAL-XXXX"; // current license
std::string targetSerial = "TARG-ETSE-RIAL-XXXX"; // upgrade license
Keyzy::LicenseStatus status = pActivator->upgradeLicense(sourceSerial, targetSerial);
if (status == Keyzy::LicenseStatus::VALID)
{
// Upgrade successful on the server — now activate the target serial
status = pActivator->activateSemiOnline(targetSerial);
}
else
{
// Upgrade failed
}
Important: Activate After Upgrade
The upgradeLicense() method only performs the upgrade on the KEYZY server. It does not activate the new license or store the target serial on the device. After a successful upgrade, you must call one of the activation methods to activate the target serial:
// Choose the activation schema that matches your setup
pActivator->activateSemiOnline(targetSerial); // or
pActivator->activateOnline(targetSerial); // or
pActivator->activateOffline(licenseFilePath);
Typical Application Flow
auto pActivator = std::make_unique<Keyzy::KeyzyLicenseActivator>(productData);
auto pValidator = pActivator->getLicenseValidator();
// User enters the upgrade serial
std::string targetSerial = getUpgradeSerialFromUser(); // your UI code
// Upgrade on the server (source serial is read from the device)
Keyzy::LicenseStatus status = pActivator->upgradeLicense(targetSerial);
if (status == Keyzy::LicenseStatus::VALID)
{
// Activate the new license
status = pActivator->activateSemiOnline(targetSerial);
if (status == Keyzy::LicenseStatus::VALID)
{
// Upgrade complete — unlock the new version/edition
}
}
else if (status == Keyzy::LicenseStatus::UPGRADE_LICENSE_DOES_NOT_MATCH)
{
// The upgrade serial doesn't match the current license's upgrade path
}
else if (status == Keyzy::LicenseStatus::CLIENT_SERIAL_DOES_NOT_EXIST)
{
// No source serial stored — ask for both serials
}
WooCommerce Integration
If you are using the KEYZY WooCommerce plugin, your customers can perform the upgrade directly from your store. The plugin provides an upgrade form where the user enters both serial numbers, and the upgrade is handled automatically on the server side.
Error Handling
The most common LicenseStatus values for upgrade operations are UPGRADE_LICENSE_DOES_NOT_MATCH, UPGRADE_LICENSE_DOES_NOT_EXIST, CURRENT_LICENSE_DOES_NOT_EXIST, and CLIENT_SERIAL_DOES_NOT_EXIST.
For the complete list of all status codes and their descriptions, see the C++ License Status Codes reference.
Next Steps
- Semi-Online Activation — Most common activation schema after upgrade
- Online Activation — Server-validated on every launch
- Offline Activation — No internet connection required
- Trial Licenses — Let users try before they buy
- C++ License Status Codes — Complete list of all LicenseStatus values
- Quick Start — Getting started from scratch