-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
108 lines (98 loc) · 2.82 KB
/
index.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
97
98
99
100
101
102
103
104
105
106
107
108
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<style>
.form-wrapper
{
padding: 10px 100px;
}
.amount_wrapper
{
margin: 20px 0;
}
</style>
</head>
<body>
<div class="form-wrapper">
<h1>Card Form</h1>
<hr>
<form>
<div>
<label>
Amount($)
<input id="amount" type="number">
</label>
</div>
</form>
<justifi-card-form style-overrides='{
"layout":{
"padding":"0",
"formCon>trolSpacingHorizontal":".5rem",
"formControlSpacingVertical":"1rem"
},
"formLabel":{
"fontWeight":700,
"fontFamily":"sans-serif",
"margin":"0 0 .5rem 0"
},
"formControl":{
"backgroundColor":"#F4F4F6",
"backgroundColorHover":"#EEEEF5",
"borderColor":"rgba(0, 0, 0, 0.42)",
"borderColorHover":"rgba(0, 0, 0, 0.62)",
"borderColorFocus":"#fccc32",
"borderColorError":"#C12727",
"borderWidth":"0px",
"borderBottomWidth":"1px",
"borderRadius":"4px 4px 0 0",
"borderStyle":"solid",
"boxShadowErrorFocus":"none",
"boxShadowFocus":"none",
"color":"#212529",
"fontSize":"1rem",
"fontWeight":"400",
"lineHeight":"2",
"margin":"0",
"padding":".5rem .875rem"
},
"errorMessage":{
"color":"#C12727",
"margin":".25rem 0 0 0",
"fontSize":".875rem"
}
}'></justifi-card-form>
<button type="submit" id="card-pay-button">Pay</button>
</div>
<!-- Add your site or application content here -->
<script type='module' src="https://cdn.jsdelivr.net/npm/@justifi/[email protected]/dist/webcomponents/webcomponents.esm.js"></script>
<script>
(function () {
const cardForm = document.querySelector('justifi-card-form');
const cardPayButton = document.querySelector('#card-pay-button');
const amountEl = document.getElementById("amount");
cardPayButton.addEventListener('click',(event) => {
const paymentMethodData = {
name: 'John Doe',
address_line1: '123 Broadway', // optional
address_line2: '', // optional
address_city: 'Minneapolis', // optional
address_state: 'MN', // optional
address_postal_code: '55413',
address_country: 'US', // optional
metadata: { something: "somevalue" } // optional
};
const amount = amountEl.value;
cardForm.tokenize('acc_58sfzGghtL2qDchgGKct3s', paymentMethodData, '')
.then((data) => {
// We gate UnAuthorized when we try to tokenize it...
console.log('justifi-card-form tokenized: ', data);
});
});
})();
</script>
</body>
</html>