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.