-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
96 lines (96 loc) · 4.7 KB
/
example.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!-- Monetary WebToken Example Payment Form -->
<html>
<head>
<title>Monetary WebToken Demo</title>
<link rel="stylesheet" href="stylesheets/example.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
<script src="https://token.monetary.co/v1/client"></script>
<script>
// Tokenization Callback
var tokenCallback = function(response) {
if (response.Error) {
// Handle tokenization errors
var error = response.Error;
document.getElementById('payment_errors').innerHTML = error;
document.getElementById('pay_button').disabled = false;
}
else {
var token = response.Token;
// Add token to payment form control
document.getElementById("payment_token").value = token;
// Submit payment form
document.getElementById("payment_form").submit();
}
}
// Function to call for tokenization
var tokenize = function(formName) {
MonetaryWebToken.requestToken("[Public Key Goes Here]", formName, tokenCallback);
}
</script>
</head>
<body>
<div class="container container-table">
<div class="row vertical-center-row">
<div class="col-xs-8 col-md-4 col-md-offset-4">
<div class="panel panel-default credit-card-box">
<div class="panel-heading display-table">
<div class="row display-tr">
<h3 class="panel-title display-td">Payment Details</h3>
<div class="display-td">
<img class="img-responsive pull-right" src="accepted.png">
</div>
</div>
</div>
<div class="panel-body">
<form id="payment_form">
<div class="row">
<div class="col-xs-12">
<div class="form-group">
<label for="cardNumber">Card Number</label>
<div class="input-group">
<input type="tel" class="form-control" data-token="card_number" placeholder="Valid Card Number" required autofocus />
<input type="hidden" id="payment_token" />
<span class="input-group-addon"><i class="fa fa-credit-card"></i></span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-4 col-md-4">
<div class="form-group">
<label>Exp Month</label>
<input type="tel" class="form-control" data-token="exp_month" placeholder="MM" maxlength="2" required />
</div>
</div>
<div class="col-xs-4 col-md-4">
<div class="form-group">
<label>Exp Year</label>
<input type="tel" class="form-control" data-token="exp_year" placeholder="YYYY" maxlength="4" required />
</div>
</div>
<div class="col-xs-4 col-md-4 pull-right">
<div class="form-group">
<label>CVV Code</label>
<input type="tel" class="form-control" data-token="cvv" placeholder="CVV" maxlength="4" required />
</div>
</div>
</div>
<div class="row" style="margin-top:20px;">
<div class="col-xs-12">
<button id="pay_button" class="btn btn-success btn-lg btn-block" type="button" onclick="tokenize('payment_form'); this.disabled=true;">Pay</button>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<p class="payment-errors text-center" id="payment_errors"></p>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>