-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
84 lines (68 loc) · 2.8 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
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/md5.js"></script>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.0.0-alpha.1/axios.min.js"
integrity="sha512-xIPqqrfvUAc/Cspuj7Bq0UtHNo/5qkdyngx6Vwt+tmbvTLDszzXM0G6c91LXmGrRx8KEPulT+AfOOez+TeVylg=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<title>Document</title>
</head>
<body>
<script>
let example = {
m_shop: "1693427769",
m_orderid: "12345",
m_amount: "121.00",
m_curr: "USD",
m_desc: btoa("Test121"),
m_key : "12345" // 515100
}
function hash(string) {
const utf8 = new TextEncoder().encode(string);
return crypto.subtle.digest('SHA-256', utf8).then((hashBuffer) => {
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray
.map((bytes) => bytes.toString(16).padStart(2, '0'))
.join('');
return hashHex;
});
}
let sendRequest = (obj)=>{
let params = "";
Object.keys(obj).forEach(key=> params +=`${key}=${obj[key]}&`)
console.log(`https://payeer.com/merchant/?${params}`);
let url = `https://payeer.com/merchant/?${params}`;
fetch(url , {
method : "POST",
cors : "no-cors"
})
.then((response) => {
return response.json();
})
.then((data) => {
console.log("data" , data);
});
}
let arr = Object.values(example) ;
let result = hash(arr.join(":")).then(res=>{
example.m_sign = res.toUpperCase();
document.body.insertAdjacentHTML('beforeend', `<form method="post" action="https://payeer.com/merchant/">
<input type = "hidden" name = "m_shop" value = "${example.m_shop}" >
<input type="hidden" name="m_orderid" value="${example.m_orderid}">
<input type="hidden" name="m_amount" value="${example.m_amount}">
<input type="hidden" name="m_curr" value="${example.m_curr}">
<input type="hidden" name="m_desc" value="${example.m_desc}">
<input type="hidden" name="m_sign" value="${example.m_sign}">
<button id="send" type="submit" name="m_process" value="sendTestRequest">SENDAAAA</button>
</form>`);
});
setTimeout(()=>{
let btn = document.getElementById("send");
btn && btn.click();}, 2000)
</script>
</body>
</html>