Skip to content

Instantly share code, notes, and snippets.

@mbmaciel
Created January 30, 2023 16:53
Show Gist options
  • Save mbmaciel/fe28fc71391b2cf09c15cac0759f8900 to your computer and use it in GitHub Desktop.
Save mbmaciel/fe28fc71391b2cf09c15cac0759f8900 to your computer and use it in GitHub Desktop.
Webhook para eduzz
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Origin, Cache-Control, Pragma, Authorization, Accept, Accept-Encoding");
require_once('wp-load.php');
require_once('wp-includes/user.php');
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
$senha = "20202525" ; //generateRandomString (5);
// Pega os dados do post
$data = json_decode(file_get_contents('php://input'), true);
//print_r($data);
$cus_email = $data["customer"]["email"];
$cus_name = $data["customer"]["name"];
$event = $data["status"];
file_put_contents("post.log", print_r($data, true));
$msg = "<img src=\"https://loginplaybotpro.com/wp-content/uploads/2022/10/BOT-PRO-04-e1666883879176.png\"><h4>Agradecemos por adquirir o plano de acesso ao Playbot Pro. \n\n <br> Seus dados para acessar email: ".$cus_email." e senha: ".$senha."\n\n <br>Use-os para acessar a plataforma \n\n <br><br><a href='http://playbotpro.com/login.html'>Clique aqui para entrar na plataforma</a></h4>";
switch ($event) {
case 'APPROVED':
// Pagou
libera_acesso($cus_email, $senha, $msg);
break;
case 'COMPLETED':
libera_acesso($cus_email, $senha, $msg);
break;
case '7': // Reembolsado
remove_acesso();
break;
// ...
// ...
// ...
default:
echo "STATUS DESCONHECIDO";
break;
}
function libera_acesso($cus_email, $senha, $msg) {
$headers = array('Content-Type: text/html; charset=UTF-8');
if (is_numeric (wp_create_user( $cus_email, $senha , $cus_email )) )
{
echo "ACESSO LIBERADO";
wp_mail( $cus_email, "Playbot PRO", $msg, $headers) ;
//wp_mail( "[email protected]", "Novo Cadastro" , $msg);
} else {
echo "ERRO AO CADASTRAR OU JÁ CADASTRADO";
}
}
function remove_acesso() {
echo "ACESSO REMOVIDO";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment