-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
68 lines (63 loc) · 1.24 KB
/
scripts.js
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
var brandName;
var hash;
var cardToken;
var numCard = '4444.444.4444.4444';
var totalValue = '200.00';
var cvvCard = '123';
var monthCard = '10';
var yearCard = '2030';
// getSessionId
function getSessionId(){
$.ajax({
url: 'getSessionId.php',
type: 'POST',
dataType: 'json',
success: function (res) {
PagSeguroDirectPayment.setSessionId(res.id);
}
});
}
// Hash Generate
PagSeguroDirectPayment.onSenderHashReady(function(res){
if(res.status == 'error') {
console.log(res.message);
return false;
}
hash = res.senderHash;
});
// getBrand
PagSeguroDirectPayment.getBrand({
cardBin: numCard.replace(/\s/g, ''),
success: function (res) {
brandName = res.brand.name;
},
error: function (res) {
console.log(res);
}
});
// getInstallments
PagSeguroDirectPayment.getInstallments({
amount: totalValue,
maxInstallmentNoInterest: 18,
brand: brandName,
success: function(res){
console.log(res);
},
error: function(res) {
console.log(res);
}
});
// Create CardToken
PagSeguroDirectPayment.createCardToken({
cardNumber: numCard,
brand: brandName,
cvv: cvvCard,
expirationMonth: monthCard,
expirationYear: yearCard,
success: function(res) {
cardToken = res.card.token;
},
error: function(res) {
console.log(res);
}
});