1- Create an account with hotmart: https://app-vlc.hotmart.com/
2- Create a subscription product
3- Go to your product page -> tools - > webhook
4- Create a new setting for 'order approved' make sure the url is yourdomain.com/appfolder/sub_access.php
sub_access.php
Code: Select all
<?php
$currDir = dirname(__FILE__);
include("{$currDir}/language.php");
include("{$currDir}/defaultLang.php");
include("{$currDir}/lib.php");
include_once("{$currDir}/header.php");
$adminConfig = config('adminConfig');
print_r($_POST);
$name = $_POST["name"];
$email = $_POST["email"];
$statuss = $_POST["subscription_status"];
print_r($data);
print($email . ' ' . $statuss);
$date0 = new DateTime();
$date1 = new DateTime();
$date1->modify('+'.'34'.' day');
$date2 = $date1->format('Y-m-d');
$sql = "SELECT memberID FROM membership_users WHERE email = '{$email}'";
$datos = sqlValue($sql);
if ( $datos == "" ){
sql("INSERT INTO `membership_users` set memberID='{$email}', passMD5='" . password_hash('whateverpass', PASSWORD_DEFAULT) . "', email='{$email}', signupDate='" . @date('Y-m-d') . "', groupID='7', isBanned='0', isApproved='1', custom1='{$name}', custom2='1', custom3='', custom4='{$date2}', comments=''", $eo);
}else{
sql("UPDATE `membership_users` SET `groupID` = '7', `custom4` = '{$date2}' WHERE email = '{$email}'", $eo);
}
$to = $email;
$subject = $name." - Welcome to my app";
$message = "
<html>
<head>
<title>Welcome</title>
</head>
<body>
<div style='text-align: center'><img style='width: 250px' src='yourlogourl.png' /></div>
<table align='center'>
<p><br/></p>". "\n". "\n". "\n". "\n". "\n"."
<tr>
<td align='center'> Hello ".$name.", welcome to the App!</td>
</tr>
<p><br/></p>". "\n" . "
<tr>
<td align='center'> credentials: </td>
</tr>
<tr>
<td align='center'> (user/pass) </td>
</tr>
<p> </p>
</table>
<p><br/></p>". "\n". "\n". "\n". "\n". "\n". "\n". "\n". "\n"."
<table align='center'>
<tr>
<th align='center'>user</th>
</tr>
<tr>
<td align='center'>".$email."</td>
</tr>
<p> </p>
</table>
<table align='center'>
<tr>
<th align='center'>pass</th>
</tr>
<tr>
<td align='center'>whateverpass</td>
</tr>
</table>
<p><br/></p>". "\n". "\n". "\n". "\n". "\n". "\n". "\n". "\n"."
<table align='center'>
<tr>
<th align='center'>Access App</th>
</tr>
<tr>
<td align='center'>https://yourappurl.com</td>
</tr>
<p> </p>
</table>
<p><br/></p>". "\n". "\n". "\n". "\n". "\n". "\n". "\n". "\n"."
<table align='center'>
<tr>
<th align='center'>Contact</th>
</tr>
<tr>
<td align='center'>[email protected]</td>
</tr>
</table>
<p> </p>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <[email protected]>' . "\r\n";
mail($to,$subject,$message,$headers);
?>
Code: Select all
var ps2 = '0';
$j.ajax({
url: 'hooks/ajax-ps2.php',
data: { entidad_id: ps2 },
success: function(data){
if (data) {
console.log(data);
window.location.replace('hooks/erro_hook.php');
}else{
//console.log('no data');
}
}
});
6- Also inside hooks folder create erro_hook.php (this is re-activation page)
Code: Select all
<?php
define('PREPEND_PATH', '../');
$hooks_dir = dirname(__FILE__);
include("$hooks_dir/../defaultLang.php");
include("$hooks_dir/../language.php");
include("$hooks_dir/../lib.php");
include_once("$hooks_dir/../header.php");
//include_once("$hooks_dir/../footer.php");
$mi = getMemberInfo();
?>
<style>
.panel-body-description{
margin-top: 10px;
height: 100px;
overflow: auto;
}
.panel-body .btn img{
margin: 0 0px;
max-height: 32px;
}
.glyphicon {
font-size: 7px;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/roundSlider/1.3.2/roundslider.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/roundSlider/1.3.2/roundslider.min.js"></script>
<div id="teste" class="" style="text-align: center;">
<div style="text-align: center"><img src="../logon2.png" onmouseover="this.src='../logon2.png'" onmouseout="this.src='../logon2.png'" style="width:250px;height:250px;" /></div>
<div style="text-align: center"><img src="../spacer.png" style="width:50%;height:85px;" /></div>
<div style="text-align: center"><img src="../rc.png" onmouseover="this.src='../rc1.png'" onmouseout="this.src='../rc.png'" style="width:320px;height:64px;" id="img1"/></div>
<script type="text/javascript">
jQuery('#img1').click(function(){
var lki = '1';
jQuery.ajax({
url: 'ajax-email.php',
data: { entidad_id: lki },
success: function(data){
if (data) {
console.log(data);
window.location.replace('https://checkout.hotmart.com/HOTMARTPRODUCT_ID?email='+data);
}else{
console.log('no data');
}
}
});
});
</script>
7- inside hooks folder add the file ajax-ps2.php:
Code: Select all
<?php
$currDir = dirname(__FILE__) . '/..';
include("$currDir/defaultLang.php");
include("$currDir/language.php");
include("$currDir/lib.php");
/* grant access to all users who have acess to the orders table */
$mi = getMemberInfo();
$entidad = makesafe($_REQUEST['entidad_id']);
$date1 = new DateTime();
$date3 = $date1->format('Y-m-d');
$date2 = $mi['custom'][3];
if ( $date3 > $date2 ){
echo $date3.' > '.$date2.' -- '.$mi['username'];
sql("UPDATE `membership_users` SET `groupID` = '124' WHERE `memberID` = '{$mi['username']}'", $eo);
};
?>
Code: Select all
<?php
$currDir = dirname(__FILE__) . '/..';
include("$currDir/defaultLang.php");
include("$currDir/language.php");
include("$currDir/lib.php");
/* grant access to all users who have acess to the orders table */
$entidad = makesafe($_REQUEST['entidad_id']);
$mi = getMemberInfo();
echo $mi['email'];
?>
* This is a short summary that really gives you everything you need, the 'order approved' event is fired from hotmart when first subscription payment is made and also for all future recurrent payments, we give the user 34 days of credit because hotmart still tries to process the charge for 3 days after the due date in case it was declined for whatever reason, if user fails to pay, order approved will not be fired, and after the expiration date when user tries to log in he will be redirected to the re-activation page to go through hotmart checkout again, it is important to initiate that checkout with the same email that account was registered look : window.location.replace('https://checkout.hotmart.com/HOTMARTPRO ... ail='+data);
also to note:
active user group ID = 2
inactive = 124
admin email settings must be set for mail script to work
hope it helps