-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest-notification-server.js
51 lines (43 loc) · 1.45 KB
/
test-notification-server.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
const express = require('express')
const bodyParser = require('body-parser')
const util = require('util')
const app = express()
const client = require('../build/main/index.js').default
const app = express()
const tClient = client({
username: 'Your_trustly_username',
password: 'Your_trustly_password',
privateKeyPath: 'Path/to/your/private/pem/file',
})
const port = process.env.PORT || 4343
app.use(bodyParser.raw())
app.use(bodyParser.json())
/* serves main page */
app.post('/notification', function (req, res) {
console.log('- Notification is comming. √')
tClient
.createNotificationResponse(req.body)
.then(function (data) {
console.log(util.inspect(data, false, 20, true))
res.send(data)
})
.catch(function (error) {
console.log('_Error')
console.log(util.inspect(error, false, 20, true))
})
})
app.get('/success', function (req, res) {
console.log('- Success payment was arrive.')
res.send('OK')
})
/* serves all the static files */
app.get('/fail', function (req, res) {
console.log('- Failed payment was arrive.')
res.send('OK')
})
app.listen(port, function () {
console.log('**********************************************')
console.log('* Trustly Server Tester *')
console.log('* >> Listening on 127.0.0.1:' + port + ' *')
console.log('**********************************************')
})