-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayment-server.js
More file actions
29 lines (26 loc) · 914 Bytes
/
payment-server.js
File metadata and controls
29 lines (26 loc) · 914 Bytes
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
const express = require('express');
const axios = require('axios');
const app = express();
app.get('/pay', async (req, res) => {
try {
const response = await axios.post('https://test.instamojo.com/api/1.1/payment-requests/', {
purpose: "Test Payment",
amount: "100",
buyer_name: "Test User",
email: "pratikmorkar000@gmail.com",
phone: "8369775954",
redirect_url: "https://pagarpiyush347.com/payment-success"
}, {
headers: {
'X-Api-Key': '9b9066f41a817005073f3a1e36582ed3',
'X-Auth-Token': 'a6053cf745808968c1885a184a0359c9'
}
});
// Redirect user to Instamojo payment page
res.redirect(response.data.payment_request.longurl);
} catch (err) {
console.error(err.response?.data || err.message);
res.send("Error initiating payment.");
}
});
app.listen(3000, () => console.log("Payment server running on port 3000"));