-
Notifications
You must be signed in to change notification settings - Fork 0
/
webhook.php
75 lines (61 loc) · 2.14 KB
/
webhook.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
// ini_set('display_errors',1);
// ini_set('display_startup_erros',1);
// error_reporting(E_ALL);
include "../app/variaveis.php";
include "../app/constants.php";
include "../app/conexao.php";
include "../app/function.php";
include "includes/variaveis.php";
include "includes/functions.php";
header('Content-type: application/json');
date_default_timezone_set('America/Sao_Paulo');
acessoAPI();
urlAPI();
$pagamento = $urlapi[3];
$pagamentoac = array("boleto", "cartao", "pix", "debito");
$token = $urlapi[4];
if ($metodo == "GET") {
header("Content-Type:application/json");
include "includes/curlconsulta.php"; //Conversa com a API do Boleto
// echo in_array($pagamento, $pagamentoac) ? "" : die(json_encode(array('aviso' => 'Meio de pagamento nao aceito')));
if (!in_array($pagamento, $pagamentoac)) {header($http." 400");die(json_encode(array('aviso' => 'Meio de pagamento nao aceito')));}
if (!$token) { die(json_encode(array('aviso' => 'Sem Token complica...'))); }
switch ($pagamento) {
case "boleto":
webhook ($pagamento, $token);
break;
case "cartao":
webhook ($pagamento, $token);
break;
case "pix":
die(json_encode(array('aviso' => 'PIX em breve')));
break;
case "debito":
die(json_encode(array('aviso' => 'Debito em breve')));
break;
}
} else {
header($http." 405");
die( json_encode(array('aviso' => 'Metodo nao compativel.')) );
}
function webhook ($pagamento, $token) {
global $http;
$status = "";
$buscatoken = "231323123213213231244312";
$numero = "0";
header($http." 200");
if ($numero) {
$response['status'] = true;
$response['pagamento'] = $pagamento;
$response['token'] = $token;
$response['message'] = "Pagamento efetuado";
} else {
$response['status'] = false;
$response['pagamento'] = $pagamento;
$response['token'] = $token;
$response['message'] = "Pagamento pendente";
}
$json = json_encode($response);
echo $json;
}