-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.php
60 lines (54 loc) · 2.17 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html>
<head>
<title>Sample Envato Purchase Code Verifier</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="wrap">
<!-- // Include the EnvatoPurchaseCodeVerifier.php file that holds the verifier class.-->
<?php require_once 'EnvatoPurchaseCodeVerifier.php'; ?>
<!-- // Create your own access token at (https://build.envato.com/create-token)-->
<?php $access_token = 'your_token'; // Change 'your_token' value with your own token ?>
<!-- // Create new instance of EnvatoPurchaseCodeVerifier. -->
<!-- // Pass your own access token -->
<?php $purchase = new EnvatoPurchaseCodeVerifier($access_token); ?>
<?php $buyer_purchase_code = filter_input(INPUT_POST, 'purchase_code', FILTER_DEFAULT); ?>
<!-- check if user submits the form -->
<?php if ( ! empty( $buyer_purchase_code ) ) { ?>
<?php $verified = $purchase->verified($buyer_purchase_code); ?>
<!-- User purchase code is good!-->
<?php if ( $verified ) { ?>
<?php
$item_id = $verified->item->id;
$item_name = $verified->item->name;
$buyer = $verified->buyer;
$license = $verified->license;
$amount = $verified->amount;
$sold_at = $verified->sold_at;
$supported_until = $verified->supported_until;
?>
<h1>Valid Purchase Code</h1>
<table>
<tr><td>Item ID:</td><td><?php echo $item_id; ?></td></tr>
<tr><td>Item Name:</td><td><?php echo $item_name; ?></td></tr>
<tr><td>Buyer:</td><td><?php echo $buyer; ?></td></tr>
<tr><td>License:</td><td><?php echo $license; ?></td></tr>
<tr><td>Amount:</td><td><?php echo $amount; ?></td></tr>
<tr><td>Sold At:</td><td><?php echo $sold_at; ?></td></tr>
<tr><td>Supported Until:</td><td><?php echo $supported_until; ?></td></tr>
</table>
<?php } else { ?>
<!-- Invalid purchase code -->
<h1>Invalid Purchase Code</h1>
<?php } ?>
<?php } else { ?>
<form action="index.php" method="post">
<label>Purchase Code: </label>
<input type="text" name="purchase_code" placeholder="Type or paste the buyer's purchase code here"><br>
<input type="submit">
</form>
<?php } ?>
</div>
</body>
</html>