Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- otp_request.html +34 -0
- otp_request.js +37 -0
otp_request.html
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<!DOCTYPE html>
|
3 |
+
<html lang="en">
|
4 |
+
<head>
|
5 |
+
<meta charset="UTF-8">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>OTP Gateway</title>
|
8 |
+
</head>
|
9 |
+
<body>
|
10 |
+
<h2>Send OTP Request</h2>
|
11 |
+
|
12 |
+
<form id="otpForm">
|
13 |
+
<label for="isd_code">ISD Code:</label><br>
|
14 |
+
<input type="text" id="isd_code" name="isd_code" required><br><br>
|
15 |
+
|
16 |
+
<label for="phone">Phone Number:</label><br>
|
17 |
+
<input type="text" id="phone" name="phone" required><br><br>
|
18 |
+
|
19 |
+
<label for="tenant_id">Tenant ID:</label><br>
|
20 |
+
<input type="number" id="tenant_id" name="tenant_id" required><br><br>
|
21 |
+
|
22 |
+
<label for="product_id">Product ID:</label><br>
|
23 |
+
<input type="number" id="product_id" name="product_id" required><br><br>
|
24 |
+
|
25 |
+
<button type="submit">Send OTP</button>
|
26 |
+
</form>
|
27 |
+
|
28 |
+
<h3>Response:</h3>
|
29 |
+
<pre id="response"></pre>
|
30 |
+
|
31 |
+
<!-- Link to the external JavaScript file -->
|
32 |
+
<script src="otp_request.js"></script>
|
33 |
+
</body>
|
34 |
+
</html>
|
otp_request.js
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
document.getElementById("otpForm").addEventListener("submit", async function(event) {
|
3 |
+
event.preventDefault();
|
4 |
+
|
5 |
+
// Capture form values
|
6 |
+
const isd_code = document.getElementById("isd_code").value;
|
7 |
+
const phone = document.getElementById("phone").value;
|
8 |
+
const tenant_id = document.getElementById("tenant_id").value;
|
9 |
+
const product_id = document.getElementById("product_id").value;
|
10 |
+
|
11 |
+
// Construct API payload
|
12 |
+
const payload = {
|
13 |
+
isd_code: isd_code,
|
14 |
+
phone: phone,
|
15 |
+
tenant_id: parseInt(tenant_id),
|
16 |
+
product_id: parseInt(product_id)
|
17 |
+
};
|
18 |
+
|
19 |
+
try {
|
20 |
+
// Send POST request to the API
|
21 |
+
const response = await fetch("https://otp.infinitylearn.com/api/getGatewayOtp", {
|
22 |
+
method: "POST",
|
23 |
+
headers: {
|
24 |
+
"Content-Type": "application/json"
|
25 |
+
},
|
26 |
+
body: JSON.stringify(payload)
|
27 |
+
});
|
28 |
+
|
29 |
+
// Parse JSON response
|
30 |
+
const data = await response.json();
|
31 |
+
|
32 |
+
// Display the response in the preformatted section
|
33 |
+
document.getElementById("response").textContent = JSON.stringify(data, null, 2);
|
34 |
+
} catch (error) {
|
35 |
+
document.getElementById("response").textContent = "Error: " + error.message;
|
36 |
+
}
|
37 |
+
});
|