-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmockBE.js
More file actions
48 lines (46 loc) · 1.02 KB
/
mockBE.js
File metadata and controls
48 lines (46 loc) · 1.02 KB
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
const WebSocket = require('ws')
const _ = require('lodash')
const wss = new WebSocket.Server({ port: 3000 })
const H_PAYMENT_CREATED = {
type: 'H_PAYMENT_CREATED',
data: {
usdAmount: 100.00,
payer: {
isoCountryCode: 'US',
state: 'FL',
province: null,
city: 'Tampa',
primaryCurrency: 'USD',
postalCode: '33603',
},
payee: {
isoCountryCode: 'IN',
state: null,
province: 'Uttar Pradesh',
city: 'Agra',
postalCode: '282001',
primaryCurrency: 'INR',
},
},
}
const H_ACCOUNT_CREATED = {
type: 'H_ACCOUNT_CREATED',
data: {
isoCountryCode: 'US',
state: 'FL',
province: null,
city: 'Tampa',
postalCode: '33603',
primaryCurrency: 'USD',
},
}
wss.on('connection', function connection (ws) {
// This fires a H_PAYMENT_CREATED every 20 seconds
setInterval(() => {
if (_.random(0, 1)) {
ws.send(JSON.stringify(H_PAYMENT_CREATED))
} else {
ws.send(JSON.stringify(H_ACCOUNT_CREATED))
}
}, 5000)
})