-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
59 lines (46 loc) · 1.36 KB
/
app.js
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
const express = require("express");
const exphbs = require("express-handlebars");
const bodyParser = require("body-parser");
const Paysera = require("paysera-nodejs");
const WebToPay = require("./lib/web-to-pay.js");
const app = express();
app.engine("handlebars", exphbs({ defaultLayout: "main" }));
app.set("view engine", "handlebars");
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(`${__dirname}/public`));
app.post("/charge", (req, res) => {
let options = {
projectid: "222845",
sign_password: "27cba94c9a9fe4283458e52c09592890",
accepturl: "https://audrius.herokuapp.com/success",
cancelurl: "https://audrius.herokuapp.com/cancel",
callbackurl: "https://audrius.herokuapp.com",
test: 1,
};
let paysera = new Paysera(options);
let params = {
payment: "",
frame: "1",
orderid: 1234567,
p_email: "[email protected]",
amount: 10,
currency: "EUR",
};
var urlToGo = paysera.buildRequestUrl(params);
res.status(200);
res.redirect(`${urlToGo}`);
});
app.get("/", (req, res) => {
res.render("index", {});
});
app.get("/cancel", (req, res) => {
res.render("cancel", {});
});
app.get("/success", (req, res) => {
res.render("success", {});
});
const port = process.env.PORT || 3338;
app.listen(port, () => {
console.log(`Server started on port ${port}`);
});