-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathexample-6.js
More file actions
63 lines (51 loc) · 1.68 KB
/
example-6.js
File metadata and controls
63 lines (51 loc) · 1.68 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
const fieldsExample6 = dlocalInstance.fields({
fonts: [{
cssSrc: 'https://rsms.me/inter/inter-ui.css'
}],
locale: 'en',
country: 'BR'
});
const cardExample6 = fieldsExample6.create('card', {
style: {
base: {
fontSize: "16px",
fontFamily: "'Inter UI medium', sans-serif",
lineHeight: '18px',
fontSmoothing: 'antialiased',
fontWeight: '500',
color: "#666",
'::placeholder': {
color: "#aab7c4"
},
iconColor: "#adbfd3"
}
}
});
document.getElementById('fields-form-example-6').onsubmit = function (e) {
e.preventDefault();
var example = document.querySelector(".example-6");
var form = example.querySelector('form');
var error = form.querySelector('.error');
var errorMessage = error.querySelector('.message');
if (errorMessage.innerText) {
return;
}
// Show a loading screen...
example.classList.add('submitting');
dlocalInstance.createToken(cardExample6, {
name: "Test"
}).then((result) => {
error.classList.remove('visible');
errorMessage.innerText = "";
example.classList.remove('submitting');
example.querySelector(".token").innerText = result.token;
example.classList.add("submitted");
}).catch((result) => {
example.classList.remove('submitting');
error.classList.add('visible');
errorMessage.innerText = result.error.message;
});
}
registerClearBtn("example-6", [cardExample6])
registerEvents("example-6", [cardExample6], ["example-6-card"])
cardExample6.mount(document.getElementById('example-6-card'));