forked from vgs-samples/vgs-collect-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshipping-info-example.html
246 lines (227 loc) · 7.49 KB
/
shipping-info-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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>VGS Collect Shipping Info Example</title>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous"
/>
<script src="https://js.verygoodvault.com/vgs-collect/2.14.0/vgs-collect.js"></script>
<style>
body {
padding: 25px;
}
span[id*="cc-"] {
display: block;
height: 40px;
margin-bottom: 15px;
}
span[id*="cc-"] iframe {
height: 100%;
width: 100%;
}
pre {
font-size: 12px;
}
.form-field {
display: block;
width: 100%;
height: calc(2.25rem + 2px);
padding: 0.375rem 0.75rem;
font-size: 1rem;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 0.25rem;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.form-field iframe {
border: 0 none transparent;
height: 100%;
vertical-align: middle;
width: 100%;
}
p {
margin-bottom: 10px;
}
</style>
</head>
<body>
<main>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-4">
<div class="row card card-outline-secondary">
<div class="card-body">
<h3 class="text-center">Credit Card Payment</h3>
<hr />
<div class="alert alert-info p-2">
Please fill in and submit a form to see redacted data in
response window.
</div>
<form id="cc-form-shipping-info">
<div class="form-group">
<label for="cc-first-name">First Name</label>
<span id="cc-first-name" class="form-field">
<!--VGS Collect iframe for the first name field will be here!-->
</span>
</div>
<div class="form-group">
<label for="cc-last-name">Last Name</label>
<span id="cc-last-name" class="form-field">
<!--VGS Collect iframe for the last name field will be here!-->
</span>
</div>
<div class="form-group">
<label for="cc-address">Address</label>
<span id="cc-address" class="form-field">
<!--VGS Collect iframe for address field will be here!-->
</span>
</div>
<div class="form-group">
<label for="cc-country">Country</label>
<span id="cc-country" class="form-field">
<!--VGS Collect iframe for the country field will be here!-->
</span>
</div>
<div class="form-group">
<label for="cc-city">City</label>
<span id="cc-city" class="form-field">
<!--VGS Collect iframe for the city field will be here!-->
</span>
</div>
<div class="form-group">
<label for="cc-region">Region</label>
<span id="cc-region" class="form-field">
<!--VGS Collect iframe for the region field will be here!-->
</span>
</div>
<div class="form-group">
<label for="cc-zip">Zip Code</label>
<span id="cc-zip" class="form-field">
<!--VGS Collect iframe for zip code field will be here!-->
</span>
</div>
<!--Submit credit card form button-->
<button type="submit" class="btn btn-success btn-block">
Submit
</button>
</form>
</div>
</div>
</div>
<div class="col-md-4">
<div class="alert alert-secondary">
<h5 class="text-center">Instruction</h5>
<p>
1. Make sure you initialize form using correct vault id and
environment params.
</p>
<p>
2. Create an inbound route, proceed to Logs on a Dashboard and
start recording traffic.
</p>
<p>3. Fill in and submit the form.</p>
<p>
4. Open Logs, find your POST request and secure fields that you
want to be redacted.
</p>
<p>5. Submit form one more time.</p>
</div>
<div class="alert alert-warning">
<h5 class="text-center">Response</h5>
<pre id="result">
Submit a form to see result.
</pre
>
</div>
</div>
</div>
</main>
<!--Include script with VGS Collect form initialization-->
<script>
// VGS Collect form initialization
const form = VGSCollect.create(
"<vault-id>",
"<environment>",
function (state) {}
);
// Create VGS Collect field for the first name
form.field("#cc-first-name", {
type: "text",
name: "shipping_first_name",
placeholder: "Joe",
validations: ["required"],
});
// Create VGS Collect field for the last name
form.field("#cc-last-name", {
type: "text",
name: "shipping_last_name",
placeholder: "Business",
validations: ["required"],
});
// Create VGS Collect field for an address
form.field("#cc-address", {
type: "text",
name: "shipping_address",
placeholder: "Address",
validations: ["required"],
});
// Create VGS Collect field for country
form.field("#cc-country", {
type: "dropdown",
name: "shipping_country",
placeholder: "Select Country",
validations: ["required"],
options: [
{ value: "USA", text: "United States of America" },
{ value: "Canada", text: "Canada" },
{ value: "Mexica", text: "Mexica" },
],
});
// Create VGS Collect field for the city
form.field("#cc-city", {
type: "text",
name: "shipping_city",
placeholder: "City",
validations: ["required"],
});
// Create VGS Collect field for the region
form.field("#cc-region", {
type: "text",
name: "shipping_region",
placeholder: "Region",
validations: ["required"],
});
// Create VGS Collect field for zip code
form.field("#cc-zip", {
type: "zip-code",
name: "shipping_zip",
placeholder: "Zip Code",
validations: ["required"],
});
// Submits all of the form fields by executing a POST request.
document.getElementById("cc-form-shipping-info").addEventListener(
"submit",
function (e) {
e.preventDefault();
form.submit("/post", {}, function (status, data) {
document.getElementById("result").innerHTML = JSON.stringify(
data.json,
null,
4
);
});
},
function (errors) {
document.getElementById("result").innerHTML = errors;
}
);
</script>
</body>
</html>