-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gerar_Token.html
63 lines (48 loc) · 2.48 KB
/
Gerar_Token.html
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
<!DOCTYPE html>
<!-- This html script must be used into a configured virtual host in your Web Server -->
<html>
<head>
<meta charset="utf-8">
<title>Boacompra Direct Checkout Test</title>
<!-- Script loaded with a dynamic parameter (?p=999999) value to invalidate the browser cache. -->
<script type="text/javascript" src="https://stc.boacompra.com/payment.boacompra.min.js?p=999999"></script>
<script type="text/javascript">
// You MUST instance the payment object ASAP after add the javascript on page,
// it will prevent loading time issues in the flow.
var payment = new Boacompra.PaymentMethod();
</script>
</head>
<body>
<a href="javascript:charge()" target="_self">Click here to Generate the DirectToken</a>
<script type="text/javascript">
// Example: https://developers.boacompra.com/direct-checkout/#creating-a-credit-card-payment
function charge() {
// User's credit card data should be collected in a html form
var cardData = {
creditCard: '5555666677778884',
cvv: '123',
expiration: {
month: '02',
year: '2026'
}
};
//callback function will contain errors or a directToken
var callback = function(err, directToken) {
if (err) {
// Check all errors in:
// https://developers.boacompra.com/direct-checkout/#direct-payment-js
alert('Error: ' + err);
return false;
}
alert('Success!\ndirect-token: ' + directToken + '\n\nUse them to create your transaction.');
// Post [directToken + user data, previously collected from html forms] to your server (Ajax request)
// The directToken parameter will be used to create your transaction
// on the endpoint https://api.boacompra.com/transactions
// The directToken parameter and others are descibed in our Manual:
// https://developers.boacompra.com/direct-checkout/#transaction-api
};
payment.getDirectToken(cardData, callback);
}
</script>
</body>
</html>