-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesteFernando.php
66 lines (57 loc) · 2 KB
/
testeFernando.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
<?php
$credenciais = array(
"email" => "[email protected]",
"token" => "4E0499D6BB3C4347AA263BB95E30E5FC"
);
$url = "https://ws.pagseguro.uol.com.br/v2/sessions";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($credenciais));
$resultado = curl_exec($curl);
curl_close($curl);
?>
<html>
<head>
<title>
</title>
</head>
<body>
<center><h1>Exemplo - Checkout Transparente.</h1></center>
<hr>
<p><b>SessionID:</b> <?php echo $resultado;?></p>
<hr>
<b>Gerando o identificador do comprador.</b><br>
<p><button id="SenderHash">Gerar getSenderHash</button> <input type="hidden" id="hash" size="80" readonly="true">
<hr>
<b>Cartão de Crédito:</b><input type ="text" id ="numero"><input type="hidden" id="bandeira"><br>
<hr>
</body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="https://stc.pagseguro.uol.com.br/pagseguro/api/v2/checkout/pagseguro.directpayment.js"></script>
<script type="text/javascript">
PagSeguroDirectPayment.setSessionId('<?php echo $resultado;?>');
$("#SenderHash").click(function(){
var Hash = PagSeguroDirectPayment.getSenderHash();
console.log(Hash);
$("#hash").val(Hash);
$("#hash").attr('type','text');
})
$("#numero").keyup(function(){
if($("#numero").val().length == 6){
PagSeguroDirectPayment.getBrand({
cardBin: $("#numero").val().substring(0,6),
success: function(response){
console.log(response);
var brand = response['brand']['name'];
$("#bandeira").val(brand);
$("#bandeira").attr('type','text');
},
error: function(response) {
console.log("erro " + response);
}
});
}
})
</script>
</html>