Verify purchase code and Validate One purchase code for one URL only

Hello,

I am new in Envato Author. I have one product in CodeCanyon. I want to verify purchase key and one purchase key will be valid for one domain (URL) only.

I have used this script

<?php
if(isset($_REQUEST['submit']))
		 {
$product_code = $_POST['product_code'];
$url = "https://api.envato.com/v3/market/author/sale?code=".$product_code;
$curl = curl_init($url);
$personal_token = "API KEY...................................";
$header = array();
$header[] = 'Authorization: Bearer '.$personal_token;
$header[] = 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:41.0) Gecko/20100101 Firefox/41.0';
$header[] = 'timeout: 20';
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER,$header);
$envatoRes = curl_exec($curl);
curl_close($curl);
$envatoRes = json_decode($envatoRes);
 }
?><form method="post" id="purchase_code">
<input type="text" name="product_code">
<button type="submit" name="submit" value="Save and Submit">Activate</button>
</form>
<?php
if (isset($envatoRes->item->name)) {  
$date = new DateTime($envatoRes->supported_until);
$result = $date->format('Y-m-d H:i:s'); 
    $author_url = "{$envatoRes->item->author_url}";
	$item_id = "{$envatoRes->item->id}";
	$item_name = "{$envatoRes->item->name}";
	$support_date = "{$envatoRes->supported_until}";
	$buyer_name = "{$envatoRes->buyer}";
	$license = "{$envatoRes->license}";
	$amount = "{$envatoRes->amount}";
	?>
<input type="text" value="<?php echo $product_code; ?>" name="product_code">
<input type="text" value="<?php echo $author_url; ?>" name="author_url">
<input type="text" value="<?php echo $item_id; ?>" name="item_id">
<input type="text" value="<?php echo $item_name; ?>" name="item_name">
<input type="text" value="<?php echo $support_date; ?>" name="support_date">
<input type="text" value="<?php echo $buyer_name; ?>" name="buyer_name">
<input type="text" value="<?php echo $license; ?>" name="license">
<input type="text" value="<?php echo $amount; ?>" name="amount">

<input type="text" value="<?php echo "http://" . $_SERVER['SERVER_NAME']; ?>" name="server_url">
<?php 
} else {
	$data= " FAILED";
?>
<input type="text" value="<?php echo $data; ?>" name="author_url">
<?php } ?>

Here I can verify the purchase code. But I cant verify if that purchase code is already installed in an URL or not. If already installed then the purchase code will show error an message .

Please help. Thanks in advance.

Hello,

There are several ways to allow your product to be valid for one single domain (URL). You may create a database table where you store the server name and the purchase code. After then, check and compare all rows on your table if the buyer trying to install your product again from different domain name with the same purchase code.

Hope this helps!

Hello,

Thanks for your reply. I want to save the record once user click on “Activate” button. Right now Activate button is checking if the license key if genuine or not. Do I need to add another button, where user click on that a record will save in database ?

Please suggest with full code.

thanks in advance.

Hi @xlinkinfocom,

there should be only one button (e.g. Activate License) when customer will provide purchase code and click on the button you should check purchase code validation and at the same time you need to do the necessary database work for checking purchaser and activated domain.

Thanks

Is there any dummy purchase code for testing my envato purchase code validation? Stripe API has test card number 4242 4242 4242 4242. I am searching for dummy envato purchase code for testing purpose.

Is there any dummy purchase code for testing my envato purchase code validation? Stripe API has test card number 4242 4242 4242 4242. I am searching for dummy envato purchase code for testing purpose. Do you know the answer?

No, there is no such dummy code. envato don’t have any sandbox to test the purchase code.

Thanks. I am new user of envato. I am coding for my envato product license verification. how I am going to sure my code working or has some mistakes?

You can check this helpful reply from @baileyherbert :