-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsimple.html
More file actions
136 lines (117 loc) · 5.6 KB
/
simple.html
File metadata and controls
136 lines (117 loc) · 5.6 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html>
<html>
<head>
<title>DatPayment example</title>
<meta charset='utf-8'>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="../dist/css/DatPayment.css">
<link rel="stylesheet" type="text/css" href="./example.css">
</head>
<body>
<form action="/" method="POST" id="payment-form" class="datpayment-form">
<div class="dpf-title">
Paiement par carte bancaire
<div class="accepted-cards-logo"></div>
</div>
<div class="dpf-card-placeholder"></div>
<div class="dpf-input-container">
<div class="dpf-input-row">
<label class="dpf-input-label">Numéro de carte</label>
<div class="dpf-input-container with-icon">
<span class="dpf-input-icon"><i class="fa fa-credit-card" aria-hidden="true"></i></span>
<input type="text" class="dpf-input" size="20" data-type="number">
</div>
</div>
<div class="dpf-input-row">
<div class="dpf-input-column">
<input type="hidden" size="2" data-type="exp_month" placeholder="MM">
<input type="hidden" size="2" data-type="exp_year" placeholder="YY">
<label class="dpf-input-label">Date d'expiration</label>
<div class="dpf-input-container">
<input type="text" class="dpf-input" data-type="expiry">
</div>
</div>
<div class="dpf-input-column">
<label class="dpf-input-label">Code de vérification</label>
<div class="dpf-input-container">
<input type="text" class="dpf-input" size="4" data-type="cvc">
</div>
</div>
</div>
<div class="dpf-input-row">
<label class="dpf-input-label">Nom du porteur</label>
<div class="dpf-input-container">
<input type="text" size="4" class="dpf-input" data-type="name">
</div>
</div>
<button type="submit" class="dpf-submit">
<span class="btn-active-state">
Payer maintenant
</span>
<span class="btn-loading-state">
<i class="fa fa-refresh "></i>
</span>
</button>
</div>
</form>
<br><br><br><br>
<pre>
NUMBER BRAND
_____________________________________
4242424242424242 Visa
5555555555554444 Mastercard
378282246310005 American Express
6011111111111117 Discover
</pre>
<pre id="demo-log"></pre>
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<script type="text/javascript" src="../dist/js/DatPayment.js"></script>
<script type="text/javascript">
var payment_form = new DatPayment({
form_selector: '#payment-form',
card_container_selector: '.dpf-card-placeholder',
number_selector: '.dpf-input[data-type="number"]',
date_selector: '.dpf-input[data-type="expiry"]',
cvc_selector: '.dpf-input[data-type="cvc"]',
name_selector: '.dpf-input[data-type="name"]',
submit_button_selector: '.dpf-submit',
placeholders: {
number: '•••• •••• •••• ••••',
expiry: '••/••',
cvc: '•••',
name: 'DUPONT'
},
validators: {
number: function(number){
return Stripe.card.validateCardNumber(number);
},
expiry: function(expiry){
var expiry = expiry.split(' / ');
return Stripe.card.validateExpiry(expiry[0]||0,expiry[1]||0);
},
cvc: function(cvc){
return Stripe.card.validateCVC(cvc);
},
name: function(value){
return value.length > 0;
}
}
});
var demo_log_div = document.getElementById("demo-log");
payment_form.form.addEventListener('payment_form:submit',function(e){
var form_data = e.detail;
payment_form.unlockForm();
demo_log_div.innerHTML += "<br>"+JSON.stringify(form_data);
});
payment_form.form.addEventListener('payment_form:field_validation_success',function(e){
var input = e.detail;
demo_log_div.innerHTML += "<br>field_validation_success:"+input.getAttribute("data-type");
});
payment_form.form.addEventListener('payment_form:field_validation_failed',function(e){
var input = e.detail;
demo_log_div.innerHTML += "<br>field_validation_failed:"+input.getAttribute("data-type");
});
</script>
</body>
</html>