Hi!
We need to insert a custom field on the checkout page. Our product is a digital plugin that is linked to a license code from an application. People give there own application license where we create a new one to secure the plugin. This way the plugin is locked to one application license. Very common way to secure for Cinema 4D plugins.
How can we add a new field to the checkout page to make this work? The script will generate a lic. file (or txt file) that needs to be stored on the server.
To make it even more complicated, not all product need to have a license generator.
You help is really appreciated! 🙂
This is an example of the code:
<?php
function GenerateLicense ($C4Dserial) {
$LicenseSalt1 = ‘salt1’;
$LicenseSalt2 = ‘salt2’;
$LicenseChallange = $LicenseSalt1.$C4Dserial.$LicenseSalt2;
$LicenseHash = hash (‘sha256′, $LicenseChallange);
$License = substr ($LicenseHash,8).substr ($LicenseHash,0,8);
$LicenseFileName = “/licenses/”.$C4Dserial.’license.lic’;
$LicenseFileHandle = fopen($LicenseFileName, ‘w’) or die(“can’t open file”);
fwrite($LicenseFileHandle, $License);
fclose($LicenseFileHandle);
return $C4Dserial.’license.lic’;
}
function StreamLicenseFile ($LicenseFile) {
$LicenseFileFullpath = ‘/licenses/’.$LicenseFile;
if (file_exists($LicenseFileFullpath)) {
header(‘Content-Description: File Transfer’);
header(‘Content-Type: application/octet-stream’);
header(‘Content-Disposition: attachment; filename=license.lic’);
header(‘Content-Transfer-Encoding: binary’);
header(‘Expires: 0’);
header(‘Cache-Control: must-revalidate’);
header(‘Pragma: public’);
header(‘Content-Length: ‘ . filesize($LicenseFileFullpath));
ob_clean();
flush();
readfile($LicenseFileFullpath);
}
}
$StreamFile = GenerateLicense (‘1234567890’);
StreamLicenseFile ($StreamFile);
?>